2013-06-24 08:00:28 +00:00
|
|
|
<? // This is a very primitive IRC bot
|
2011-03-28 14:21:28 +00:00
|
|
|
if (!isset($argv)) {
|
|
|
|
die('CLI Only.');
|
|
|
|
}
|
|
|
|
|
2013-06-24 08:00:28 +00:00
|
|
|
define('SERVER', 'irc.what.cd');
|
|
|
|
define('PORT', 6667);
|
|
|
|
define('NICK', 'RawBot');
|
|
|
|
define('WATCH', '#raw-input');
|
|
|
|
define('RELAY', '#raw-output');
|
2011-03-28 14:21:28 +00:00
|
|
|
|
|
|
|
$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");
|
|
|
|
}
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
// Example command
|
2013-06-24 08:00:28 +00:00
|
|
|
if (stripos('!mode', $Line) !== false) {
|
|
|
|
fwrite($Socket, "PRIVMSG ".RELAY." :Mode command used\n");
|
2011-03-28 14:21:28 +00:00
|
|
|
fwrite($Socket, "MODE WhatMan\n");
|
|
|
|
fwrite($Socket, "WHOIS WhatMan\n");
|
|
|
|
fwrite($Socket, "MODE Orbulon\n");
|
|
|
|
}
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2013-06-24 08:00:28 +00:00
|
|
|
fwrite($Socket, 'PRIVMSG '.RELAY." : -----$Line\n");
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|