/** * When MQD is activated we also wants that Monique reacts with another * random message. * * @param Bot $pBot Instance of the bot which received this message. */ private function MQDextra(Bot $pBot) { $aMessages = file('Data/Logs/#lvp.echo.log'); $sOriginalMessage = array_slice($aMessages, count($aMessages) - 100); $aMessageWords = explode(' ', $sOriginalMessage[mt_rand(2, count($sOriginalMessage) - 1)]); $sMessage = str_ireplace('Monique', str_replace(array('<', '>'), '', $aMessageWords[1]), $aMessageWords); $pBot->send('PRIVMSG #lvp.echo :!msg ' . Util::getPieces($sMessage, ' ', 2)); }
/** * This function creates a bot with the specified name and network, and * optionally joins a number of channels. * * @param string $sName Nickname of the bot to create. * @param string $sNetwork Name of the network to connect with. * @param array $aChannels Array of channels to auto-join. */ public function create($sName, $sNetwork, $aChannels = array()) { $pBot = new Bot($sName); $pBot->setNetwork($sNetwork); $pBot->connect(); foreach ((array) $aChannels as $sChannel) { $pBot->send('JOIN ' . $sChannel); } }
/** * In order for the user to be able to login with their password and obtain their elevated rights, we need to * catch their login attempt. For completeness sake, we also handle the logout command here. * * @param Bot $bot The bot that received the message. * @param string $nickname The nickname of the user. * @param string $message The actual message the user sent us. */ public function onPrivmsg(Bot $bot, $nickname, $message) { if ($bot != $this->bot) { return; } if (substr($message, 0, 6) == 'login ') { if ($this->identifyUser($bot->In->User, md5(substr($message, 6)))) { $bot->send('PRIVMSG ' . $nickname . ' :You have successfully identified yourself!'); return; } else { $bot->send('PRIVMSG ' . $nickname . ' :Incorrect password.'); return; } } else { if (substr($message, 0, 6) == 'logout') { if ($this->logoutUser($bot->In->User)) { $bot->send('PRIVMSG ' . $nickname . ' :You have been logged out successfully.'); return; } } } }