/** * Handles the PRIVMSG command * * @param string $input * @param array<string> $inputEx * @return void */ public static function PRIVMSG($input, $inputEx) { if ($inputEx[2][0] != '$') { // get source $source = Services::getUserManager()->getUser($inputEx[0]); if ($inputEx[2][0] == '#' and $source !== null) { // send debug message if (defined('DEBUG')) { Services::getConnection()->getProtocol()->sendLogLine($source->getUuid() . " (" . $source->getNick() . ") sent a message to " . $inputEx[2]); } // notify module manager Services::getModuleManager()->handleLine($source, $inputEx[2], substr($input, stripos($input, ':') + 1)); } elseif ($source) { // kick numeric $inputEx[2] = substr($inputEx[2], strlen(Services::getConnection()->getProtocol()->numeric)); // send debug message if (defined('DEBUG')) { Services::getConnection()->getProtocol()->sendLogLine($source->getUuid() . " (" . $source->getNick() . ") sent a message to " . $inputEx[2]); } // try to find bot if (($bot = Services::getBotManager()->getUser($inputEx[2])) !== null) { // resolved uuid ... send debug message if (defined('DEBUG')) { Services::getConnection()->getProtocol()->sendLogLine("Resolved " . $inputEx[2] . " to " . $bot->getNick()); } // notify module manager Services::getModuleManager()->handleLine($source, $inputEx[2], substr($input, stripos($input, ':') + 1)); } else { // cannot find user ... send debug message if (defined('DEBUG')) { Services::getConnection()->getProtocol()->sendLogLine("Cannot resolve '" . $inputEx[2] . "'! Type of return value: " . gettype($bot)); } } } else { Services::getConnection()->getProtocol()->sendLogLine("Received invalid UUID '" . $inputEx[0] . "'! Maybe choosen wrong IRCd?"); } } }
/** * Creates a new bot * * @param string $nick * @param string $hostname * @param string $ident * @param string $ip * @param string $modes * @param string $gecos * @return AbstractUserType */ public function createBot($nick, $hostname, $ident, $ip, $modes, $gecos) { // get current unix timestamp $timestamp = time(); // create user in bot manager $uuid = Services::getBotManager()->introduceUser($timestamp, $nick, $hostname, $hostname, $ident, $ip, $timestamp, $modes, $gecos); // send SVSHOLD command // Services::getConnection()->sendServerLine("SVSHOLD ".$nick." :Reserved for services"); // send uid command Services::getConnection()->sendServerLine("UID " . $this->numeric . $uuid . " " . $timestamp . " " . $nick . " " . $hostname . " " . $hostname . " " . $ident . " " . $ip . " " . $timestamp . " " . $modes . " :" . $gecos); // return bot object return Services::getBotManager()->getUser($uuid); }