SCAR Code:
program New;
const
nick = '';
realname = '';
port = 6667;
server = '';
timeout = 0;
Chan = '';
master = '';
CRLF = #13#10; //dont touch, and thanks to Tootoot :D
procedure A_Debug(msg: string);
begin
writeln(msg);
alert(msg);
status(msg);
terminatescript;
end;
type
TMessage = record
mess, user, time : string;
line : TStringArray;
end;
var
c, p: integer;
s, a : string;
Curr_Master : String;
TheMessage : TMessage;
is_fun : boolean;
function Connect: integer;
begin
p:= port;
repeat
result:= OpenConnection(server, p, timeout);
if result < 0 then inc(p);
until (port = 7000) or (c >= 0);
if result < 0 then exit;
writeln('Connection Open');
writeln(' ');
writeln('Server: ' + server);
writeln('Port: ' + inttostr(port));
writeln('Connection: ' + inttostr(c));
writeln(' ');
end;
function setfun : string;
begin
if is_fun then result := 'PRIVMSG ' + chan else result := 'NOTICE ' + themessage.user;
end;
procedure setup;
begin
if (not SendConnectionData(c, 'USER ' + nick + ' * * :' + realname + CRLF) and
SendConnectionData(c, 'NICK '+ nick + CRLF) and
SendConnectionData(c, 'JOIN ' + Chan + CRLF)) then
A_Debug('Joining messed up');
writeln('Nick Set:' + nick);
writeln('User Set: ' + realname);
writeln('Joined Channel: ' + chan);
writeln(' ');
wait(1000);
end;
Function Contain(Stringz, Strings : String) : Boolean;
Begin
Result := Pos(Stringz, Strings) <> 0;
End;
function parse(messge : string) : string;
begin
with themessage do
begin
user := between(':', '!~', messge);
mess := between('PRIVMSG', CRLF, messge);
result := user + ': ' + mess;
end;
end;
procedure ping;
begin
SendConnectionData(c, 'PONG ' + chan + CRLF);
end;
function GetFact: string;
var a: string;
begin
a:= getpage('http://www.randomfunfacts.com/');
result:= TrimEx(' ', between('<td bordercolor="#FFFFFF"><font face="Verdana" size="4"><strong><i>', '</i></strong></font> </td>', a));
end;
procedure changenick(mess : string);
begin
if not (themessage.user = Curr_Master) then exit;
Themessage.line := explode(';', mess);
if length(themessage.line) < 2 then exit;
SendConnectionData(c, 'NICK '+ Themessage.line[1] + CRLF);
end;
procedure changemaster(mess : string);
begin
if not (themessage.user = Curr_Master) then exit;
Themessage.line := explode(';', mess);
if length(themessage.line) < 2 then exit;
Curr_Master := themessage.line[1];
end;
procedure rape(mess : string);
var
arr : TStringArray;
begin
Arr := ['Cactus', 'Bat', 'Rake', 'Cat', themessage.user, 'Spoon', 'Knife', 'Spork',
'AwkwardSaw'];
themessage.line := explode(';', mess);
if length(themessage.line) < 2 then exit;
SendConnectionData(c, setfun + ' Akwardbot rapes ' + Themessage.line[1] + ' with a ' + arr[random(high(arr))] + CRLF);
end;
procedure magicball(mess : string);
var
arr : TStringArray;
begin
arr := ['Yes', 'No', 'Mabey', 'Dont hold your breath', 'Hell yeah!'];
themessage.line := explode(';', mess);
if length(themessage.line) < 2 then
exit;
SendConnectionData(c, setfun + ' The answer to: ' + themessage.line[1] + ' is: ' + arr[random(high(arr))] + CRLF);
end;
procedure fun(mess : string);
begin
if not (themessage.user = Curr_Master) then exit;
Themessage.line := explode(';', mess);
if length(themessage.line) < 2 then
begin
writeln(':(');
exit;
end;
case lowercase(themessage.line[1]) of
'off' : is_fun := false;
'on' : is_fun := true;
end;
writeln(themessage.line[0] + ' - ' + themessage.line[1]);
writeln(booltostr(is_fun));
end;
procedure respond(mess : string);
begin
if contain('.fact', lowercase(parse(mess))) then
SendConnectionData(c, setfun + ' ' + getfact + CRLF);
if contain('.nick', lowercase(parse(mess))) then
changenick(lowercase(parse(mess)));
if contain('.changemaster', lowercase(parse(mess))) then
changemaster(lowercase(parse(mess)));
if contain('.master', lowercase(parse(mess))) then
SendConnectionData(c, setfun + ' my current master is: ' + curr_master + CRLF);
if contain('.rape', lowercase(parse(mess))) then
rape(parse(mess));
if contain('.mball', lowercase(parse(mess))) then
magicball(parse(mess));
if contain('.fun', lowercase(parse(mess))) then
fun(parse(mess));
end;
var
t : integer;
begin
if Connect < 0 then A_Debug('Connection Problems');
setup;
Curr_Master := master;
writeln('Master: ' + Curr_Master);
is_fun := false;
repeat
t := GetSystemTime;
repeat
if not IsConnectionOpen(c) then A_Debug('Connection Closed');
ReadConnectionData(c, s);
if contain('PRIVMSG', s) then
writeln(parse(s));
respond(s);
a:= s;
until getsystemtime - t > 10000;
ping;
until false;
end.