forked from L4nz/gazelle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
irc_raw.php
39 lines (32 loc) · 972 Bytes
/
irc_raw.php
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
<?// This is a very primitive IRC bot
if (!isset($argv)) {
die('CLI Only.');
}
define('SERVER','irc.what.cd');
define('PORT',6667);
define('NICK','RawBot');
define('WATCH','#raw-input');
define('RELAY','#raw-output');
$Socket = fsockopen(SERVER, PORT);
fwrite($Socket, "USER ".NICK." * * :".NICK."\n");
fwrite($Socket, "NICK ".NICK."\n");
sleep(10);
fwrite($Socket, "JOIN ".WATCH."\n");
fwrite($Socket, "JOIN ".RELAY."\n");
while (!feof($Socket)) {
$Line = fgets ($Socket, 1024);
if (preg_match('/Nickname is already in use\.$/', $Line)) {
fwrite($Socket, "NICK ".NICK."_\n");
}
if (preg_match('/PING :(.+)$/', $Line, $Ping)) {
fwrite($Socket, "PONG :$Ping[1]\n");
}
// Example command
if(stripos('!mode', $Line)) {
fwrite($Socket, "PRIVMSG ".RELAY." :Mode command used\n");
fwrite($Socket, "MODE WhatMan\n");
fwrite($Socket, "WHOIS WhatMan\n");
fwrite($Socket, "MODE Orbulon\n");
}
fwrite($Socket, "PRIVMSG ".RELAY." : -----".$Line."\n");
}