I wanna make a command that actually lets you do php from inside irc. For example, if I was in an irc channel and I typed:
! $words = "Hi"; echo $words;
Then the bot would respond by saying Hi in the channel.
How could I make a command like that?
This is the code for my bot:
<?php
set_time_limit(0);
$conf['nick'] = 'bot;
$conf['server'] = 'irc.gtanet.com';
$conf['port'] = 6667;
$conf['ident'] = 'bot';
$conf['realname'] = 'bot';
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($socket, $conf['server'], $conf['port']) || die("\nfailed conn\n");
socket_write($socket, 'NICK '.$conf['nick']."\r\n");
socket_write($socket, 'USER '.$conf['ident'].' email.com Simps :'.$conf['realname']."\r\n");
while(($line = socket_read($socket, 1024, PHP_NORMAL_READ)) !== false)
{
if (substr($line, 0, 5) == 'PING ')
{
socket_write($socket,'PONG '.substr($line,5)); continue;
} else {
echo $line;
$ex = explode(' ', $line);
if($ex[1] == '001')
{
socket_write($socket,'JOIN #gta'."\r\n");
} elseif($ex[1] == 'PRIVMSG')
{
unset($chan);
list($nick,$addr) = explode('!',substr($ex[0],1));
$text = substr(rtrim(implode(' ', array_slice($ex, 3))), 1);
if (substr($ex[2], 0, 1) == '#')
{
$chan = $ex[2];
}
if ($text == 'die')
{
if($chan) {
socket_write($socket,'PRIVMSG '.$chan.' :Bye'."\r\n");
} else {
socket_write($socket,'PRIVMSG '.$nick.' :Dying'."\r\n");
}
die("\nRequested\n");
}
}
}
}
?>