|
Erebot
latest
A modular IRC bot for PHP 5.3+
|
Handles a (possibly encrypted) connection to an IRC server. More...
Inheritance diagram for Erebot\IrcConnection:Protected Member Functions | |
| dispatchEvent (\Erebot\Interfaces\Event\Base\Generic $event) | |
| dispatchNumeric (\Erebot\Interfaces\Event\Numeric $numeric) | |
| loadModules (\Erebot\Interfaces\Config\Server $config, $flags) | |
| realLoadModule ($module, $chan, $flags, &$plainModules, &$channelModules) | |
Protected Attributes | |
| $bot | |
| A bot object implementing the Erebot::Interfaces::Core interface. | |
| $channelModules | |
| Maps channels to their loaded modules. | |
| $collator | |
| Collator for IRC nicknames. | |
| $config | |
| $connected | |
| Whether this connection is actually... well, connected. | |
| $events | |
| A list of event handlers. | |
| $eventsProducer | |
| Class to use to parse IRC messages and produce events from them. | |
| $io | |
| I/O manager for the socket. | |
| $numericProfile | |
| Numeric profile. | |
| $numerics | |
| A list of numeric handlers. | |
| $plainModules | |
| Maps modules names to modules instances. | |
| $socket | |
| The underlying socket, represented as a stream. | |
| $uriFactory | |
| Factory to use to parse URI. | |
Handles a (possibly encrypted) connection to an IRC server.
Definition at line 27 of file IrcConnection.php.
| Erebot\IrcConnection::__construct | ( | \Erebot\Interfaces\Core | $bot, |
| \Erebot\Interfaces\Config\Server | $config = null, |
||
$events = array() |
|||
| ) |
Constructs the object which will hold a connection.
| Erebot::Interfaces::Core | $bot | A bot instance. |
| Erebot::Interfaces::Config::Server | $config | The connfiguration for this connection. |
| array | $events | (optional) A mapping of event interface names to the class that must be used to produce such events (factory). |
Definition at line 90 of file IrcConnection.php.
| Erebot\IrcConnection::__destruct | ( | ) |
Destructor.
Definition at line 132 of file IrcConnection.php.
| Erebot\IrcConnection::connect | ( | ) |
Makes the actual connection to an IRC server, using the configuration data passed to the constructor.
| Erebot::ConnectionFailureException | Thrown whenever the bot fails to establish a connection to the given server. |
Implements Erebot\Interfaces\Connection.
Definition at line 314 of file IrcConnection.php.
| Erebot\IrcConnection::disconnect | ( | $quitMessage = null | ) |
Disconnects the bot from that particular IRC server.
| string | $quitMessage | (optional) A message which will be visible by other users when the bot gets disconnected. If no message is given, the IrcConnector module is probed for its "quit_message" parameter. If no message is available, the bot quits with an empty string as its quit message. |
Implements Erebot\Interfaces\Connection.
Definition at line 464 of file IrcConnection.php.
References Erebot\Utils\stringifiable().
| Erebot\IrcConnection::dispatch | ( | \Erebot\Interfaces\Event\Base\Generic | $event | ) |
Dispatches the given event to handlers which have been registered for this type of event.
| Erebot::Interfaces::Event::Base::Generic | $event | An event to dispatch. |
Implements Erebot\Interfaces\EventDispatcher.
Definition at line 802 of file IrcConnection.php.
|
protected |
Dispatches the given event to handlers which have been registered for this type of event.
| Erebot::Interfaces::Event::Base::Generic | $event | An event to dispatch. |
Definition at line 755 of file IrcConnection.php.
|
protected |
Dispatches the given numeric event to handlers which have been registered for this type of numeric.
| Erebot::Interfaces::Event::Numeric | $numeric | A numeric message to dispatch. |
Definition at line 782 of file IrcConnection.php.
| Erebot\IrcConnection::getBot | ( | ) |
Returns the bot instance this connection is associated with.
| Erebot::Interfaces::Core | An instance of the core class (Erebot). |
Implements Erebot\Interfaces\Connection.
Definition at line 519 of file IrcConnection.php.
| Erebot\IrcConnection::getCollator | ( | ) |
Returns the collator associated with this connection.
| Erebot::Interfaces::IrcCollator | The collator for this connection. |
Implements Erebot\Interfaces\Collated.
Definition at line 910 of file IrcConnection.php.
| Erebot\IrcConnection::getConfig | ( | $chan | ) |
Retrieves the configuration for a given channel.
| null | string | $chan | The name of the IRC channel for which a configuration must be retrieved. If $chan is null, the configuration associated with this object is returned instead (an instance of the Erebot::Interfaces::Config::Server). |
| Erebot::Interfaces::Config::Channel | The configuration for the given channel, if there is one. |
| Erebot::Interfaces::Config::Server | Otherwise, the configuration for the associated IRC server. |
| Erebot::NotFoundException | No Erebot::Interfaces::Config::Channel object exists for the given channel. |
Implements Erebot\Interfaces\Connection.
Definition at line 498 of file IrcConnection.php.
| Erebot\IrcConnection::getEventsProducer | ( | ) |
Returns the object used to produce events.
| Erebot::Interfaces::IrcParser | Object used to produce events. |
Implements Erebot\Interfaces\IrcConnection.
Definition at line 915 of file IrcConnection.php.
| Erebot\IrcConnection::getIO | ( | ) |
Returns the object used to handle I/O (input/output) with this connection.
Implements Erebot\Interfaces\Connection.
Definition at line 524 of file IrcConnection.php.
| Erebot\IrcConnection::getModule | ( | $name, | |
$chan = null, |
|||
$autoload = true |
|||
| ) |
Returns an instance of a given module on a given channel.
| string | $name | The name of the module (ie. the name of the class implementing the feature we're interested in). |
| string | $chan | (optional) An IRC channel name. If given, the bot will try to return an instance which is specific to that particular channel, before falling back to a shared instance. Otherwise, this method only looks for a shared instance. |
| bool | $autoload | (optional) Whether the module should be autoloaded if it could not be found first time around (true) or not (false). The default is to autoload missing modules. |
| Erebot::Module::Base | An instance of the given module. |
| Erebot::InvalidValueException | Thrown when an invalid $type is passed. |
| Erebot::NotFoundException | Thrown if no instance of the given module could be found. |
Implements Erebot\Interfaces\ModuleContainer.
Definition at line 690 of file IrcConnection.php.
| Erebot\IrcConnection::getModules | ( | $chan = null | ) |
Returns the modules loaded for a given channel or for the whole connection.
| string | $chan | (optional) An IRC channel name. If given, both the modules which were specifically loaded for that channel and the shared modules are returned. Otherwise, only the shared modules are returned. |
| array | A list of module instances implementing Erebot::Module::Base. |
Implements Erebot\Interfaces\ModuleContainer.
Definition at line 679 of file IrcConnection.php.
| Erebot\IrcConnection::getNumericProfile | ( | ) |
Returns the numeric profile associated with this connection.
| Erebot::NumericProfile::Base | The numeric profile associated with this connection. |
Implements Erebot\Interfaces\IrcConnection.
Definition at line 176 of file IrcConnection.php.
| Erebot\IrcConnection::getSocket | ( | ) |
Returns the underlying transport implementation for this connection.
| stream | Returns this connection's socket, as a PHP stream. |
Implements Erebot\Interfaces\Connection.
Definition at line 514 of file IrcConnection.php.
| Erebot\IrcConnection::getURIFactory | ( | ) |
Returns the name of the class used to parse Uniform Resource Identifiers.
| string | Name of the class used to parse an URI. |
Definition at line 153 of file IrcConnection.php.
| Erebot\IrcConnection::handleCapabilities | ( | \Erebot\Interfaces\EventHandler | $handler, |
| \Erebot\Event\ServerCapabilities | $event | ||
| ) |
Handles the "ServerCapabilities" event.
| Erebot::Interfaces::EventHandler | $handler | The event handler responsible for calling this method. |
| Erebot::Event::ServerCapabilities | $event | The "ServerCapabilities" event to process. |
Definition at line 856 of file IrcConnection.php.
| Erebot\IrcConnection::handleConnect | ( | \Erebot\Interfaces\EventHandler | $handler, |
| \Erebot\Interfaces\Event\Connect | $event | ||
| ) |
Handles the "Connect" event.
| Erebot::Interfaces::EventHandler | $handler | The event handler responsible for calling this method. |
| Erebot::Interfaces::Event::Connect | $event | The "Connect" event to process. |
Definition at line 885 of file IrcConnection.php.
| Erebot\IrcConnection::isChannel | ( | $chan | ) |
Determines if the given string is a valid channel name or not. A channel name usually starts with the hash symbol (#). Valid characters for the rest of the name vary between IRC networks.
| $chan | Tentative channel name. |
| bool | true if $chan is a valid channel name, false otherwise. |
| Erebot::InvalidValueException::$chan | is not a string or is empty. |
Implements Erebot\Interfaces\IrcConnection.
Definition at line 810 of file IrcConnection.php.
| Erebot\IrcConnection::isConnected | ( | ) |
Returns whether this connection object is currently connected to a server.
| bool | true if the connection is really connected, false otherwise. |
Implements Erebot\Interfaces\Connection.
Definition at line 309 of file IrcConnection.php.
| Erebot\IrcConnection::loadModule | ( | $module, | |
$chan = null |
|||
| ) |
Loads a module for a specific channel or for the whole connection.
| string | $module | The name of the module to load. |
| NULL | string | $chan | (optional) An IRC channel name. If given, the module will be loaded and a specific instance will be created for that $chan. Otherwise, an instance will be created that will be shared across channels on the same connection. |
| Erebot::Module::Base | An instance of the module. |
| Erebot::InvalidValueException | Thrown when invalid values are found in the (meta)data of the module. |
| Erebot::NotFoundException | Thrown when a required dependency could not be loaded. You may want to load the required dependency and then try to load the module again. |
Implements Erebot\Interfaces\ModuleContainer.
Definition at line 668 of file IrcConnection.php.
|
protected |
(Re)Load the modules for this connection.
| Erebot::Interfaces::Config::Server | $config | A server configuration that describes the modules to load. |
| int | $flags | Flags that will be passed to the reload() method of every module that needs reloading. This is a bitwise-OR of the RELOAD_* constants defined in Erebot::Module::Base. |
Definition at line 214 of file IrcConnection.php.
| Erebot\IrcConnection::read | ( | ) |
Processes data from the incoming buffer.
Once this method has been called, all lines awaiting processing in the incoming buffer have been transferred to the incoming FIFO. You must call Erebot::Connection::processQueuedData() after that in order to process the lines in the FIFO. This is done so that a throttling policy may be put in place if needed (eg. for an anti-flood system).
Implements Erebot\Interfaces\ReceivingConnection.
Definition at line 529 of file IrcConnection.php.
|
protected |
Load a single module for this connection.
| string | $module | Name of the module to load. If the module is already loaded, nothing will happen. |
| string | null | $chan | Name of the IRC channel for which this module is being loaded. Pass null to load a module globally (for the whole connection) rather than for a specific IRC channel. |
| opaque | $flags | Bitwise-OR combination of flags to pass to the module's initialization method. |
| array | $plainModules | An associative array containing the global modules currently loaded. This array will be updated if it needs to be once the module has been successfully loaded. |
| array | $channelModules | An associative array containing the modules currently loaded for the given IRC channel. This array will be updated if it needs to be once the module has been successfully loaded. |
| Erebot::Module::Base | An instance of the module with the given name. |
Definition at line 621 of file IrcConnection.php.
| Erebot\IrcConnection::reload | ( | \Erebot\Interfaces\Config\Server | $config | ) |
Reloads/sets the configuration for this connection.
| Erebot::Interfaces::Config::Server | $config | The new configuration for this connection. |
Definition at line 192 of file IrcConnection.php.
| Erebot\IrcConnection::setCollator | ( | \Erebot\Interfaces\IrcCollator | $collator | ) |
Sets the collector to use for this connection.
| Erebot::Interfaces::Collator | $collator | The new collator to use for this connection. |
Definition at line 898 of file IrcConnection.php.
| Erebot\IrcConnection::setNumericProfile | ( | \Erebot\NumericProfile\Base | $profile | ) |
Sets the new numeric profile for this connection.
| Erebot::NumericProfile::Base | $profile | The new numeric profile to use for this connection. |
Implements Erebot\Interfaces\IrcConnection.
Definition at line 181 of file IrcConnection.php.
| Erebot\IrcConnection::setURIFactory | ( | $factory | ) |
Sets the class to use as a factory to parse Uniform Resource Identifiers.
| string | $factory | Name of the class to use to parse an URI. |
Definition at line 165 of file IrcConnection.php.
| Erebot\IrcConnection::write | ( | ) |
Sends a single line of data from the outgoing FIFO to the underlying socket.
This method is misnamed, because it acts on a FIFO rather than on raw data. This method can be called multiple times (such as in a loop) to send all lines in the outgoing FIFO. This is done so that a throttling policy may be put in place if needed (eg. for an anti-flood system).
Implements Erebot\Interfaces\SendingConnection.
Definition at line 553 of file IrcConnection.php.
|
protected |
A configuration object implementing the Erebot::Interfaces::Config::Server interface.
Definition at line 33 of file IrcConnection.php.