File: msbot.php (not microsoft bot, multi server bot...)
Code: Select all
<pre>
<?PHP
//### Multi-Server IRC bot By Gogeta70 ###//
set_time_limit(0);
$server = $argv[1];
if(empty($server))
$server = "irc.suck-oold.com";
$port = 6667;
$nick = "G7-multi_srvr";
$channel = $argv[2];
if(empty($channel))
$channel = "#suck-o";
$buffer = array();
$first = TRUE;
$allowed = str_split("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.#-");
$servertmp = $server;
$channeltemp = $channel;
for($a = 0; $a < count($allowed); $a++)
{
$servertemp = str_replace($allowed[$a], NULL, $servertemp);
$channeltemp = str_replace($allowed[$a], NULL, $channeltemp);
}
if(!empty($channeltemp) || !empty($servertemp))
exit(1);
$con = array();
if(!$con[0] = fsockopen($server, $port))
die("Unable to connect to server.");
send("USER $nick fatalh.sytes.net fatalh.sytes.net :$nick", 0);
send("NICK $nick", 0);
while(!feof($con[0]))
{
for($a = 0; $a < count($con); $a++)
{
$buffer[$a] = trim(fgets($con[$a], 4096));
echo " <<< " . $buffer[$a] . chr(10);
}
for($a = 0; $a < count($buffer); $a++)
{
if(substr($buffer[$a], 0, 4) == "PING")
{
send("PONG :" . substr($buffer[$a], 6), $a);
}
}
if($first === TRUE)
{
send("JOIN $channel", 0);
$first = FALSE;
}
for($a = 0; $a < count($buffer); $a++)
{
if($buffer[$a] != NULL)
{
commands($a);
$buffer[$a] = NULL;
}
}
}
function send($cmd, $a)
{ global $con;
//echo "Con$a[". date("g:ia") ."] >>> $cmd\n";
echo " >>> " . $cmd . chr(10);
fputs($con[$a], $cmd . "\r\n");
}
function commands($ofs)
{ global $buffer, $con, $nick;
$chan = explode(" ", $buffer[$ofs]);
@$chan = $chan[2];
$said = explode("$chan :", $buffer[$ofs]);
@$said = $said[1];
$usr = explode("!", $buffer[$ofs]);
@$usr = substr($usr[0], 1);
if(substr($said, 0, 4) == "!say")
{
$what2say = substr($said, 5);
send("PRIVMSG $chan :$what2say", $ofs);
}
if(substr($said, 0, 7) == "!server")
{
$srvr = substr($said, 8);
$srvr = explode(" ", $srvr);
if(!empty($srvr[0])
exec("C:\php\php E:\msbot.php ". $srvr[0] . " " . $srvr[1]);
send("PRIVMSG $chan :Connecting... bot will join channel when connected.", 0);
}
if(substr($said, 0, 5) == "!join")
{
$chnl = substr($said, 6);
send("JOIN $chnl", $ofs);
}
if($said == "!disconnect")
{
if($ofs == 0)
send("QUIT:Multi server bot, Created by Gogeta70", $ofs);
unset($con[$ofs]);
unset($buffer[$ofs]);
}
}