Tootoot222
2009-02-08 08:41:53
Yes! This is my IRC bot that I made! (I based it off of yakman's IScarC)
Have fun!
(This requires SCAR 3.15+, it now has Explode and Implode within the script (if you're using 3.20 you can take them out, as it will make it a little faster))
Have fun!
(This requires SCAR 3.15+, it now has Explode and Implode within the script (if you're using 3.20 you can take them out, as it will make it a little faster))
program TootIRCv3;
const
//Static const can be used within the script, and to set other values
IRC_Static_JoinChan = '#SRL';
IRC_Static_Username = '';
IRC_Static_Realname = '';
IRC_Static_NickServ = '';
IRC_Static_RecoverWord = '';
IRC_Static_Server = 'irc.freenode.net';
IRC_Static_Port = 6665;
IRC_Static_AutoJoin = True;
//Default values should NEVER be used within the script, except to set other values.
//These are used for inital values that will be changed during runtime
//(I.E. the QuitWord, if the MasterNick wants to change that, they can;
//also, the MasterNick can be changed, I.E. you wanna give someone else a try with the bot)
IRC_Default_MasterNick = '';
IRC_Default_JoinNick1 = '';
IRC_Default_JoinNick2 = '';
CRLF = #13#10;
//{$DEFINE Safe}
type
TMessage = record
Nick, User, Host, Sender, Command, Param, TheMessage, WholeLineData: String;
end;
type
TMethod = record
Declaration, Creator, Description, FileIn: String;
end;
var
TheConnection: Integer;
IRC_CurrentServer, IRC_MasterNick, IRC_CurrentNick: String;
IRC_BanList, SRL_Lines: array of String;
Locked, Quitting: Boolean;
function GetOcc(SubStr, S: String): Integer;
var
I: Integer;
begin
Result:= -1;
repeat
I:= PosEx(SubStr, S, I + Length(SubStr));
Result:= Result + 1;
until(I < 1);
end;
function Explode(Seperator, S: String): TStringArray;
var
I: Integer;
begin
S:= S + Seperator;
SetLength(Result, GetOcc(Seperator, S));
for I:= 0 to High(Result) do
begin
Result[I]:= Copy(S, 1, Pos(Seperator, S) - 1);
Delete(S, 1, (Pos(Seperator, S) - 1) + Length(Seperator));
end;
end;
function Implode(Glue: String; Pieces: TStringArray): String;
var
I: Integer;
begin
for I:= 0 to High(Pieces) do
Result:= Result + Pieces[I] + Glue;
Result:= Copy(Result, 1, Length(Result) - Length(Glue));
end;
procedure ConnectToServer(Host: String; Port: Integer);
begin
TheConnection:= OpenConnection(Host, Port, 9999);
end;
function Timestamp: String;
var
H, M, S, MS: Word;
begin
DecodeTime(Time, H, M, S, MS);
Result:= '[' + Padz(IntToStr(H), 2) + ':' + Padz(IntToStr(M), 2) + ':' + Padz(IntToStr(S), 2) + ':' + Padz(IntToStr(MS), 3) + ']';
end;
procedure OutputMessage(CMessage: TMessage; Mes: String);
var
Output: String;
H, M, S, MS: Word;
begin
with CMessage do
begin
if(not(Mes = '')) then
Output:= Mes
else
case Command of
'PRIVMSG': Output:= Param + ': <' + Nick + '> ' + TheMessage;
end;
end;
DecodeTime(Time, H, M, S, MS);
Writeln(Timestamp + ' ' + Output);
end;
procedure SendData(Data: String);
var
MM: TMessage;
begin
if(not(TheConnection < 0)) then
begin
SendConnectionData(TheConnection, Data + CRLF);
OutputMessage(MM, '-> ' + Data);
end;
end;
function InStr(SubStr, S: String): Boolean;
begin
Result:= Pos(SubStr, S) > 0;
end;
function NextToken(var S: String; SubStr: String): String; //pwns yakman's ;)
begin
Result:= #0;
if(Pos(SubStr, S) < 1) then
Exit;
Result:= Copy(S, 1, Pos(SubStr, S) - 1);
Delete(S, 1, Length(Result) + Length(SubStr));
end;
function IsNumber(S: String): Boolean;
var
X: Integer;
begin
Result:= True;
try
X:= StrToInt(S);
if(X = -1) then
if(not(S = '-1')) then
Result:= False;
except
Result:= False;
end;
end;
function InStrArrEx(S: String; StrArr: TStringArray): Integer; //returns where it was found, -1 if not found
begin
for Result:= High(StrArr) downto 0 do
if(Lowercase(StrArr[Result]) = Lowercase(S)) then
Exit;
end;
function MergeArrays(A1, A2: TStringArray): TStringArray;
var
I, L: Integer;
begin
L:= High(A1);
SetLength(Result, L + Length(A2) + 1);
for I:= 0 to L do
Result[I]:= A1[I];
for I:= L + 1 to High(Result) do
Result[I]:= A2[I - L - 1];
end;
procedure LoadBanList;
var
I: Integer;
begin
I:= 0;
repeat
SetArrayLength(IRC_BanList, I + 1);
IRC_BanList[I]:= ReadINI('BANLIST', 'B' + IntToStr(I), ScriptPath + 'TootIRCv3.ini');
if(IRC_BanList[I] = '') then
Break;
I:= I + 1;
until(False);
SetArrayLength(IRC_BanList, I);
end;
procedure SaveBanList;
var
I, II, X: Integer;
S: String;
begin
X:= OpenFile(ScriptPath + 'TootIRCv3.ini', False);
ReadFileString(X, S, FileSize(X));
CloseFile(X);
for I:= 0 to GetOcc(#10 + 'B', S) - 1 do
DeleteINI('BANLIST', 'B' + IntToStr(I), ScriptPath + 'TootIRCv3.ini');
II:= 0;
for I:= 0 to High(IRC_BanList) do
begin
WriteINI('BANLIST', 'B' + IntToStr(II), IRC_BanList[I], ScriptPath + 'TootIRCv3.ini');
if(IRC_BanList[I] = '') then
Continue;
II:= II + 1;
end;
end;
procedure AddToBanList(Nicks, ChannelList: TStringArray);
var
I, II, III: Integer;
begin
for I:= 0 to High(Nicks) do
begin
if(not(InStrArr(Nicks[I], IRC_BanList, False))) then
begin
SendData('PRIVMSG ' + Nicks[I] + ' :' + Nicks[I] + ': You have been banned from using this bot.');
II:= InStrArrEx('', IRC_BanList);
if(II >= 0) then
IRC_BanList[II]:= Nicks[I]
else
begin
III:= Length(IRC_BanList);
SetLength(IRC_BanList, III + 1);
IRC_BanList[III]:= Nicks[I];
end;
end;
end;
SaveBanList;
LoadBanList;
for I:= 0 to High(ChannelList) do
SendData('PRIVMSG ' + ChannelList[I] + ' :' + Implode(', ', Nicks) + ' has been banned from using this bot.');
end;
procedure RemoveFromBanList(Nicks, ChannelList: TStringArray);
var
I, II: Integer;
B: TStringArray;
begin
SetLength(B, Length(Nicks));
for I:= 0 to High(Nicks) do
begin
II:= InStrArrEx(Nicks[I], IRC_BanList);
if(II >= 0) then
IRC_BanList[II]:= '';
end;
SaveBanList;
LoadBanList;
for I:= 0 to High(ChannelList) do
SendData('PRIVMSG ' + ChannelList[I] + ' :' + Implode(', ', Nicks) + ' has been unbanned from using this bot.');
end;
procedure Quit(M: String);
begin
SendData('QUIT: ' + M);
Quitting:= True;
end;
procedure ScriptTerminate;
begin
if(not(Quitting)) then
Quit('A Tootoot222 made IRC bot has been told to quit.');
if(not(TheConnection < 0)) then
FreeConnection(TheConnection);
end;
procedure JoinChannel(Chan: String);
begin
if(InStr(',', Chan)) then
begin
SendData('PRIVMSG ' + IRC_Static_JoinChan + ' :Joining this channel will cause me to part. I will not join this channel.');
Exit;
end;
if(InStr('#', Chan)) then
SendData('JOIN ' + Chan)
else
SendData('JOIN #' + Chan);
//TODO: make it return if it was able to join the channel or not
end;
function Banned(Nick: String): Boolean;
begin
Result:= InStrArr(Nick, IRC_BanList, False);
end;
function AbleToSend(Nick: String): Boolean;
begin
Result:= False;
if(Locked) then
begin
SendData('NOTICE ' + Nick + ' :' + Nick + ': The bot is locked. Please wait for the Master to unlock it.');
Exit;
end;
if(Banned(Nick)) then
begin
SendData('NOTICE ' + Nick + ' :' + Nick + ': You are banned from using this bot.');
Exit;
end;
Result:= True;
end;
procedure SetNick(NewNick: String);
begin
SendData('NICK ' + NewNick);
IRC_CurrentNick:= NewNick;
//TODO: make it return if it was able to set the nick or not
end;
procedure SetLock(NewLock: Boolean; Channels: TStringArray);
var
I: Integer;
begin
if(NewLock = Locked) then
Exit;
Locked:= NewLock;
for I:= 0 to High(Channels) do
if(NewLock) then
SendData('PRIVMSG ' + Channels[I] + ' :I am now locked. My Master must use the !unlock command to unlock me.')
else
SendData('PRIVMSG ' + Channels[I] + ' :I am now unlocked. My Master must use the !lock command to lock me.');
end;
var
Days, Months: TStringArray;
function DateTimeToString(T: TDateTime): String;
var
Y, Mo, D, H, Mi, S, MS: word;
begin
DecodeDate(T, Y, Mo, D);
DecodeTime(T, H, Mi, S, MS);
Result:= Days[DayOfWeek(T) - 1] + ' ' + IntToStr(D)
+ ' ' + Months[Mo - 1] + ' ' + IntToStr(Y) + ' ' +
IntToStr(H) + ':' + IntToStr(Mi) + ':' + IntToStr(S);
end;
function UnixTimeToStr(UnixTime: Int64): String;
begin
Result:= DateTimeToString(UnixToDateTime(UnixTime));
end;
function ReplaceBetween(S, LSearch, RSearch, ReplaceWith: String): String;
var
X, Y: Integer;
begin
X:= 0;
Y:= 0;
Result:= S;
repeat
if(Result = '') then
Exit;
X:= PosEx(LSearch, Result, X);
if(X < 1) then
Exit;
Y:= PosEx(RSearch, Result, X);
if(Y < 1) then
Exit;
Delete(Result, X, (Y - X) + 1);
Insert(ReplaceWith, Result, X);
X:= X + Length(ReplaceWith);
until(False);
end;
function WhichInStr(Arr: TStringArray; S: String): Integer;
begin
for Result:= High(Arr) downto 0 do
if(InStr(Arr[Result], S)) then
Exit;
end;
function ReadSRLManual: TStringArray;
var
ThePath: String;
X: Integer;
S: String;
begin
ThePath:= AppPath + 'Includes\SRL\SRL.html';
if(FileExists(ThePath)) then
begin
try
X:= OpenFile(ThePath, True);
if(not(X < 0)) then
begin
ReadFileString(X, S, FileSize(X));
Result:= Explode(#13#10, S);
end;
finally
CloseFile(X);
end;
end else
Writeln('Unable to locate ' + ThePath + '!');
end;
function ParaseSRLManual(Line: TStringArray; SearchFor: String): TMethod;
var
T, W, I: Integer;
CurrentFile: String;
SS: array of String;
GotInfo: Boolean;
begin
for I:= 0 to High(Line) do
begin
W:= WhichInStr(['srl\', 'by:', 'description:', Lowercase(SearchFor)], Lowercase(Line[I]));
if((W < 0) or (((W = 1) or (W = 2)) and (not(GotInfo)))) then
Continue;
Line[I]:= Trim(Replace(ReplaceBetween(Line[I], '<', '>', ''), ' ', ' '));
case W of
0: CurrentFile:= Trim(Line[I]);
1:
begin
if(GotInfo) then
Result.Creator:= Trim(TrimEx('By:', Line[I]));
end;
2:
begin
if(GotInfo) then
begin
SS:= Explode(' ', Trim(TrimEx('Description:', Line[I])));
for T:= 0 to High(SS) do
SS[T]:= Trim(SS[T]);
Result.Description:= Implode(#13#10, SS);
Exit;
end;
end;
3:
begin
W:= WhichInStr([' ' + Lowercase(SearchFor) + '(', ' ' + Lowercase(SearchFor) + ':', ' ' + Lowercase(SearchFor) + ';'], Lowercase(Line[I]));
if((W + 1) > 0) then
begin
Result.Declaration:= Line[I];
for T:= 0 to 4 do
Result.Declaration:= Replace(Line[I], ' ', ' ');
Result.FileIn:= CurrentFile;
GotInfo:= True;
end;
end;
end;
end;
Result.Declaration:= 'Unable to locate method "' + SearchFor + '" in SRL.html' + #13#10#0;
end;
function MethodToString(M: TMethod): String;
begin
with M do
begin
Result:= Declaration;
Result:= Result + #13#10 + 'Found in file: ' + FileIn;
Result:= Result + #13#10 + 'Made by: ' + Creator;
Result:= Result + #13#10 + 'Description: ' + Description;
end;
end;
function HandleNumberCommands(var CMessage: TMessage): Boolean;
var
Output: String;
begin
with CMessage do
begin
Result:= True;
Output:= '';
case Command of
'001': IRC_CurrentServer:= Host;
'005': //for now, i cbf to do anything with 005 params; i'm just going to output them (i'm also going to leave them in their own case, for when i decide to do things with them)
begin
Output:= TrimEx(IRC_CurrentNick + ' ', Param) + ' ' + TheMessage;
end;
'252', '254': Output:= TrimEx(IRC_CurrentNick + ' ', Param) + ' ' + TheMessage;
'433':
begin
OutputMessage(CMessage, 'Nickname "' + Param + '" is already in use.');
if(IRC_CurrentNick = IRC_Default_JoinNick1) then
SetNick(IRC_Default_JoinNick2)
else
SetNick(IRC_Default_JoinNick1);
JoinChannel(IRC_Static_JoinChan);
Result:= True;
Exit;
end;
'474':
begin
SendData('PRIVMSG ' + IRC_Static_JoinChan + ' :Unable to join channel ' + TrimEx(IRC_CurrentNick + ' ', Param) + ' because: ' + TheMessage);
JoinChannel(IRC_Static_JoinChan);
end;
end;
if(Output = '') then
Output:= TheMessage;
OutputMessage(CMessage, Output);
end;
end;
function HandleChatCommands(CMessage: TMessage): Boolean;
var
S, SS, SSS: String;
NoMess, B: Boolean;
begin
with CMessage do
begin
Result:= False;
if((Nick = #0) or (TheMessage = '')) then
Exit;
Result:= True;
if(Pos(#1, TheMessage) = 1) then
begin
SS:= TrimEx(#1, TheMessage) + ' ';
S:= Uppercase(NextToken(SS, ' '));
SS:= Trim(SS);
Result:= True;
case S of
'ACTION': OutputMessage(CMessage, Param + ': * ' + Nick + ' ' + SS);
'PING': SendData('NOTICE ' + Nick + ' :' + #1 + 'PING ' + SS + #1);
'TIME': SendData('NOTICE ' + Nick + ' :' + #1 + 'TIME ' + DateTimeToString(Now) + #1);
'VERSION': SendData('NOTICE ' + Nick + ' :' + #1 + 'VERSION IRC Bot made by Tootoot222 in SCAR. V3' + #1);
'FINGER': SendData('NOTICE ' + Nick + ' :' + #1 + 'FINGER What is this even for?' + #1);
else
Result:= False;
end;
if(Result) then
Exit;
end;
OutputMessage(CMessage, '');
if(not(StartsWith('!', TheMessage))) then
Exit;
S:= Copy(TheMessage, 1, Pos(';', TheMessage));
SS:= Trim(TrimEx(S, TheMessage));
S:= Trim(Lowercase(Replace(S, ';', ' ')));
if(High(S) > 0) then
if(not(S[1] = '!')) then
Exit;
NoMess:= False;
B:= False;
case S of
'!recover':
begin
if(StartsWith(IRC_Static_RecoverWord + ' ', SS)) then
begin
IRC_MasterNick:= TrimEx(IRC_Static_RecoverWord + ' ', SS);
RemoveFromBanList([IRC_MasterNick], [IRC_MasterNick]);
end;
end;
'!say':
begin
if(AbleToSend(Nick)) then
begin
if(StartsWith('#', Param)) then
SendData('PRIVMSG ' + Param + ' :' + SS)
else
if(Param = IRC_CurrentNick) then
SendData('PRIVMSG ' + Copy(SS, 1, Pos(' ', SS)) + ':' + TrimEx(Copy(SS, 1, Pos(' ', SS)), SS));
end else
B:= True;
end;
'!says':
begin
if(AbleToSend(Nick)) then
begin
if(StartsWith('#', Param)) then
SendData('PRIVMSG ' + Param + ' :' + Nick + ' says: ' + SS)
else
if(Param = IRC_CurrentNick) then
SendData('PRIVMSG ' + Copy(SS, 1, Pos(' ', SS)) + ':' + Nick + ' says: ' + TrimEx(Copy(SS, 1, Pos(' ', SS)), SS));
end else
B:= True;
end;
'!sayme':
begin
if(AbleToSend(Nick)) then
begin
if(StartsWith('#', Param)) then
SendData('PRIVMSG ' + Param + ' :' + #1 + 'ACTION ' + SS + #1)
else
if(Param = IRC_CurrentNick) then
SendData('PRIVMSG ' + Copy(SS, 1, Pos(' ', SS)) + ':' + #1 + 'ACTION ' + TrimEx(Copy(SS, 1, Pos(' ', SS)), SS) + #1);
end else
B:= True;
end;
'!send':
begin
if(AbleToSend(Nick)) then
begin
if(not(StartsWith('quit', Trim(Lowercase(SS))))) then
SendData(SS)
else
if(Nick = IRC_MasterNick) then
SendData(SS)
else
SendData('NOTICE ' + Nick + ' :You do not have permission to do this.');
end else
B:= True;
end;
'!banlist': SendData('NOTICE ' + Nick + ' :The users: ' + Implode(', ', IRC_BanList) + ' are banned.');
'!methodsearch':
begin
if(AbleToSend(Nick)) then
SendData('NOTICE ' + Nick + ' :' + Implode(#13#10 + 'NOTICE ' + Nick + ' :', Explode(#13#10, MethodToString(ParaseSRLManual(SRL_Lines, SS)))))
else
B:= True;
end;
else
begin
NoMess:= True;
if(not(Nick = IRC_MasterNick)) then
if(not(S = '')) then
SendData('NOTICE ' + Nick + ' : I am sorry ' + Nick + ', but I do not know the "' + S + '" commnad.');
end;
end;
if(not(Nick = IRC_MasterNick)) then
Exit;
if(B or Banned(Nick)) then
begin
if(NoMess) then
SendData('NOTICE ' + Nick + ' :You are banned ' + Nick + '. You may not use this bot.');
Exit;
end;
case S of
'!lock': SetLock(True, [IRC_Static_JoinChan]);
'!unlock': SetLock(False, [IRC_Static_JoinChan]);
'!kick': SendData('KICK ' + SS);
'!part': SendData('PART ' + SS);
'!join': JoinChannel(SS);
'!nick': SetNick(SS);
'!quit':
begin
if(not(Trim(SS) = '')) then
Quit(SS);
TerminateScript;
end;
'!prompt': SendData(Readln('Enter your message here:'));
'!master':
begin
if(not(Banned(Nick))) then
IRC_MasterNick:= TrimEx('master ', SS)
else
SendData('NOTICE ' + Nick + ' :' + TrimEx('master ', SS) + ' -- ' + SS + ' are banned from using this bot.');
end;
'!load banlist': LoadBanList;
'!save banlist': SaveBanList;
'!ban':
begin
SSS:= Copy(SS, 1, Pos(' ', SS));
AddToBanList(Explode('|', Lowercase(Trim(SSS))), Explode('|', TrimEx(SSS, SS)));
end;
'!unban':
begin
SSS:= Copy(SS, 1, Pos(' ', SS));
RemoveFromBanList(Explode('|', Lowercase(Trim(SSS))), Explode('|', TrimEx(SSS, SS)));
end;
'!mode':
begin
if(StartsWith('#', Param)) then
SendData('MODE ' + Param + ' ' + SS)
else
if(Param = IRC_CurrentNick) then
SendData('MODE ' + SS);
end;
else
if(not(S = '')) then
if(NoMess) then
SendData('NOTICE ' + Nick + ' :I am sorry ' + Nick + ', but I do not know the "' + S + '" commnad.');
end;
end;
end;
function HandleNormalCommands(CMessage: TMessage): Boolean;
var
P: Integer;
KickedChan, Kickee: String;
begin
with CMessage do
begin
Result:= True;
if(StartsWith('NOTICE AUTH', WholeLineData))then
begin
OutputMessage(CMessage, '-' + IRC_Static_Server + '- *** ' + TheMessage);
Exit;
end;
if(StartsWith('NOTICE', WholeLineData))then
begin
OutputMessage(CMessage, '-' + IRC_CurrentServer + '- ' + TheMessage);
Exit;
end;
case Command of
'KICK':
begin
P:= Pos('#', Param);
KickedChan:= Trim(Copy(Param, P, PosEx(' ', Param, P) - P));
Delete(Param, P, PosEx(' ', Param, P) - P);
Kickee:= Trim(Param);
if(Kickee = IRC_CurrentNick) then
begin
OutputMessage(CMessage, 'You were kicked from ' + KickedChan + ' by ' + Nick + ' (' + TheMessage + ')');
if(IRC_Static_AutoJoin) then
JoinChannel(KickedChan);
end else
OutputMessage(CMessage, Kickee + ' was kicked from ' + KickedChan + ' by ' + Nick + ' (' + TheMessage + ')');
end;
'MODE':
begin
if(Nick = #0) then
OutputMessage(CMessage, Host + ' sets mode: ' + TheMessage)
else
OutputMessage(CMessage, Nick + ' sets mode: ' + TheMessage);
end;
'NOTICE': OutputMessage(CMessage, '-' + Nick + '- ' + TheMessage);
'PRIVMSG': Result:= HandleChatCommands(CMessage);
'PART':
begin
if(not(TheMessage = '')) then
OutputMessage(CMessage, Nick + ' (' + User + '@' + Host + ') (' + TheMessage + ') has left ' + Param)
else
OutputMessage(CMessage, Nick + ' (' + User + '@' + Host + ') has left ' + Param);
end;
'JOIN': OutputMessage(CMessage, Nick + ' (' + User + '@' + Host + ') has joined ' + TheMessage);
'QUIT':
begin
if(not(TheMessage = '')) then
OutputMessage(CMessage, Nick + ' (' + User + '@' + Host + ') (' + TheMessage + ') has quit')
else
OutputMessage(CMessage, Nick + ' (' + User + '@' + Host + ') has quit');
end;
'NICK': OutputMessage(CMessage, Nick + ' is now known as ' + TheMessage);
else
Result:= False;
end;
end;
end;
procedure ParaseMessage(Data: String);
var
CMessage: TMessage;
DataArr: TStringArray;
NUH, Line: String;
I, L: Integer;
begin
DataArr:= Explode(CRLF, Data);
L:= High(DataArr);
for I:= 0 to L do
with CMessage do
begin
if(High(DataArr[I]) < 1) then
Continue;
WholeLineData:= DataArr[I];
if(StartsWith('PING', DataArr[I]))then
begin
Writeln(Timestamp + ' <- ' + DataArr[I]);
WholeLineData[2]:= 'O';
SendData(WholeLineData);
Continue;
end;
Line:= WholeLineData;
Sender:= NextToken(Line, ' ');
if(High(Sender) > 0) then
if(Sender[1] = ':')then
Delete(Sender, 1, 1);
NUH:= Sender;
Nick:= NextToken(NUH, '!');
User:= NextToken(NUH, '@');
Host:= NUH;
Command:= NextToken(Line, ' ');
if(InStr(' :', Line)) then
begin
Param:= NextToken(Line, ' :');
Line:= ':' + Line;
end else
Param:= NextToken(Line, ' :');
if(Param = #0) then
Param:= NextToken(Line, ' ');
Param:= TrimEx('* ', Param);
TheMessage:= Line;
NextToken(TheMessage, ':');
if(TheMessage = 'This nickname is registered. Please choose a different nickname, or identify via /msg NickServ identify <password>.') then
if(Nick = 'NickServ') then
SendData('PRIVMSG NickServ :identify ' + IRC_Static_NickServ);
if(IsNumber(Command)) then
if(HandleNumberCommands(CMessage)) then
Continue;
if(HandleNormalCommands(CMessage)) then
Continue;
Writeln(Timestamp + ' ' + Nick + ' - ' + User + ' - ' + Host + ' - ' + Command + ' - ' + Param + ' - ' + TheMessage);
Writeln(Timestamp + ' ' + DataArr[I]);
end;
end;
procedure MainLoop;
var
MessageBuffer: String;
begin
ClearDebug;
{$IFDEF Safe}
try
{$ENDIF}
SRL_Lines:= ReadSRLManual;
Quitting:= False;
Days:= ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
Months:= ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
Locked:= True;
LoadBanList;
IRC_MasterNick:= IRC_Default_MasterNick;
IRC_CurrentNick:= IRC_Default_JoinNick1;
ConnectToServer(IRC_Static_Server, IRC_Static_Port);
if(TheConnection < 0) then
Exit;
IRC_CurrentNick:= IRC_Default_JoinNick1;
SendData('USER ' + IRC_Static_Username + ' * * :' + IRC_Static_Realname);
SetNick(IRC_CurrentNick);
JoinChannel(IRC_Static_JoinChan);
repeat
MessageBuffer:= '';
if(TheConnection >= 0) then
ReadConnectionData(TheConnection, MessageBuffer);
if(not(MessageBuffer = '')) then
ParaseMessage(MessageBuffer);
until(False);
{$IFDEF Safe}
except
Writeln('ERROR!! The error was: ' + ExceptionToString(ExceptionType, ExceptionParam));
finally
end;
{$ENDIF}
end;
begin
MainLoop;
end.