Erebot  latest
A modular IRC bot for PHP 7.0+
Erebot\IrcConnection Class Reference

Handles a (possibly encrypted) connection to an IRC server. More...

+ Inheritance diagram for Erebot\IrcConnection:

Public Member Functions

 __construct (\Erebot\Interfaces\Core $bot,\Erebot\Interfaces\Config\Server $config=null, $events=array())
 
 __destruct ()
 
 addEventHandler (\Erebot\Interfaces\EventHandler $handler)
 
 addNumericHandler (\Erebot\Interfaces\NumericHandler $handler)
 
 connect ()
 
 disconnect ($quitMessage=null)
 
 dispatch (\Erebot\Interfaces\Event\Base\Generic $event)
 
 getBot ()
 
 getCollator ()
 
 getConfig ($chan)
 
 getEventsProducer ()
 
 getIO ()
 
 getModule ($name, $chan=null, $autoload=true)
 
 getModules ($chan=null)
 
 getNumericProfile ()
 
 getSocket ()
 
 getURIFactory ()
 
 handleCapabilities (\Erebot\Interfaces\EventHandler $handler,\Erebot\Event\ServerCapabilities $event)
 
 handleConnect (\Erebot\Interfaces\EventHandler $handler,\Erebot\Interfaces\Event\Connect $event)
 
 isChannel ($chan)
 
 isConnected ()
 
 loadModule ($module, $chan=null)
 
 process ()
 Processes commands queued in the input buffer.
 
 read ()
 
 reload (\Erebot\Interfaces\Config\Server $config)
 
 removeEventHandler (\Erebot\Interfaces\EventHandler $handler)
 
 removeNumericHandler (\Erebot\Interfaces\NumericHandler $handler)
 
 setCollator (\Erebot\Interfaces\IrcCollator $collator)
 
 setNumericProfile (\Erebot\NumericProfile\Base $profile)
 
 setURIFactory ($factory)
 
 write ()
 

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.
 

Detailed Description

Handles a (possibly encrypted) connection to an IRC server.

Definition at line 27 of file IrcConnection.php.

Constructor & Destructor Documentation

Erebot\IrcConnection::__construct ( \Erebot\Interfaces\Core  $bot,
\Erebot\Interfaces\Config\Server  $config = null,
  $events = array() 
)

Constructs the object which will hold a connection.

Parameters
Erebot::Interfaces::Core$botA bot instance.
Erebot::Interfaces::Config::Server$configThe 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).
Note
No connection (in the socket sense) is actually created until Erebot::Interfaces::Connection::connect() is called.

Definition at line 90 of file IrcConnection.php.

Erebot\IrcConnection::__destruct ( )

Destructor.

Definition at line 132 of file IrcConnection.php.

Member Function Documentation

Erebot\IrcConnection::dispatchEvent ( \Erebot\Interfaces\Event\Base\Generic  $event)
protected

Dispatches the given event to handlers which have been registered for this type of event.

Parameters
Erebot::Interfaces::Event::Base::Generic$eventAn event to dispatch.

Definition at line 755 of file IrcConnection.php.

Erebot\IrcConnection::dispatchNumeric ( \Erebot\Interfaces\Event\Numeric  $numeric)
protected

Dispatches the given numeric event to handlers which have been registered for this type of numeric.

Parameters
Erebot::Interfaces::Event::Numeric$numericA numeric message to dispatch.

Definition at line 782 of file IrcConnection.php.

Erebot\IrcConnection::getCollator ( )

Returns the collator associated with this connection.

Return values
Erebot::Interfaces::IrcCollatorThe collator for this connection.

Definition at line 910 of file IrcConnection.php.

Erebot\IrcConnection::getURIFactory ( )

Returns the name of the class used to parse Uniform Resource Identifiers.

Return values
stringName 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.

Parameters
Erebot::Interfaces::EventHandler$handlerThe event handler responsible for calling this method.
Erebot::Event::ServerCapabilities$eventThe "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.

Parameters
Erebot::Interfaces::EventHandler$handlerThe event handler responsible for calling this method.
Erebot::Interfaces::Event::Connect$eventThe "Connect" event to process.

Definition at line 885 of file IrcConnection.php.

Erebot\IrcConnection::loadModules ( \Erebot\Interfaces\Config\Server  $config,
  $flags 
)
protected

(Re)Load the modules for this connection.

Parameters
Erebot::Interfaces::Config::Server$configA server configuration that describes the modules to load.
int$flagsFlags 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::realLoadModule (   $module,
  $chan,
  $flags,
$plainModules,
$channelModules 
)
protected

Load a single module for this connection.

Parameters
string$moduleName of the module to load. If the module is already loaded, nothing will happen.
string | null$chanName 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$flagsBitwise-OR combination of flags to pass to the module's initialization method.
array$plainModulesAn 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$channelModulesAn 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.
Return values
Erebot::Module::BaseAn 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.

Parameters
Erebot::Interfaces::Config::Server$configThe 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.

Parameters
Erebot::Interfaces::Collator$collatorThe new collator to use for this connection.

Definition at line 898 of file IrcConnection.php.

Erebot\IrcConnection::setURIFactory (   $factory)

Sets the class to use as a factory to parse Uniform Resource Identifiers.

Parameters
string$factoryName of the class to use to parse an URI.

Definition at line 165 of file IrcConnection.php.

Member Data Documentation

Erebot\IrcConnection::$config
protected

A configuration object implementing the Erebot::Interfaces::Config::Server interface.

Definition at line 33 of file IrcConnection.php.


The documentation for this class was generated from the following file: