<?php
$socket = fsockopen("tcp://xxx.xxx.xxx.xxx", 66xx) or die('Could not connect to the server');
$nick = 'PrOvA';
fputs($socket,"USER SuperGatto BoT CM :CM bot\n");
fputs($socket,"NICK $nick\n");
fputs($socket,"PRIVMSG NickServ :identify $nick list\n");
fputs($socket,"JOIN #test\n");
fputs($socket, "PRIVMSG #test :4,2Ciao a tutti! (Powered by SuperGatto)\n");
while(1)
{
while($data = fgets($socket, 128))
{
echo nl2br($data);
flush();
$ex = explode(' ', $data);
if($ex[0] == "PING")
{
fputs($socket, "PONG ".$ex[1]."\n");
}
$command = str_replace(array(chr(10), chr(13)), '', $ex[3]);
switch($command)
{
case ':!sayit':
if($ex[2] != $nick)
{
$to = $ex[2];
}
else
{
$arr = explode('!', $ex[0]);
$to = ltrim($arr[0],':');
}
fputs($socket, "PRIVMSG $to :4,2Hello!\n");
break;
case ':ciao':
fputs($socket,"PRIVMSG #test 4,2ciao!\n");
break;
case ':!quit':
fputs($socket,"Quit 4,2Programma creato da SuperGatto e ricordate visitate
****** ;)\n");
break;
case ':!version':
fputs($socket,"PRIVMSG #test 4,2Version 1.0 beta Powered by SuperGatto\n");
break;
default:
}
echo '<pre>';
print_r($ex);
echo '</pre>';
}
usleep(100000);
}
?>