Home arrow Delphi-Kylix arrow Page 3 - Building an IRC Client
DELPHI-KYLIX

Building an IRC Client


If you have ever wanted to build your own IRC client, keep reading. In this third part of a three-part article series, you will learn how to build an IRC client in Delphi from scratch, with assistance from Indy. While not all possible commands will be implemented, you will learn enough to add to and modify the code as you see fit.

Author Info:
By: Leidago
Rating: 5 stars5 stars5 stars5 stars5 stars / 7
January 22, 2007
TABLE OF CONTENTS:
  1. · Building an IRC Client
  2. · Procedures
  3. · More Procedures
  4. · Sending Messages
  5. · Processing Server Commands

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Building an IRC Client - More Procedures
(Page 3 of 5 )

The Say() procedure enables you to send a message either to the channel or to another user:

procedure TForm1.Button2Click(Sender: TObject);

begin

idIRC1.Say(edit3.text, Memo2.Text);

Memo1.Lines.Add(IdIRC1.Nickname + ': '+Memo2.Text);

Memo2.Lines.Clear;

end;

With the following code you just display the message from the administrator:

procedure TForm1.IdIRC1AdminInfoReceived(ASender: TIdContext;

  AAdminInfo: TStrings);

var

  i:integer;

begin

for i:= 0 to AAdminInfo.Count-1 do begin

memo1.lines.add(AAdminInfo.Strings[i]);

end;

end;

Notice that the message is in a TStrings object. This requires us to loop through the object and then display the information contained within it in a memo.

procedure TForm1.IdIRC1Connect(Sender: TObject);

begin

Memo1.Lines.Add('Connection ok'); //this just confirms that we
are connected

end;

procedure TForm1.IdIRC1Status(ASender: TObject; const AStatus:
TIdStatus;

  const AStatusText: String);

begin

memo1.Lines.Add(AStatusText);

end;

The status procedure keeps us up to date on what the client is doing.

procedure TForm1.IdIRC1Join(ASender: TIdContext; ANickname,
AHost,

  AChannel: String);

begin

Memo1.Lines.Add('Join :' +AChannel+'NickName '+ANickName+' Host
'+AHost);

end;

This event is fired when a new user joins a channel. How much information you want about a user is up to you, but you can get the user's host name, the channel that the user joined and the user's nickname. I just added it all to the memo.

procedure TForm1.Memo2KeyDown(Sender: TObject; var Key: Word;

  Shift: TShiftState);

var

i : integer;

begin

if Key = VK_RETURN then

begin

idIRC1.Say(edit3.text, Memo2.Text);

Memo1.Lines.Add(IdIRC1.Nickname + ': '+Memo2.Text);

Memo2.Lines.Clear;

end;

end;


blog comments powered by Disqus
DELPHI-KYLIX ARTICLES

- Loading an XML Document into the DOM
- Delphi Wrapper Classes and XML
- Delphi and the DOM
- Delphi and XML
- Internet Access: Client Service
- Finishing the Client for an Internet Access ...
- The Client for an Internet Access Control Ap...
- User Management for an Internet Access Contr...
- Important Procedures for an Internet Access ...
- Server Code for an Internet Access Control A...
- Constructing the Interface for an Internet A...
- Building a Server Application for an Interne...
- Building an Internet Access Control Applicat...
- Client Dataset: Working with Data Packets an...
- Using the Client Dataset in an N-Tiered Appl...

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 6 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials