![]() |
Re: Irc mit Indy
Hi,
Nickname? Mein Test-Code:
Delphi-Quellcode:
Muss natürlich noch verbessert werden... Ist ja erstmal nur zum Test.
//IRC = TIdIRC
IRC.OnPrivateMessage := HandleMsg; IRC.OnNotice := HandleMsg; IRC.OnWallops := HandleMsg2; //IRC.OnRaw := HandleRaw; IRC.Nickname := NickEdit.Text; IRC.RealName := 'FAlter Bot'; IRC.Username := 'FAlterBot'; IRC.Host := ServerEdit.Text; IRC.Port := StrToIntDef(PortEdit.Text, IRC.Port); IRC.Connect; Mfg FAlter [edit] Aus der IdIRC.Pas: (Indy 10)
Delphi-Quellcode:
In der markierten Zeile liegt ein Fehler. Das -2 ist falsch und kann sogar komplett weggelassen werden, ansonsten kommt da -1 hin. Das erklärt das Fehlen des letzten Buchstabens.
procedure TIdIRC.CommandPRIVMSG(ASender: TIdCommand);
var LTmp: String; begin if ASender.Params[0][1] = #1 then begin ParseCTCPQuery(ASender.Params[1], ASender.Params[0]); end else if Assigned(FOnPrivMessage) then begin LTmp := copy(ASender.Params[1], 2, length(ASender.Params[1]) - 2); ///!!!!!!!!!!!!!!! OnPrivateMessage(ASender.Context, FSenderNick, FSenderHost, ASender.Params[0], LTmp); end; end; Die anderen Worte liegen vermutlich in Params[3]..Params[Count-1], schätz ich mal. [/edit] [edit] Mit dieser Änderung gehts erstmal. Ist natürlich nicht gerade optimal, wenns erst auseinandergepflückt und hier wieder zusammengesetzt wird, erstmal reichts jedoch. Der Bot muss "liest" trotzdem schneller als ein Mensch.
Delphi-Quellcode:
[/edit]
procedure TIdIRC.CommandPRIVMSG(ASender: TIdCommand);
var LTmp: String; I: Integer; begin if ASender.Params[0][1] = #1 then begin ParseCTCPQuery(ASender.Params[1], ASender.Params[0]); end else if Assigned(FOnPrivMessage) then begin LTmp := copy(ASender.Params[1], 2, length(ASender.Params[1])); for I := 2 to ASender.Params.Count - 1 do LTmp := LTmp + ' ' + ASender.Params[I]; OnPrivateMessage(ASender.Context, FSenderNick, FSenderHost, ASender.Params[0], LTmp); end; end; procedure TIdIRC.CommandNOTICE(ASender: TIdCommand); var LTmp: String; I: Integer; begin if ASender.Params[0][1] = #1 then begin ParseCTCPReply(ASender.Params[1], ASender.Params[0]); end else if Assigned(FOnNotice) then begin LTmp := copy(ASender.Params[1], 2, length(ASender.Params[1])); for I := 2 to ASender.Params.Count - 1 do LTmp := LTmp + ' ' + ASender.Params[I]; OnNotice(ASender.Context, FSenderNick, FSenderHost, ASender.Params[0], LTmp); end; end; |
Re: Irc mit Indy
Ich habe das Tutorial mal aus gegebenem Anlass ins Englische übersetzt, damit unser User dangerduck auch was davon versteht. Ich hoffe, MSSSSM hat nichts dagegen. :-)
--- Hello and welcome! This post is about the Indy IRC component. You can download it ![]() Let's begin: First, put the Indy IRC component on your form. Form.Create should now look like the following:
Delphi-Quellcode:
With this you define the settings for the connection.
IdIRC1.Nick:='MyNick'; // Defines the nickname
IdIRC1.Host:='irc.server.org'; // Defines the Server IdIRC1.Port:=6667; //Irc Port Now we have to connect: Put a button on your form and create the onClick-event: The buttons caption should be 'Connect' Put in this code:
Delphi-Quellcode:
You should make a buton with the folling code in the onClick-event
try // try ...
IdIRC1.Connect(); // ... to connect except // ... when an error happens ... showMessage('Fehler beim Verbinden!'); // ... show a message end;
Delphi-Quellcode:
Now you can already connect and join a channel.
IdIRC1.Join('#lima-city');
But to display messages later, you should put a the TMemo component on the form. The you have to add two events: OnReceive and OnMessage. OnReceive (It only works with this additional event):
Delphi-Quellcode:
OnMessage:
Memo1.lines.add(ACommand); // add to memo
Delphi-Quellcode:
Memo1.lines.add(AUser.Nick+': '+Content); // Add message
Now you can already receive a message, but it lacks writing yet. Put a TEdit and a TButton component on your form. The button gets the caption "Send". The OnClick-event is:
Delphi-Quellcode:
Now you can send and receive messages with that.
IdIRC1.Say('#CHANNEL',Edit1.Text); // Send message to the channel
Memo1.Lines.Add(IdIRC1.Nick+': '+Edit1.Text); // Ad to memo, because the OnMessage event won't be called when sending own messages Put the following into the forms OnClose event:
Delphi-Quellcode:
IdIRC1.Disconnect(); // to stop
Additional code: Create a TListBox. Create the OnNames event and write:
Delphi-Quellcode:
Now you have a working IRC client!
var
i: integer; //begin for i:=0 to AUsers.Count-1 do // execute as many times as users in the channel ListBox1.Items.Add(AUsers.Items[i].Nick); // Add to ListBox //end Tip: Build an IRC-bot, you only have to work with the content in OnMessage! |
Re: Irc mit Indy
Hi,
Du solltest noch dazu schreiben, ob es sich um die Indy 9 oder Indy 10 handelt! |
Re: Irc mit Indy
Zitat:
Mit freundlichen Grüßen, Valle |
Re: Irc mit Indy
Er als Autor. Ich meinte, dass er es ins Tutorial schreiben soll und nicht nur in ein paar Beiträgen drunter.
|
Re: Irc mit Indy
Danke!
:-D |
Re: Irc mit Indy
download link doestn work :cry:
could someone upload it on rapidshare or megaupload please :D |
Re: Irc mit Indy
Which link do you mean?
|
Re: Irc mit Indy
Zitat:
![]() Everywhere I click, sooner or later I always find this page. But I don't know where to go now, there's no "Continue" button, no "Download" button. And every link on this page results in a 404 error page. :? |
Re: Irc mit Indy
Maybe you can have a look at
![]() |
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:29 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz