SRL Archive - Other Scripts

IRC bot - By akwardsaw


Awkwardsaw

2010-01-11 22:11:40

this is mah project that i'v been working on for the past few days, and i figure that its good enough for an "official" release, :)

thanks too:
Tootoot, i sorta based it off of his bot(and took the CRLF ;))
Harry, and noidea for helping me :)

the commands:
.fact - generates a random fact
.rape ;nick - rapes the nick with a random item
.mball ;question - answers the question randomly, ;p
.nick ;nick* - changes the bots nick
.fun ;on/off* - turns fun mode on or off. when on the bot will message the channel, when off it will notice the user
.changemaster ;master* - changes the new master
.master - says the current master of the bot

*only usable by the master

how to set it up:


const
nick = ''; //bots default nick
realname = ''; //your name
port = 6667; //irc port
server = ''; //the irc server
timeout = 0; //leave
Chan = '#'; //channel for the bot to join. remember the #
master = ''; //the default master of the bot

script:

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>&nbsp;</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.

note: i made this script for easy to edit/change > functionality(as long as it works ;))

which means, you can easily make your own command if you want, and add it to the database if you know anything about scripting :)

enjoy, :D

jimmy_mac

2010-01-11 22:24:27

Thanks! this is pretty sweet, gj man :)

NCDS

2010-01-11 22:55:02

From: IRC

<NCDS> .mball;can I make an IRC bot?
-DaBoss- The
<NCDS> .mball ; can I make an IRC bot?
-DaBoss- The

lol

jimmy_mac

2010-01-11 23:04:23

Cant get this to work, it comes up with:

Successfully compiled (110 ms)
Connection Open

Server: irc.rizon.net
Port: 6667
Connection: 0

Nick Set: *NAME*
User Set: *NAME*
Joined Channel: SRL

Master: jimmy_mac
Connection Closed
Successfully executed

NCDS

2010-01-11 23:27:22

From: jimmy_mac
Cant get this to work, it comes up with:

Successfully compiled (110 ms)
Connection Open

Server: irc.rizon.net
Port: 6667
Connection: 0

Nick Set: *NAME*
User Set: *NAME*
Joined Channel: SRL

Master: jimmy_mac
Connection Closed
Successfully executed


Do you allow the script to connect?

jimmy_mac

2010-01-11 23:38:54

yep i did

YoHoJo

2010-01-11 23:56:13

Sweet job dude, this is really cool. I believe YakMan also made one of these before too! :D

Awkwardsaw

2010-01-12 08:17:57

From: jimmy_mac
yep i did


is "SRL" the channel you wanted to join?

jimmy_mac

2010-01-12 08:27:12

From: Awkwardsaw
is "SRL" the channel you wanted to join?


I tried it with this aswell: "#SRL" still didnt work.

Awkwardsaw

2010-01-12 08:29:52

From: jimmy_mac
I tried it with this aswell: "#SRL" still didnt work.


to join #srl, you must be registered + identified(unless they changed it recently)

jimmy_mac

2010-01-12 08:37:45

am registered, and i'm identified. i tried it with my original username aswell.. still not working unfortunately.

Awkwardsaw

2010-01-12 08:39:56

From: jimmy_mac
am registered, and i'm identified. i tried it with my original username aswell.. still not working unfortunately.


post the part in the script that identifies your nick then pl0x, :)

jimmy_mac

2010-01-12 08:41:42

procedure setup;
begin
SendConnectionData(c, '/ns identify *MY PASSWORD*');
wait(300);
if (not SendConnectionData(c, 'USER ' + nick + ' * * :' + realname + CRLF) and
SendConnectionData(c, 'NICK '+ nick + CRLF) and

Awkwardsaw

2010-01-12 08:45:07

From: jimmy_mac
procedure setup;
begin
SendConnectionData(c, '/ns identify *MY PASSWORD*');
wait(300);
if (not SendConnectionData(c, 'USER ' + nick + ' * * :' + realname + CRLF) and
SendConnectionData(c, 'NICK '+ nick + CRLF) and


change that to


procedure setup;
begin
wait(300);
if SendConnectionData(c, 'USER ' + nick + ' * * :' + realname + CRLF) and
SendConnectionData(c, 'NICK '+ nick + CRLF) and
SendConnectionData(c, 'identify *MY PASSWORD*' + CRLF) and

jimmy_mac

2010-01-12 08:49:12

After changing that it still doesnt connect but i get this now, sorry for the hassle mate:
Successfully compiled (91 ms)
Connection Open

Server: irc.rizon.net
Port: 6667
Connection: 0

Nick Set:AnOldMan
User Set: An Old Man
Joined Channel: #SRL

Master: jimmy_mac
: :4,WHOIS:1 CHANTYPES=# :are supported by this server
irc.nuu.cc 372 AnOldMan :- o Want a vhost? /msg hostserv help request
:irc.nuu.cc 372 AnOldMan :-
:irc.nuu.cc 372 AnOldMan :- _______ Open Proxy's & Transit Provider ______________________________
:irc.nuu.cc 372 AnOldMan :-
:irc.nuu.cc 372 AnOldMan :- o The use of this server & network is a privilege, not a right.
:irc.nuu.cc 372 AnOldMan :-
:irc.nuu.cc 372 AnOldMan :- o IRC is a free media, therefore no person or entity involved
:irc.nuu.cc 372 AnOldMan :- o with *.rizon.net and irc.nuu.cc takes any responsibility
:irc.nuu.cc 372 AnOldMan :- o whatsoever for the opinions expressed or the actions taken by
:irc.nuu.cc 372 AnOldMan :- o users. Absolutely no warranty is either expressed or implied.
:irc.nuu.cc 376 AnOldMan :End of /MOTD command.
:AnOldMan: AnOldMan :VERSION

Awkwardsaw

2010-01-12 08:52:32

idk, :o

try it on a private chan, where you dont need identifying