<html>
<head>
<title>IRC Bot</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?php
// Prevent PHP from stopping the script after 30 sec
set_time_limit(0);
// Opening the socket to the SwiftIRC network
$socket = fsockopen("irc.swiftirc.net", 6667)
// Send auth info
fputs($socket,"USER WhiteyBot pink-lemon.co.uk WB : Whitey\n");
fputs($socket,"NICK WhiteyBot \n");
// Join channel
fputs($socket,"JOIN #weepee\n");
// Force an endless while
while(1) {
// Continue the rest of the script here
while($data = fgets($socket, 128)) {
echo nl2br($data);
flush();
// Separate all data
$ex = explode(' ', $data);
// Send PONG back to the server
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]);
if ($command == ":!cmack") {
fputs($socket, "PRIVMSG ".$ex[2]." :GOT ON THE BUS WIT MY DAY SAVA\n");
if($command == ":!stop"){
fputs($socket,"PRIVMSG $ex[2] Bot stopped!\n");
sleep(0.1);
}
}
}
}
?>
</html>