<?php
$config = array();
$config['nickname'] = 'Cocktail';
$config['realname'] = 'Frozen Bot';
$config['ident'] = 'cocktailbot';
$config['hostname'] = 0;
$config['server'] = 'irc.krey.net';
$config['poort'] = 6667;
$config['kanalen'] = array('#Frozen');
if(!$socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP)) {
die('error, unable to create socket');
}
echo 'Socket created'."\n";
if(!socket_bind($socket,$config['hostname'])) {
die('error connection couldn't be bind on hostname '.$config['hostname'].'.');
}
echo 'connection binded'."\n";
if(!socket_connect($socket,$config['server'],$config['poort'])) {
die('Unable to connect to server');
}
echo 'Connecting'."\n";
function schrijf($data) {
global $socket;
socket_write($socket,$data."\r\n");
}
function zeg($bericht,$ontvanger) {
schrijf('PRIVMSG '.$ontvanger.' :'.$bericht);
}
schrijf('USER '.$config['ident'].' '.$config['hostname'].' '.$config['server'].' :'.$config['realname']);
schrijf('NICK '.$config['nickname']);
$inKanaal = false;
while($data = @socket_read($socket,65000,PHP_NORMAL_READ)) {
if($data == "\n") continue;
// If $inKanaal still is false, we still have to join
// We're only able to join if there is a MOTD command.
if($inKanaal == false && strstr($data,'MOTD')) {
for($i = 0; isset($config['kanaal'][$i]); $i++) {
schrijf('JOIN '.$config['kanaal'][$i]);
zeg('Ik ben een überbot!',$config['kanaal'][$i]);
}
$inKanaal = true;
}
// IRC-server will send a ping that needs to be answerd with pong (so you wouldn't be kicked => ghost client)
$eData = explode(' ',$data);
if($eData[0] == 'PING') {
schrijf('PONG '.$eData[1]);
}
// Code here (bot commands)
}
?>
So, my browser says it does it's connections (using xampp) and so on, but the bot just doesn't join the channel
Anybody knows why this is?
Thx
Greetz
Edited by Frozen_W, 20 July 2007 - 05:16 AM.
