-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.pike
55 lines (51 loc) · 1.19 KB
/
demo.pike
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import .Swordfish.Connection;
import .Swordfish.Message;
import .Swordfish.Sender;
class Mybot {
inherit Connection;
string Comchar;
void handle(string data) {
write ("--> " + data + "\n");
//Check for PING
if(Regexp.match("^PING", data)) {
if(array ping = Regexp.split2("PING (.*)", data)) {
raw("PONG " + ping[1]); //Send it straight back at 'em!
}
}
else {
array info = ({});
if(Regexp.split2(":(.*?)!(.*?)@(.*?) PRIVMSG (.*?) :(.*?)", data) != 0) {
Message message = Message(data);
write(message->msg);
if(array command = Regexp.split("^"+Comchar+"(.+)", message->msg)) {
switch(command[0]-"\r"-"\n") {
case "foo":
send(message->dest, "bar!");
break;
case "quit":
quit("Quit!");
break;
case "action":
action(message->dest, "jumps at " + message->sender->nick);
}
}
}
}
}
}
int main()
{
Mybot bot = Mybot();
bot->Server = "irc.eighthbit.net";
bot->Nick = "Badbot";
bot->Userln = "badbot badbot badbot badbot";
bot->Port = 6667;
bot->Channels = ({"#bots"});
bot->Comchar = "%";
bot->connect();
bot->nick(bot->Nick);
bot->raw("USER " + bot->Userln);
while(1) {
bot->read();
}
}