/**
  * 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());
     }
 }
 /**
  * @param ConstructEvent $event
  */
 public function construct(ConstructEvent $event)
 {
     $client = new Client();
     $client->setLoop($event->getLoop());
     $bot = new Bot();
     $bot->setConfig(Configure::read('WyriHaximus.Phergie.config'));
     $bot->setClient($client);
     $bot->run(false);
     EventManager::instance()->dispatch(StartEvent::create($event->getLoop(), $bot));
 }
Example #3
0
 /**
  * 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());
     }
 }
 /**
  * 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 EventQueueFactoryAwareInterface) {
         $plugin->setEventQueueFactory($bot->getEventQueueFactory());
     }
 }
 /**
  * Injects the bot's logger into the plugin if it implements
  * \Psr\Log\LoggerAwareInterface.
  *
  * @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 LoggerAwareInterface) {
         $plugin->setLogger($bot->getLogger());
     }
 }