1

I want to join an IRC room, using TIdIRC + Lazarus. I am familair with this discussion.

This is my code :

procedure TForm1.Button4Click(Sender: TObject);
begin
  if Edit3.Text = '' then
  begin
     log('ERROR :  Nick unknown, specify a Nick (look for the textbox saying ''Nick'' and replace it)', Memo3);
     log('ERROR :  Also provide Real Name and Alt Nic', Memo3);
     Edit3.Text:= 'Nick';
     Edit6.Text:= 'Real Name';
  end
  else
     if Edit6.Text = '' then
     begin
       log('ERROR :  Real Name unknown, provide Real Name', Memo3);
     end
     else
     begin
       IdIRC1.Host:=Edit1.Text;
       IdIRC1.Port:=StrToInt(Edit5.Text);
       IdIRC1.Nickname:=Edit4.Text;
       IdIRC1.Username:=Edit4.Text;
       IdIRC1.RealName:=Edit6.Text;
       IdIRC1.AltNickname:=Edit7.Text;

       log('Attempting to connect .. ', Memo1);
       IdIRC1.Connect;
       if IdIRC1.Connected then
       begin
         log('Connected ! ' , Memo1);
         {Trying to join a channel .. }
         if Edit4.Text = '' then
         begin
           IdIRC1.Join(Edit2.Text);
//           IdIRC1.OnJoin:=;
           log('channel joined', Memo1);
         end
         else
         begin
           IdIRC1.Join(Edit2.Text, Edit4.Text);
           log('channel joined with password', Memo1);
         end;

       end
       else
       begin
       end;
     end;

  begin
  end;
end;      

The log message "Connected !" is printed. Since this will happen after IdIRC1.Connect() is exited, and IdIRC1.Connected is found to be true, I am assuming that connection was established.

However, IdIRC1.Join() is not connecting.

Edit2.Text is set to '#Orcan'; while Edit4.Text is set to '' (an empty string).

I am recieving an error message:

Project has raised Exception class EIdConnClosedGracefully with the message :
Connection Closed gracefully 

I am at the same time, from the same computer, logged in to irc.freenode.net , where the program is supposed to connect to, using konversations. In the user list the program, using the preset nick name, does not show up.

What am I doing wrong?

Community
  • 1
  • 1
Sean
  • 789
  • 6
  • 26
  • `IdIRC1.Connected` merely tells you if the underlying socket is connected, not whether you are actually logged in to the server. And remember that IRC is primarily asynchronous, so many things do not take place inside of `Connect()` itself, they are handled in a background thread. `Connect()` starts the thread and issues `PASS`, `NICK`, and `USER` commands, but does not wait for their responses, the thread handles them... – Remy Lebeau Apr 06 '15 at 18:08
  • ... `EIdConnClosedGracefully` means the server disconnected you. Maybe login failed, or wasn't complete yet, before you called `Join()`. For instance, is your client app running an `IDENT` server? Many IRC servers require that as part of login. Indy has a `TIdIdentServer` component. If that is not solving the problem for you, then please show the actual command/response log from another IRC app, like mIRC, and compare that to what `TIdIRC` is generating. – Remy Lebeau Apr 06 '15 at 18:12

0 Answers0