Hello guys, I'm a noob in php,
I'm trying to write a php logging bot in some irc channels..
The followings are my code and error msg
connecting to irc
$sock = fsockopen($ircserver,$ircport, $errorno, $errstr, 30);
if ( !$sock ) { echo "Socket connection failed: $errstr\n"; }
else { echo "Making connection to $ircserver:$ircport\n"; }
then here comes the problem part..
function do_cmd ($reqcmd,$reqtype,$reqnick,$reqparams) {
if ( strstr($reqcmd,"help") ) { fputs($sock,"NOTICE $reqnick :Help Fuction\n"); }
}
//Start Handling Data
while ( $sock ) {
//... (here explode and sort the irc protocol..
if ( substr($msg,0,1) == $prefix ) {
$cmd = substr($msg,1,strlen($msg));
do_cmd($cmd,chan,$nick,$msg);
}
}
it seems that I can't call a function ( a function that will write to the socket )
I got this error when I was trying to execute some control commands..
Warning: fputs(): supplied argument is not a valid stream resource in /home/benny/bots/phpbot/bot.php on line 38
where line38 is
if ( strstr($reqcmd,"help") ) { fputs($sock,"NOTICE $reqnick :Help Fuction\n"); }
Thanks for looking 🙂 appreciated