/** * Main plugin handler for help requests * * @param \Phergie\Irc\Plugin\React\Command\CommandEvent $event * @param \Phergie\Irc\Bot\React\EventQueueInterface $queue */ public function handleCommandHelp(Event $event, Queue $queue) { $params = $event->getCustomParams(); $provider = $this->getProvider($event->getCustomCommand() === "help" ? $params[0] : $event->getCustomCommand()); if ($provider) { $this->sendIrcResponse($event, $queue, $provider->getHelpLines()); } }
/** * Set up the API request and set the callbacks * * @param \Phergie\Irc\Plugin\React\Command\CommandEvent $event * @param \Phergie\Irc\Bot\React\EventQueueInterface $queue * @return \Phergie\Plugin\Http\Request */ protected function getApiRequest(Event $event, Queue $queue) { $provider = $this->getProvider($event->getCustomCommand()); $self = $this; return new HttpRequest(array('url' => $provider->getApiRequestUrl($event), 'resolveCallback' => function (Response $response) use($self, $event, $queue, $provider) { $self->sendIrcResponse($event, $queue, $provider->getSuccessLines($event, $response->getBody())); }, 'rejectCallback' => function (Response $error) use($self, $event, $queue) { $self->sendIrcResponse($event, $queue, $self->getRejectLines($error->getBody())); })); }
/** * Tests setCustomCommand(). */ public function testSetCustomCommand() { $command = 'foo'; $this->event->setCustomCommand($command); $this->assertSame($command, $this->event->getCustomCommand()); }