Public feed
#726897
<?php
// No execution Time limit
set_time_limit(0);
// Opening the socket to the Rizon network
$socket = fsockopen("irc.globalogc.org", 443) or die('Could not connect to the server');
// Send auth info
$nick = 'ellis-bot2';
fputs($socket,"USER CMbot combined-minds.net CM :CM bot\n");
fputs($socket,"NICK $nick\n");
// Join a channel
fputs($socket,"JOIN #pvt \n");
// Endless loop until exit.
while(1)
{
// Continue the rest of the script here
while($data = fgets($socket, 128))
{
echo nl2br($data);
flush();
// Separate all data
$ex = explode(' ', $data);
// Respond to PING W/ PONG
if($ex[0] == "PING")
{
fputs($socket, "PONG ".$ex[1]."\n");
}
// Say something in the channel
$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 :Combined-Minds.net irc bot tutorial!\n");
break;
case ':!dienow':
fputs($socket,"PRIVMSG ".$ex[2]." Goodbye cruel world!\n");
die('Session ended.');
break;
default:
}
echo '<pre>';
print_r($ex);
echo '</pre>';
}
usleep(100000);
}
?>