Author: Phergie Development Team (team@phergie.org)
Inheritance: extends Phergie_Event_Request
Exemplo n.º 1
0
 /**
  * Adds an event to the queue.
  *
  * @param Phergie_Plugin_Abstract $plugin Plugin originating the event
  * @param string                  $type   Event type, corresponding to a 
  *        Phergie_Event_Command::TYPE_* constant
  * @param array                   $args   Optional event arguments
  *
  * @return Phergie_Event_Handler Provides a fluent interface
  */
 public function addEvent(Phergie_Plugin_Abstract $plugin, $type, array $args = array())
 {
     if (!defined('Phergie_Event_Command::TYPE_' . strtoupper($type))) {
         throw new Phergie_Event_Exception('Unknown event type "' . $type . '"', Phergie_Event_Exception::ERR_UNKNOWN_EVENT_TYPE);
     }
     $event = new Phergie_Event_Command();
     $event->setPlugin($plugin)->setType($type)->setArguments($args);
     $this->events[] = $event;
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Tests that a plugin can be associated with an event.
  *
  * @return void
  */
 public function testSetPlugin()
 {
     $plugin = $this->getMock('Phergie_Plugin_Abstract');
     $this->event->setPlugin($plugin);
     $this->assertSame($plugin, $this->event->getPlugin());
 }
Exemplo n.º 3
0
 /**
  * Assert that the emitter of the given command event was the given
  * plugin
  *
  * @param Phergie_Event_Command   $event
  * @param Phergie_Plugin_Abstract $plugin
  * @param string                  $message
  */
 public function assertEventEmitter(Phergie_Event_Command $event, Phergie_Plugin_Abstract $plugin, $message = null)
 {
     $this->assertSame($plugin, $event->getPlugin(), $message);
 }
Exemplo n.º 4
0
 /**
  * Outputs a prompt when the bot sends a command to a server.
  *
  * @param Phergie_Event_Command $event      Event representing the 
  *        command being sent
  * @param Phergie_Connection    $connection Connection on which the 
  *        command is being sent 
  *
  * @return void
  */
 public function onCommand(Phergie_Event_Command $event, Phergie_Connection $connection)
 {
     $plugin = $event->getPlugin()->getName();
     $host = $connection->getHostmask()->getHost();
     $type = strtoupper($event->getType());
     $args = implode(' ', $event->getArguments());
     $this->console($plugin . ' plugin: ' . $host . ' -> ' . $type . ' ' . $args);
 }