message(SMARTIRC_TYPE_QUERY, $data->nick, 'No help is available at this time.'); } function whoareyou(&$irc, &$data) { $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'All is well.'); } function master(&$irc, &$data) { $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'Master created me.'); } function join(&$irc, &$data) { //need the channel if (isset($data->messageex[1])) { $channel = $data->channel; $irc->join($channel); } else { $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'No valid channel has been specified.'); } } function kick(&$irc, &$data) { // we need the nickname parameter if(isset($data->messageex[1])) { $nickname = $data->messageex[1]; $channel = $data->channel; $irc->kick($channel, $nickname); } else { $irc->message( $data->type, $data->nick, 'Wrong.' ); $irc->message( $data->type, $data->nick, 'usage: !kick $nickname' ); } } function tell(&$irc, &$data) { $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', $data->nick.' said "'.$data->message.'" to you!'); $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, 'I told everyone on #GWing what you said!'); } function onjoin_greeting(&$irc, &$data) { // if _we_ join, don't greet ourself, just jump out via return if ($data->nick == $irc->_nick) return; // now check if this is the right channel if ($data->channel == '#GWing') // it is, lets greet the joint user $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'Welcome '.$data->nick).'!'; } function fight(&$irc, &$data) { $name = $data->nick; $running = '0'; if(isset($data->messageex[1])) { $timing = $data->messageex[1]; if ($running == '1') { $irc->message(SMART_IRC_TYPE_CHANNEL, '#GWing', 'I\'m already fighting! Wait your turn!'); } else { if ($timing <= '1000') { $irc->message(SMART_IRC_TYPE_CHANNEL, '#GWing', 'A second per line is quite fast, and it would cause me to flood the servers.'); $irc->message(SMART_IRC_TYPE_CHANNEL, '#GWing', 'So, in short... no.'); } else { $running = '1'; $fight = &new fight(); $irc->registerTimehandler($timing, $fight, 'training'); } } } else { $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'Usage: !train '); $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'Where is the amount of time in milliseconds between lines.'); } } function insult(&$irc, &$data) { // we need the nickname parameter if (isset($data->messageex[1]) and $data->messageex[1]=="HAL") { $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'I\'m sorry. I can\'t do that right now.'); } else if (isset($data->messageex[1])) { $randinsult = rand(1,4); if ($randinsult == 1) { $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', $data->messageex[1].' is a stinking rhinoceros pizzle.'); } if ($randinsult == 2) { $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', $data->messageex[1].' tends to pick his nose.'); } if ($randinsult == 3) { $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', $data->messageex[1].' is in love with William Hung.'); } if ($randinsult == 4) { $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', $data->messageex[1].' is a dirty trash recepticle for sperm.'); } } else { $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'I\'m sorry. You have not supplied the correct parameters, so I am unable to comply.'); $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'Please try again.'); } } function shutdown(&$irc, &$data) { $password = $data->messageex[1]; if($data->nick=='Master') { $irc->quit('Yes SIR!'); } else { $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'You do not have the appropriate permissions to execute that command.'); } } } class fight { function training(&$irc, &$data) { $nick = $data->nick; if (!isset($type)) { $line = $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'Roger that. Commencing training session.'); global $type = 1; } else { $randomline = rand(1,3); if ($randomline == 1) { global $type = 1; } if ($randomline == 2) { global $type = 2; } if ($randomline == 3) { } } switch($type) { case "1": $line = $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', '-= He would begin to move, slightly extending his words =-'); break; case "2": $line = $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', '-= Comes forth to bring upwards his attack for the trainee =-'); break; case "3": $line = $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', '-= Drives in to connect with his previous attack =-'); break; } return $line; } } $bot = &new mybot(); $irc = &new Net_SmartIRC(); $irc->setDebug(SMARTIRC_DEBUG_ALL); $irc->setUseSockets(TRUE); $irc->setChannelSyncing(TRUE); $irc->registerActionhandler(SMARTIRC_TYPE_JOIN, 'GWingUser', $bot, 'onjoin_greeting'); $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!status', $bot, 'whoareyou'); $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!master', $bot, 'master'); $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!train', $bot, 'fight'); $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!shutdown', $bot, 'shutdown'); $irc->registerActionhandler(SMARTIRC_TYPE_QUERY, '^!shutdown', $bot, 'shutdown'); $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!join', $bot, 'join'); $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!kick', $bot, 'kick'); $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!tell', $bot, 'tell'); $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!insult', $bot, 'insult'); $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!help', $bot, 'help'); $irc->connect('irc.surrealchat.net', 6667); $irc->login('HAL', 'HALscript', 0, 'GWing', 'c0mputer'); $irc->join(array('#GWing')); $irc->listen(); $irc->disconnect(); ?>