{******************************************************************}
{ }
{ Delhiarea-IRC-Components 0.1.2 by Amnon82 (C)2006 AMSOFT }
{ }
{******************************************************************}
unit DA_IrcClient;
interface
uses
Windows, SysUtils, Classes, ScktComp, WinSock, DA_CutBreak
{, DesignIntf, DesignEditors};
type
TDA_IrcClient =
class;
Tstr200max =
String[200];
TManualAuto = (Manual, Auto);
TIDOnUnknownCTCPAnswer =
procedure(Sender: TDA_IrcClient; LongNick:
string; Nick:
string; CTCPOrder:
string; CTCPRequest:
string;
var CTCPAnswer:
string; RawData:
string)
of object;
TIDOnCTCPAction =
procedure(Sender: TDA_IrcClient; LongNick:
string; Nick:
string; MSGToSend:
string; Action:
string; RawData:
string)
of object;
TIDPing =
procedure(Sender: TDA_IrcClient; AutoAnswer:
string; RawData:
string)
of object;
TDccGet =
procedure(Sender: TDA_IrcClient; LongNick:
string; Nick:
string; FileName, SenderIPAddresse:
string; Port: integer; BytesToGet: Longint)
of object;
TDccResume =
procedure(Sender: TDA_IrcClient; LongNick:
string; Nick:
string; FileName:
string; Port: integer; BytesToGet: Longint)
of object;
TDccChat =
procedure(Sender: TDA_IrcClient; LongNick:
string; Nick:
string; SenderIPAddress:
string; Port: integer)
of object;
TIDRawData =
procedure(Sender: TDA_IrcClient; RawData:
string)
of object;
TIDKickMSG =
procedure(Sender: TDA_IrcClient; LongNick:
string; Nick:
string; Channel:
string; KickMSG:
string; RawData:
string)
of object;
TIDTopicMSG =
procedure(Sender: TDA_IrcClient; LongNick:
string; Nick:
string; Channel:
string; MSG:
string; RawData:
string)
of object;
TIDChannelMSG =
procedure(Sender: TDA_IrcClient; LongNick:
string; Nick:
string; Channel:
string; MSG:
string; RawData:
string)
of object;
TIDPrivateMSG =
procedure(Sender: TDA_IrcClient; LongNick:
string; Nick:
string; Priv:
string; MSG:
string; RawData:
string)
of object;
TIDOnNoticePrivateMSG =
procedure(Sender: TDA_IrcClient; LongNick:
string; Nick:
string; Notice:
string; MSG:
string; RawData:
string)
of object;
TIDOnNoticePublicMSG =
procedure(Sender: TDA_IrcClient; LongNick:
string; Nick:
string; Notice:
string; MSG:
string; RawData:
string)
of object;
TIDOnJoinMSG =
procedure(Sender: TDA_IrcClient; LongNick:
string; Nick:
string; Channel:
string; RawData:
string)
of object;
TIDOnPartMSG =
procedure(Sender: TDA_IrcClient; LongNick:
string; Nick:
string; Channel:
string; RawData:
string)
of object;
TIDOnCloseMSG =
procedure(Sender: TDA_IrcClient; LongNick:
string; Nick:
string; CloseMSG:
string; RawData:
string)
of object;
TIDOnNickChange =
procedure(Sender: TDA_IrcClient; OldLongNick:
string; OldShortNick:
string; NewNick:
string; RawData:
string)
of object;
TIDOnVersionRequest =
procedure(Sender: TDA_IrcClient; LongNick:
string; Nick:
string; RawData:
string)
of object;
TIDOnTimeRequest =
procedure(Sender: TDA_IrcClient; LongNick:
string; Nick:
string;
Var TimeAnswer:
string; RawData:
string)
of object;
TIDChannelNames =
procedure(Sender: TDA_IrcClient; LongNick:
string; chan:
string; NickName:
string; RawData:
string)
of object;
TIDChannelNamesEnd =
procedure(Sender: TDA_IrcClient; Channel:
string; RawData:
string)
of object;
TIDChannelTopic =
procedure(Sender: TDA_IrcClient; Channel:
string; Topic:
string; RawData:
string)
of object;
TIDNickInUse =
procedure(Sender: TDA_IrcClient; NickInUse:
string; RawData:
string)
of object;
TIDUnknownNumbers =
procedure(Sender: TDA_IrcClient; Number:
string; RawData:
string)
of object;
// type TSocketNotifyEvent = procedure (Sender: TObject; Socket: TCustomWinSocket) of object;
TDA_IrcClient =
class(TComponent)
Private
{ Private declarations }
CutBreak1: TDA_CutBreak;
CutBreak2: TDA_CutBreak;
tmplist: TStringList;
destroyb: Boolean;
procedure TriggerOnDataAvailable(Sender: TObject; Socket: TCustomWinSocket);
procedure TriggerOnDataSend(Sender: TObject; Socket: TCustomWinSocket);
procedure TriggerOnConnection(Sender: TObject; Socket: TCustomWinSocket);
procedure TriggerOnDisconnection(Sender: TObject; Socket: TCustomWinSocket);
procedure TriggerOnErrorMSG(Sender: TObject; Socket: TCustomWinSocket; FehlerEvent: TErrorEvent;
var FehlerCode: Integer);
procedure WorkOnMSG(Sender: TDA_IrcClient; MSGList: Tstringlist; RawData:
String);
procedure WorkOnCTCPMSG(Sender: TDA_IrcClient; LongNick :
String; Nick:
String; Source:
String; MSGList: TStringList; RawData:
String);
procedure WorkOnUndefinierteMSG(Sender: TDA_IrcClient; numerisch: Word; MSGList : Tstringlist; RawData:
String);
function isInteger(szString:
String):Boolean;
function CopyFrom(
const S:
String;
const Start: Integer):
String;
function CopyAt(
const S:
String;
const SearchFor:
String;
const Start: Integer):
String;
function CopyLeft(
const S:
String;
const Count: Integer):
String;
protected
{ Protected declarations }
FInBuf:
String;
FUserName:
String;
FRealName:
String;
FIRCHost:
String;
FIRCPort: Integer;
FEmail:
String;
FNickname:
String;
FAltNick:
String;
FIrcPassword:
String;
FPingAnswer: TManualAuto;
FChangeAltNick: TManualAuto;
FOnPing: TIDPing;
FOnCTCPAction: TIDOnCTCPAction;
FOnRawData: TIDRawData;
FOnMainServerChannelMSG: TIDChannelMSG;
FOnLocalServerChannelMSG: TIDChannelMSG;
FOnMainServerTopicMSG: TIDTopicMSG;
FOnLocalServerTopicMSG: TIDTopicMSG;
FOnMainServerNoticeMSG: TIDOnNoticePublicMSG;
FOnLocalServerNoticeMSG: TIDOnNoticePublicMSG;
FOnPrivateMSG: TIDPrivateMSG;
FOnNoticePrivateMSG: TIDOnNoticePrivateMSG;
FOnJoinMSG: TIDOnJoinMSG;
FOnPartMSG: TIDOnPartMSG;
FOnCloseMSG: TIDOnCloseMSG;
FMainServerKickMSG: TIDKickMSG;
FLocalServerKickMSG: TIDKickMSG;
FOnNickChange: TIDOnNickChange;
FOnVersionRequest: TIDOnVersionRequest;
FOnTimeRequest: TIDOnTimeRequest;
FDccGet: TDccGet;
FDccAccept: TDccResume;
FDccResume: TDccResume;
FDccChat: TDccChat;
FOnUnknownCTCPAnswer: TIDOnUnknownCTCPAnswer;
FOnNames: TIDChannelNames;
FOnNamesList: TIDChannelNamesEnd;
FOnTopic: TIDChannelTopic;
FOnNickInUse: TIDNickInUse;
FOnUnknownNumbers: TIDUnknownNumbers;
FCloseMSG: Tstr200max;
FVersionAnswer: Tstr200max;
FTag: integer;
FOnDataAvailable: TSocketNotifyEvent;
FOnDataSend: TSocketNotifyEvent;
FOnConnection: TSocketNotifyEvent;
FOnDisconnection: TSocketNotifyEvent;
FOnError: TSocketErrorEvent;
public
{ Public declarations }
ConnectIt: TClientSocket;
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
procedure Close;
procedure Connect;
procedure SelfInvisible;
procedure SelfVisible;
procedure KickUser(Channel, NickName, Grund:
String);
procedure DeBanUser(Channel, UserHostMask:
String);
procedure BanUser(Channel, UserHostMask:
String);
procedure DeVoiceUsers(Channel, UserNickname:
String);
procedure VoiceUsers(Channel, UserNickname:
String);
procedure DeopUsers(Channel, UserNickname:
String);
procedure OpUsers(Channel, UserNickname:
String);
procedure ChannelMode(Channel, Mode, Param:
String);
procedure UserMode(Mode:
String);
procedure ChangeNick(Nickname:
String);
procedure Join(Channel:
String);
procedure Part(Channel:
String);
procedure SendPrivateMSG(Nickname, MSG:
String);
procedure SendRawData(ZuSenddeMSG:
String);
function LongIPtoPointIP(value: LongWord):
String;
function PointIPtoLongIP(str: PChar): LongWord;
function SendChannelMSG(Chan, MSG:
String): Boolean;
published
{ Published declarations }
property VersionAnswer: Tstr200max
read FVersionAnswer
write FVersionAnswer;
property UserName:
String read FUserName
write FUserName;
property RealName:
String read FRealName
write FRealName;
property Email:
String read FEmail
write FEmail;
property NickName:
String read FNickname
write FNickname;
property AltNickName:
String read FAltNick
write FAltNick;
property IRCHost:
String read FIRCHost
write FIRCHost;
property IrcPort: Integer
read FIRCPort
write FIRCPort;
property IrcPassword:
String read FIrcpassword
write FIrcpassword;
property PingAnswer: TManualAuto
read FPingAnswer
write FPingAnswer;
property ChangeAltNick: TManualAuto
read FChangeAltNick
write FChangeAltNick;
property CloseMSG: Tstr200max
read FCloseMSG
write FCloseMSG;
property Tag: Integer
read FTag
write FTag;
property OnConnection: TSocketNotifyEvent
read FOnConnection
write FOnConnection;
property OnDisconnection : TSocketNotifyEvent
read FOnDisconnection
write FOnDisconnection ;
property OnError: TSocketErrorEvent
read FOnError
write FOnError;
property OnPing: TIDPing
read FOnPing
write FOnPing;
property OnLocalServerKick: TIDKickMSG
read FLocalServerKickMSG
write FLocalServerKickMSG;
property OnMainServerKick: TIDKickMSG
read FMainServerKickMSG
write FMainServerKickMSG;
property OnCTCPAction: TIDOnCTCPAction
read FOnCTCPAction
write FOnCTCPAction;
property OnRawData: TIDRawData
read FOnRawData
write FOnRawData;
property OnMainServerChannelMSG: TIDChannelMSG
read FOnMainServerChannelMSG
write FOnMainServerChannelMSG;
property OnLocalServerChannelMSG: TIDChannelMSG
read FOnLocalServerChannelMSG
write FOnLocalServerChannelMSG;
property OnMainServerNoticeMSG: TIDOnNoticePublicMSG
read FOnMainServerNoticeMSG
write FOnMainServerNoticeMSG;
property OnLocalServerNoticeMSG: TIDOnNoticePublicMSG
read FOnLocalServerNoticeMSG
write FOnLocalServerNoticeMSG;
property OnPrivateMSG: TIDPrivateMSG
read FOnPrivateMSG
write FOnPrivateMSG;
property OnNoticePrivateMSG: TIDOnNoticePrivateMSG
read FOnNoticePrivateMSG
write FOnNoticePrivateMSG;
property OnNickChange: TIDOnNickChange
read FOnNickChange
write FOnNickChange;
property OnJoinMSG: TIDOnJoinMSG
read FOnJoinMSG
write FOnJoinMSG;
property OnPartMSG: TIDOnPartMSG
read FOnPartMSG
write FOnPartMSG;
property OnCloseMSG: TIDOnCloseMSG
read FOnCloseMSG
write FOnCloseMSG;
property OnDccGet: TDccGet
read FDccGet
write FDccGet;
property OnDccAccept: TDccResume
read FDccAccept
write FDccAccept;
property OnDccResume: TDccResume
read FDccResume
write FDccResume;
property OnDccChat: TDccChat
read FDccChat
write FDccChat;
property OnVersionRequest: TIDOnVersionRequest
read FOnVersionRequest
write FOnVersionRequest;
property OnTimeRequest: TIDOnTimeRequest
read FOnTimeRequest
write FOnTimeRequest;
property OnTopic: TIDChannelTopic
read FOnTopic
write FOnTopic;
property OnNames: TIDChannelNames
read FOnNames
write FOnNames;
property OnNamesList: TIDChannelNamesEnd
read FOnNamesList
write FOnNamesList;
property OnNickInUse: TIDNickInUse
read FOnNickInUse
write FOnNickInUse;
property OnUnknownNumbers: TIDUnknownNumbers
read FOnUnknownNumbers
write FOnUnknownNumbers;
property OnUnknownCTCPAnswer: TIDOnUnknownCTCPAnswer
read FOnUnknownCTCPAnswer
write FOnUnknownCTCPAnswer;
property OnMainServerTopicMSG: TIDTopicMSG
read FOnMainServerTopicMSG
write FOnMainServerTopicMSG;
property OnLocalerServerTopicMSG: TIDTopicMSG
read FOnLocalServerTopicMSG
write FOnLocalServerTopicMSG;
end;
procedure Register;
const
CR = #13;
LF = #10;
CRLF = #13#10;
Version = '
TDA_IrcClient 0.1.2 - (C) 2006 by AMSOFT and DELPHIAREA';
var
CuttedMSG:
String;
implementation
// Komponente registrieren
procedure Register;
begin
RegisterComponents('
Delphiarea', [TDA_IrcClient]);
//Mal ein Beispiel, was noch nicht klappt:
//RegisterPropertyInCategory('DCC', TDA_IrcClient, 'OnDccAccept');
end;