SRL Archive - News and General

Idle Your Script Users @ IRC


Harry

2009-05-11 05:01:57

I wrote/edited this quickly. Do not comment on my standards, etc, please.

program new;

const
IRCPlz = True; // Have SCAR connect and idle at SRL's irc room?
SRLChatPlz = False; // Join #SRL ?
IRCNickname = ''; // The nickname you want to connect to IRC on. Leave it at default if you do not know how to IRC. No spaces can be in it, and this nickname will be public on the IRC, irc.freenode.net #SRL
Botchans = '#SRL,#fakechannel'; // chans to join. seperate by a comma, no space.

var Sock_fd:integer;

procedure SendData(buf: string);
begin
AddToReport('=> ' + buf);
SendConnectionData(Sock_fd, buf + #10 + #13);
end;

procedure scriptterminate;
begin
SendData('QUIT :Leaving');
end;

// IRC Stuff. Thanks to Yakman and LeeLokHin.
var
line: string;
nicke, host, command, channel, args: string;

type
BufferedReader = record
buffer: string;
pos, len: Integer;
usesocket: boolean;
end;

var reader, lineparse: BufferedReader;

procedure FillReaderBuffer(var reader: BufferedReader);
var
buf: string;
begin
try ReadConnectionData(Sock_fd, buf); except end;
try reader.pos:= 1; except end;
try reader.len:= Length(buf); except end;
try reader.buffer:= buf; except end;
end;


function Connect:Integer;
var botnick,botnic:string;
begin
case random(10) of
0: botnick := 'm'+Trim(TrimNumbers(TrimOthers(ircnickname)))+inttostr(random(999)); // So if they are a nub at IRC, it will not allow their username to begin with a number.
1: botnick := 's'+Trim(TrimNumbers(TrimOthers(ircnickname)))+inttostr(random(999));
2: botnick := 'c'+Trim(TrimNumbers(TrimOthers(ircnickname)))+inttostr(random(999));
3: botnick := 'f'+Trim(TrimNumbers(TrimOthers(ircnickname)))+inttostr(random(999));
4: botnick := 'w'+Trim(TrimNumbers(TrimOthers(ircnickname)))+inttostr(random(999));
5: botnick := 't'+Trim(TrimNumbers(TrimOthers(ircnickname)))+inttostr(random(999));
6: botnick := 'g'+Trim(TrimNumbers(TrimOthers(ircnickname)))+inttostr(random(999));
7: botnick := 'x'+Trim(TrimNumbers(TrimOthers(ircnickname)))+inttostr(random(999));
8: botnick := 'z'+Trim(TrimNumbers(TrimOthers(ircnickname)))+inttostr(random(999));
9: botnick := 'i'+Trim(TrimNumbers(TrimOthers(ircnickname)))+inttostr(random(999));
end;

Result := OpenConnection('irc.freenode.net', 8001, 15000);
if(Result < 0)then
begin
Writeln('Error connecting');
Exit;
end;
ClearReport;
SendData('USER ' + BotNick + ' 8 * :' + BotNick);
SendData('NICK '+botnick);
SendData('MODE '+botnick+' +i');
SendData('MODE '+botnick+' +E');
SendData('MODE '+botnick+' +C');
SendData('MODE '+botnick+' +I');
SendData('MODE '+botnick+' +Q');
if SRLChatPlz then
SendData('JOIN '+botchans+',#SRL')
else
SendData('JOIN '+botchans);
end;

function ReadNextSegment(var reader: BufferedReader; c1, c2: char): string;
var
f: Integer;
begin
repeat
for f:= reader.pos to reader.len do
if(reader.buffer[f] = c1)or(reader.buffer[f] = c2)then
begin
Result:= Copy(reader.buffer, reader.pos, f - reader.pos);
reader.pos:= f + 1; //skip the char your just read
Exit;
end;
//Didnt find the char, fill the buffer from socket
if(reader.usesocket)then
FillReaderBuffer(reader)
else
Break;
until(False);

//if we get to here, it means we arnt using the socket, and the buffer is empty
Result:= #0; //nul means error
end;

function ReadNextLine(var reader: BufferedReader): string;
var
line: string;
c: char;
begin
try line:= ReadNextSegment(reader, #10, #13); except end;
try
c:= reader.buffer[reader.pos];
except
exit;
end;
//sometimes line breaks come in twos
if(c = #13)or(c = #10)then
reader.pos:= reader.pos + 1;
Result:= line;
end;

function ReadRest(var reader: BufferedReader):string;
begin
Result:= Copy(reader.buffer, reader.pos, reader.len - reader.pos + 1);
reader.pos:= reader.len;
end;

procedure ircwake; //keep alive the connection :D
var watwat: Integer;
begin
SetTimeout(2500, 'ircwake');
//marktime(watwat);

// while timefrommark(watwat) < 200 do
begin
line:= ReadNextLine(reader);
addtoreport('<= ' + line);

lineparse.buffer:= line;
lineparse.pos:= 1;
lineparse.len:= Length(line);
lineparse.usesocket:= false;

if(line[1] = ':')then //we've got a nick and host
begin
lineparse.pos:= 2;
nicke:= ReadNextSegment(lineparse, '!', #0);
host:= ReadNextSegment(lineparse, ' ', #0);
end;
command:= ReadNextSegment(lineparse, ' ', #0);
channel:= ReadNextSegment(lineparse, ' ', #0);
args:= ReadRest(lineparse);

//if(args <> '')then
//if(args[1] = ':')then
//delete(args, 1, 1);

if(command = 'PING')then
begin
line[2] := 'O';
SendData(line);
end else
if(command = 'KICK')then
begin
SendData('JOIN '+botchans);
end else exit;
end;
end;


procedure Main;
begin
Sock_fd := Connect;
if(Sock_fd < 0)then
begin
Writeln('Failed to connect');
Exit;
end;
reader.usesocket:= true;
FillReaderBuffer(reader);

// marktime(watwat);

ircwake;

//FreeConnection(sock_fd);
end;

begin main; while true do wait(10) end.
Put this into the script somewhere. Now, just call Main; before OR after SetupSRL;

Now, your script users are idle in IRC, and it can give you a live-time status on how popular your script is, without SRL-Stats :)

I doubt this will be added into SRL, but it would be cool. Would be nice for RemoteControl, etc.


Enjoy, and comment. :)
~ Harry

Nava2

2009-05-11 05:06:01

Its a shame you are trollin' with the #hy71194 crap.

Good idea though. :)

Also #srl will make for a lot of unneeded connections. Make a new channel maybe?

Harry

2009-05-11 05:06:46

From: Nava2
Its a shame you are trollin' with the #hy71194 crap.

Good idea though. :)

Oh darn it, I forgot to remove that part out for the public release, thanks, edited.

Also #srl will make for a lot of unneeded connections. Make a new channel maybe?

Idlers are good, and do not harm the chan in any way :)

Rubix

2009-05-11 05:25:00

/offtopic NAVATWO GET RID OF THAT AVATAR NOW

P1nky

2009-05-11 08:06:20

From: Rubix Cube
/offtopic NAVATWO GET RID OF THAT AVATAR NOW


please do … no offense :S

and gj Harry.

Though i don't use IRC lolz.

Harry

2009-05-11 08:10:04

From: ~~Joker~~
please do … no offense :S

and gj Harry.

Though i don't use IRC lolz.

Come on IRC more :) It is fun sometimes.

Capricorn

2009-05-11 08:13:30

So we put this in a script and it basically logs on to SRL's IRC channel and idles?

Also pro avatar Nava2.

Harry

2009-05-11 08:15:11

From: Capricorn
So we put this in a script and it basically logs on to SRL's IRC channel and idles?

Also pro avatar Nava2.

Yeah, the more idlers the better. Also, it complies with the SRL scripting regulations, as long as you put a boolean in your script to make them choose if they want to have it connect to IRC or not.

And adblock nava2's avatar = win. :D

Bobarkinator

2009-05-11 08:15:51

Not harmful unless we max out the channel…

This, finally, I find to actually be a cool and good idea. Just do it in a channel such as #SRL-ScriptStats or #SRL-Stats

Harry

2009-05-11 08:18:17

There is no "channel peak" at freenode. ##ubuntu has over 1000 users in it.

And thanks, but using a different channel would be easier for Jagex to ban IPs. Such as, no one except the autoers would join there, making little denyability against them.

Harry

2009-06-05 23:39:14

Updated teh lolcode :3

Dynamite

2009-06-05 23:47:21

Why is it good to have idlers?

T~M

Shuttleu

2009-06-05 23:49:58

more users?

~shut

senrath

2009-06-05 23:52:11

It's to tell how many people are using your script.

Shuttleu

2009-06-06 00:00:00

ahhh… so you can put in your own channel name and it will log in there?

~shut

Harry

2009-06-06 00:27:31

Yes, I am hoping to expand it, so you can RC your army, etc.

Updated it moar. :)

Richard

2009-06-06 01:19:57

From: Harry
Yes, I am hoping to expand it, so you can RC your army, etc.


That is actually genius, then do the normal !action <action> and it will effect the script.

Good job.

Harry

2009-06-06 01:20:52

From: Richard
That is actually genius, then do the normal !action <action> and it will effect the script.

Good job.

Thanks, glad someone likes this idea :)

Shuttleu

2009-06-06 01:31:33

i do like the idea
im probs gonna add it to my scripts if it doesn't get added to SRL

~shut

Harry

2009-06-07 12:23:15

Glad you like :D

Shuttleu

2009-06-07 15:39:50

added to UCB

~shut

EvilChicken!

2009-06-08 02:24:37

Harry, I really like the idea behind this.

If you expand it/make it somewhat like an alternative to RC, I'll make it an include in the \misc folder. :)

Harry

2009-06-08 02:27:48

From: EvilChicken!
Harry, I really like the idea behind this.

If you expand it/make it somewhat like an alternative to RC, I'll make it an include in the \misc folder. :)

Well, all you would need to do would be to read the command behind it, then act on the command.

For example, if args = 'SUPER-SECRET-COMMAND' then ..

etc.

EvilChicken!

2009-06-08 07:28:46

I know.
I'm just too busy to finish your work atm.

And, could this be relevant?

Harry

2009-06-08 07:35:00

Nah, RScript is just a bot program, for commands like !ge <item>, etc. They do not macro RS.

P1nky

2009-06-08 08:25:12

Harry i try to join your IRC thingy at the Javanode thing and it says connection Null.

Tniffoc

2009-06-08 08:33:10

Harry? Is your name Oscar?

Harry

2009-06-08 08:35:33

From: Tniffoc
Harry? Is your name Oscar?

How is that relevant to the topic? :p

And no, it is Harry.

Tniffoc

2009-06-08 08:39:37

From: Harry
How is that relevant to the topic? :p

And no, it is Harry.


I knew that was a fake phone number!

Nava2

2009-06-08 17:28:39

Hmm, might mess with this a bit.. it could be useful. :)

I think that having a channel with a key would be suffice. ;)

*/me continues to think to himself..*