<?php
$bot = array();
$bot['nickname'] = 'UberBot';
$bot['realname'] = 'Mr. UberBot';
$bot['ident'] = 'uberbot';
$bot['hostname'] = '127.0.0.1';
$bot['server'] = 'irc.rizon.net';
$bot['port'] = 6667;
$bot['chan'] = '#Manekian';
if (!$bot['socket']=socket_create(AF_INET,SOCK_STREAM,SOL_TCP)) {
die("Could not create the socket.");
}
if (!socket_bind($bot['socket'],$bot['hostname'])) {
die("Couldn't merge the connecetion with ".$bot['hostname'].".");
}
if (!socket_connect($bot['socket'],$bot['server'],$bot['port'])) {
die("Could not connect to the server: ".$bot['server'].".");
}
function sockwrite($data){
global $bot;
socket_write($bot['socket'],$data."\r\n");
}
sockwrite("USER ".$bot['ident']." ".$bot['hostname']." ".$bot['server']." :".$bot['realname']);
sockwrite("NICK ".$bot['nickname']);
$channel = 0; // Deze var komt later wel terug :)
while ($data=@socket_read($bot['socket'],65000,PHP_NORMAL_READ)) {
if($data == "\n") continue;
// De data die we binnen krijgen, splitten we alvast op voor het makkelijk aanspreken.
$edata = explode(" ",$data);
for($i=0; isset($edata[$i]); $i++) {
$edata[$i]=trim($edata[$i]);
}
// De variable $channel die net is geset, gaan we nou controleren.
if ($channel == "0") {
// De variable is nog 0, we moeten nog een kanaal in !
sockwrite("JOIN ".$bot['chan']);
$channel = 1;
}
// Hier is er een PING binnengekomen. Deze gaan we antwoorden met PONG
if($edata[0] == "PING") {
sockwrite("PONG ".$edata[1]);
}
// Hier komen alle scripts te staan.
require('scripts.php');
}
?>