Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8185671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:55:51+00:00 2026-06-07T01:55:51+00:00

I’m trying to make a console application based on Indy’s IRC Component (TIdIRC) but

  • 0

I’m trying to make a console application based on Indy’s IRC Component (TIdIRC) but I’m having trouble with events. Here’s my code:

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Classes,
  Math,
  IdBaseComponent,
  IdComponent,
  IdTCPConnection,
  IdTCPClient,
  IdIRC;

type
  TEvents = class
  public
    procedure Raw(Sender: TObject; AUser: TIdIRCUser; ACommand, AContent: String; var Suppress: Boolean);
  end;

const
  IrcServ = 'gr.irc.gr';
  IrcPort = 6667;
  IrcChan = '#lalala';

var
  Irc: TidIRC;
  Event: TEvents;
  uName, rName: string;

function Log(s: string): string;
var now: TDateTime;
begin
  now := Time;
  result := FormatDateTime('[hh:nn:ss] ', now) + s;
end;

procedure TEvents.Raw(Sender: TObject; AUser: TIdIRCUser; ACommand, AContent: String; var Suppress: Boolean);
begin
  Log(AUser.Nick+' '+ACommand+' '+AContent);
end;

begin
  Event := TEvents.Create;
  Irc := TidIRC.Create(nil);
  Irc.OnRaw := Event.Raw;
  Randomize;
  Write('Nickname: ');
  ReadLn(uName);
  rName := 'IDM' + IntToStr(RandomRange(1000, 9999)) + uName;
  with Irc do begin
    AltNick := 'IDM' + IntToStr(RandomRange(1000, 9999)) + uName;
    Nick := rName;
    Username := rName;
    RealName := 'I.D.M.';
    Host := IrcHost;
    Port := IrcPort;
    //MaxLineAction := maException;  <-- [ERROR] Undeclared identifier: 'maException'
    ReadTimeout := 0;
    UserMode := [];
    Connect();
    Join(IrcChan);
  end;
  ReadLn;

end.

I’ve tried so far everything i could think of, but, although the app is connected successfully, it won’t return any raw message… What am i missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:55:53+00:00Added an answer on June 7, 2026 at 1:55 am

    TdIRC uses an internal worker thread to receive data. The OnRaw event is triggered when that thread is parsing data. The thread uses TThread.Synchronize() to do that parsing. Since your main thread does not have an active VCL message loop, you can pump the Synchronize() queue manually. After you connect, call the CheckSynchronize() function from the Classes unit in a loop while you are connected to IRC, eg:

    begin 
      ...
      Connect; 
      try
        Join(IrcChan); 
        do
          CheckSynchronize;
          Sleep(10);
        until SomeCondition;
      finally
        Disconnect;
      end;
      ...  
    end. 
    

    For good measure, you can assign a handler to the WakeMainThread event in the Classes unit to help control when CheckSynchronize() should be called, so the main thread can go to sleep while the IRC connection is idle, eg:

    program Project1;     
    
    {$APPTYPE CONSOLE}     
    
    uses     
      SysUtils,     
      Classes,     
      Math,     
      IdBaseComponent,     
      IdComponent,     
      IdTCPConnection,     
      IdTCPClient,     
      IdIRC;     
    
    type     
      TEvents = class     
      private
        FSyncEvent: TEvent;
      public     
        constructor Create;
        destructor Destroy; override;
        procedure Raw(Sender: TObject; AUser: TIdIRCUser; ACommand, AContent: String; var Suppress: Boolean);     
        procedure Wake(Sender: TObject);
        procedure CheckSync;
      end;     
    
    function Log(s: string): string;      
    begin      
      result := FormatDateTime('[hh:nn:ss] ', Time) + s;      
    end;      
    
    constructor TEvents.Create;
    begin
      inherited;
      FSyncEvent := TEvent.Create(nil, False, False, '');
    end;
    
    destructor TEvents.Destroy;
    begin
      FSyncEvent.Free;
      inherited;
    end;
    
    procedure TEvents.Raw(Sender: TObject; AUser: TIdIRCUser; ACommand, AContent: String; var Suppress: Boolean);      
    begin      
      Log(AUser.Nick+' '+ACommand+' '+AContent);      
    end;      
    
    procedure TEvents.Wake(Sender: TObject);
    begin
      FSyncEvent.SetEvent;
    end;
    
    procedure TEvents.CheckSync;
    begin
      FSyncEvent.WaitFor(Infinite);
      CheckSynchronize;
    end;
    
    const     
      IrcServ = 'gr.irc.gr';     
      IrcPort = 6667;     
      IrcChan = '#lalala';     
    
    var      
      Irc: TidIRC;      
      Event: TEvents;      
      uName, rName: string;      
    
    begin
      Event := TEvents.Create;       
      try
        WakeMainThread := Event.Wake;
        Irc := TIdIRC.Create(nil);       
        try
          Irc.OnRaw := Event.Raw;       
          Randomize;       
          Write('Nickname: ');       
          ReadLn(uName);       
          rName := 'IDM' + IntToStr(RandomRange(1000, 9999)) + uName;       
          with Irc do begin       
            AltNick := 'IDM' + IntToStr(RandomRange(1000, 9999)) + uName;
            Nick := rName;       
            Username := rName;       
            RealName := 'I.D.M.';       
            Host := IrcHost;       
            Port := IrcPort;       
            //MaxLineAction := maException;  <-- [ERROR] Undeclared identifier: 'maException'       
            ReadTimeout := 0;       
            UserMode := [];       
            Connect;       
            try
              Join(IrcChan);       
              do
                Event.CheckSync;
              until SomeCondition;
            finally
              Disconnect;
            end;
          end;       
        finally
          Irc.Free;
        end;
      finally
        Event.Free;
      end;
    end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.