/** * The bot has enter in the room and has got all the packet. * * @param \Mars\Network\Server $server The server instance. * @param array $data The data received from the socket. * * @return bool */ public function onDone(Server $server, $data) { if (Configure::read('Xavi.enabled') === true) { if (!is_numeric(Configure::read('Xavi.id'))) { return false; } $xavi = Xavi::get(Configure::read('Xavi.id')); if ($xavi === false) { $server->ModuleManager->message('Error to get the xavi of the user ' . Configure::read('Xavi.id')); return false; } $result = Xavi::post($xavi, $server->Room->loginInfos); if ($result === false) { $server->ModuleManager->message('Error to save the xavi.'); return false; } $server->ModuleManager->message('My xavi has been saved successfully with the MarsBot ! Thanks to Mars. :)'); $server->Socket->disconnect(); return true; } return false; }
/** * Handle the xavi command. * * @param \Mars\Network\Server $server The server instance. * @param \Mars\Message\Message $message The message instance. * * @return bool|void */ protected function _handleXavi(Server $server, $message) { switch ($message->arguments[0]) { case 'use': $xavi = Xavi::get($message->arguments[1]); if ($xavi === false) { $server->ModuleManager->message('Error to get the xavi of the user ' . $message->arguments[1]); break; } $result = Xavi::post($xavi, $server->Room->loginInfos); if ($result === false) { $server->ModuleManager->message('Error to save the xavi.'); break; } $server->ModuleManager->message('The xavi has been saved successfully !'); break; default: $server->ModuleManager->message('Unknown command. Syntax: ' . $this->_commands[$message->command]['syntax']); } }