Esempio n. 1
0
 public function __construct(CommandPRIVMSG $message)
 {
     $this->message = $message;
     if ($message->getBotCommand() === false || $message->getBotCommandParams() === false) {
         throw new \InvalidArgumentException('This CommandPRIVMSG does not have a command associated; CommandEvent can not be fired.');
     }
     $this->command = $message->getBotCommand();
     $this->params = $message->getBotCommandParams();
 }
Esempio n. 2
0
 /**
  * This function handles raising channelMessage events.
  * @param IRCMessageInboundEvent $e The last data received.
  */
 public function channelMessageListener(IRCMessageInboundEvent $e)
 {
     if ($e->getMessage()->getCommand() != 'PRIVMSG') {
         return;
     }
     $message = new CommandPRIVMSG($e->getMessage(), $this->bot->getConfig('prefix'));
     $this->evman()->getEvent('ChannelMessage')->trigger(new ChannelMessageEvent($message->getTargets(), $message));
 }
Esempio n. 3
0
 /**
  * Sets up the bot for initial load.
  * @param string $configFile Optionally load a custom config file
  */
 public function __construct($configFile = WPHP_CONFIG)
 {
     // Set up all managers.
     $this->initializeManagers($configFile);
     $this->nickname = $this->getConfig('nick');
     // Then set up the database.
     $this->db = new \SQLite3($this->getConfig('database'));
     $this->getEventManager()->getEvent('IRCMessageInbound')->registerEventHandler(function ($e) {
         if ($e->getMessage()->getCommand() != 'PRIVMSG') {
             return;
         }
         $msg = new IRC\CommandPRIVMSG($e->getMessage(), $this->getConfig('prefix'));
         if ($msg->getBotCommand() === false) {
             return;
         }
         $this->getEventManager()->getEvent('BotCommand')->trigger(new Event\CommandEvent($msg));
     });
     $this->getEventManager()->getEvent('BotCommand')->setAuthModule($this->getModuleInstance('Auth'));
 }