Returns the IRC client in use by the bot.
public getClient ( ) : Phergie\Irc\Client\React\ClientInterface | ||
return | Phergie\Irc\Client\React\ClientInterface |
/** * Injects the event loop of the bot's client into the plugin if it implements * \Phergie\Irc\Bot\React\LoopInterface. * * @param \Phergie\Irc\Bot\React\PluginInterface $plugin Loaded plugin * @param \Phergie\Irc\Bot\React\Bot $bot Bot that loaded the plugin */ public function process(PluginInterface $plugin, Bot $bot) { $client = $bot->getClient(); if ($plugin instanceof LoopAwareInterface && $client instanceof LoopAccessorInterface) { $plugin->setLoop($client->getLoop()); } }
/** * Tests that dependencies can be overridden via configuration. */ public function testOverrideDependencies() { $client = $this->getMockClient(); $logger = $this->getMockLogger(); $parser = $this->getMockParser(); $converter = $this->getMockConverter(); $eventQueueFactory = $this->getMockEventQueueFactory(); $config = array('client' => $client, 'logger' => $logger, 'parser' => $parser, 'converter' => $converter, 'eventQueueFactory' => $eventQueueFactory, 'plugins' => array(), 'connections' => array($this->getMockConnection())); $this->bot->setConfig($config); $this->bot->run(); $this->assertSame($client, $this->bot->getClient()); $this->assertSame($logger, $this->bot->getLogger()); $this->assertSame($parser, $this->bot->getParser()); $this->assertSame($converter, $this->bot->getConverter()); $this->assertSame($eventQueueFactory, $this->bot->getEventQueueFactory()); }
/** * Injects the bot's client into the plugin if it implements * \Phergie\Irc\Bot\React\ClientAwareInterface. * * @param \Phergie\Irc\Bot\React\PluginInterface $plugin Loaded plugin * @param \Phergie\Irc\Bot\React\Bot $bot Bot that loaded the plugin */ public function process(PluginInterface $plugin, Bot $bot) { if ($plugin instanceof ClientAwareInterface) { $plugin->setClient($bot->getClient()); } }