예제 #1
0
파일: Done.php 프로젝트: xety/marsbot
 /**
  * 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;
 }
예제 #2
0
파일: Developer.php 프로젝트: xety/marsbot
 /**
  * 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']);
     }
 }