Example #1
0
 /**
  * Process an inbound message
  *
  * For each loaded command object, check whether it's interested in processing the message.
  * Run each interested command.
  *
  * @param  JabberBot_Message $message The inbound message.
  *
  * @return void
  */
 private function _processMessage(JabberBot_Message $message)
 {
     if ($message->wasFromMe()) {
         $this->log->log('msg from me ignored', XMPPHP_Log::LEVEL_VERBOSE);
         return;
     }
     $this->log->log('Received Message : ' . $message->body . ' from: ' . $message->from, XMPPHP_Log::LEVEL_INFO);
     if ($message->wasDelayed()) {
         $this->log->log('But ignored it as it was delayed', XMPPHP_Log::LEVEL_INFO);
         return;
     }
     foreach ($this->arrCommands as $command) {
         if ($command->search($message->body)) {
             try {
                 $command->run($message);
             } catch (JabberBot_AccessDeniedException $e) {
                 $this->log->log($e->getMessage(), XMPPHP_Log::LEVEL_INFO);
                 $this->log->log($e->trace, XMPPHP_Log::LEVEL_VERBOSE);
                 $message->reply($this->getRandomQuote('denied'));
             } catch (Exception $e) {
                 $message->reply($e->getMessage());
             }
         }
     }
     $message = null;
     unset($message);
 }