PHP Class Phergie\Irc\Bot\React\Bot

Show file Open project: phergie/phergie-irc-bot-react Class Usage Examples

Protected Properties

Property Type Description
$client Phergie\Irc\Client\React\ClientInterface IRC client in use by the bot
$config array Configuration in use by the bot
$converter Phergie\Irc\Event\ParserConverterInterface Converter for event data from the IRC client's underlying parser
$logger Psr\Log\LoggerInterface Logger in use by the bot, defaults to logger in use by the IRC client
$parser Phergie\Irc\ParserInterface Parser for converting generated IRC commands into event objects
$queueFactory Phergie\Irc\Bot\React\EventQueueFactoryInterface Event queue factory for creating connection-specific event queues

Public Methods

Method Description
getClient ( ) : Phergie\Irc\Client\React\ClientInterface Returns the IRC client in use by the bot.
getConfig ( ) : array Returns the configuration in use by the bot.
getConverter ( ) : Phergie\Irc\Event\ParserConverterInterface Returns the parser converter for event data in use by the bot.
getEventQueueFactory ( ) : Phergie\Irc\Bot\React\EventQueueFactoryInterface Returns the event queue factory in use by the bot.
getLogger ( ) : Psr\Log\LoggerInterface Returns the logger in use by the bot.
getParser ( ) : Phergie\Irc\ParserInterface Returns the parser for generated event data in use by the bot.
processClientEvent ( string $event, array $message, Phergie\Irc\ConnectionInterface $connection, Phergie\Irc\Client\React\WriteStream $write ) Callback to process client events. Not intended to be called from outside this class.
processOutgoingEvents ( Phergie\Irc\ConnectionInterface $connection, Phergie\Irc\Client\React\WriteStream $write ) Callback to process any queued outgoing events. Not intended to be called from outside thie class.
run ( boolean $autorun = true ) Initiates an event loop for the bot in which it will connect to servers and monitor those connections for events to forward to plugins.
setClient ( Phergie\Irc\Client\React\ClientInterface $client ) Sets the IRC client for the bot to use.
setConfig ( array $config ) Sets the configuration to be used by the bot in its operations.
setConverter ( Phergie\Irc\Event\ParserConverterInterface $converter ) Sets the parser converter for event data in use by the bot.
setEventQueueFactory ( Phergie\Irc\Bot\React\EventQueueFactoryInterface $queueFactory ) Sets the event queue factory for the bot to use.
setLogger ( Psr\Log\LoggerInterface $logger ) Sets the logger in use by the bot.
setParser ( Phergie\Irc\ParserInterface $parser ) Sets the parser for generated event data in use by the bot.

Protected Methods

Method Description
getConnections ( array $config ) : Phergie\Irc\ConnectionInterface[] Extracts connections from configuration.
getDefaultPluginProcessors ( ) : Phergie\Irc\Bot\React\PluginProcessor\PluginProcessorInterface[] Returns a list of default plugin processors used when none are set via configuration.
getEventSubtype ( Phergie\Irc\Event\EventInterface $event ) : string Returns an event subtype corresponding to a given event object, used to generate event names when emitting events.
getPluginProcessors ( array $config ) Returns a list of processors for plugins.
getPlugins ( array $config ) : Phergie\Irc\Bot\React\PluginInterface[] Extracts plugins from configuration.
processPlugins ( array $plugins, array $processors, SplObjectStorage $processedPlugins = null ) Processes a list of plugins for use.
registerClientSubscribers ( Phergie\Irc\Client\React\ClientInterface $client ) Configures the client to emit events for specific types of messages.
registerPluginSubscribers ( array $plugins ) Registers event callbacks from plugins.
setDependencyOverrides ( array $config ) Sets dependencies from configuration.
validatePluginEvents ( Phergie\Irc\Bot\React\PluginInterface $plugin ) Validates a plugin's event callbacks.

Method Details

getClient() public method

Returns the IRC client in use by the bot.
public getClient ( ) : Phergie\Irc\Client\React\ClientInterface
return Phergie\Irc\Client\React\ClientInterface

getConfig() public method

Returns the configuration in use by the bot.
public getConfig ( ) : array
return array Associative array keyed by setting name

getConnections() protected method

Extracts connections from configuration.
protected getConnections ( array $config ) : Phergie\Irc\ConnectionInterface[]
$config array Associative array keyed by setting name
return Phergie\Irc\ConnectionInterface[]

getConverter() public method

Returns the parser converter for event data in use by the bot.
public getConverter ( ) : Phergie\Irc\Event\ParserConverterInterface
return Phergie\Irc\Event\ParserConverterInterface

getDefaultPluginProcessors() protected method

Returns a list of default plugin processors used when none are set via configuration.
protected getDefaultPluginProcessors ( ) : Phergie\Irc\Bot\React\PluginProcessor\PluginProcessorInterface[]
return Phergie\Irc\Bot\React\PluginProcessor\PluginProcessorInterface[]

getEventQueueFactory() public method

Returns the event queue factory in use by the bot.
public getEventQueueFactory ( ) : Phergie\Irc\Bot\React\EventQueueFactoryInterface
return Phergie\Irc\Bot\React\EventQueueFactoryInterface

getEventSubtype() protected method

Returns an event subtype corresponding to a given event object, used to generate event names when emitting events.
protected getEventSubtype ( Phergie\Irc\Event\EventInterface $event ) : string
$event Phergie\Irc\Event\EventInterface
return string

getLogger() public method

Returns the logger in use by the bot.
public getLogger ( ) : Psr\Log\LoggerInterface
return Psr\Log\LoggerInterface

getParser() public method

Returns the parser for generated event data in use by the bot.
public getParser ( ) : Phergie\Irc\ParserInterface
return Phergie\Irc\ParserInterface

getPluginProcessors() protected method

Returns a list of processors for plugins.
protected getPluginProcessors ( array $config )
$config array Associative array keyed by setting name

getPlugins() protected method

Extracts plugins from configuration.
protected getPlugins ( array $config ) : Phergie\Irc\Bot\React\PluginInterface[]
$config array Associative array keyed by setting name
return Phergie\Irc\Bot\React\PluginInterface[]

processClientEvent() public method

Callback to process client events. Not intended to be called from outside this class.
public processClientEvent ( string $event, array $message, Phergie\Irc\ConnectionInterface $connection, Phergie\Irc\Client\React\WriteStream $write )
$event string Received client event
$message array Parsed message
$connection Phergie\Irc\ConnectionInterface Connection on which the event occurred
$write Phergie\Irc\Client\React\WriteStream Stream used to send commands to the server

processOutgoingEvents() public method

Callback to process any queued outgoing events. Not intended to be called from outside thie class.
public processOutgoingEvents ( Phergie\Irc\ConnectionInterface $connection, Phergie\Irc\Client\React\WriteStream $write )
$connection Phergie\Irc\ConnectionInterface Connection on which the event occurred
$write Phergie\Irc\Client\React\WriteStream Stream used to send commands to the server

processPlugins() protected method

Processes a list of plugins for use.
protected processPlugins ( array $plugins, array $processors, SplObjectStorage $processedPlugins = null )
$plugins array
$processors array
$processedPlugins SplObjectStorage

registerClientSubscribers() protected method

Configures the client to emit events for specific types of messages.
protected registerClientSubscribers ( Phergie\Irc\Client\React\ClientInterface $client )
$client Phergie\Irc\Client\React\ClientInterface Client for which to configure events

registerPluginSubscribers() protected method

Registers event callbacks from plugins.
protected registerPluginSubscribers ( array $plugins )
$plugins array Plugins from which to get callbacks

run() public method

Initiates an event loop for the bot in which it will connect to servers and monitor those connections for events to forward to plugins.
public run ( boolean $autorun = true )
$autorun boolean

setClient() public method

Sets the IRC client for the bot to use.
public setClient ( Phergie\Irc\Client\React\ClientInterface $client )
$client Phergie\Irc\Client\React\ClientInterface

setConfig() public method

See config.sample.php for an example configuration file.
public setConfig ( array $config )
$config array Associative array keyed by setting name

setConverter() public method

Sets the parser converter for event data in use by the bot.
public setConverter ( Phergie\Irc\Event\ParserConverterInterface $converter )
$converter Phergie\Irc\Event\ParserConverterInterface

setDependencyOverrides() protected method

Sets dependencies from configuration.
protected setDependencyOverrides ( array $config )
$config array

setEventQueueFactory() public method

Sets the event queue factory for the bot to use.
public setEventQueueFactory ( Phergie\Irc\Bot\React\EventQueueFactoryInterface $queueFactory )
$queueFactory Phergie\Irc\Bot\React\EventQueueFactoryInterface

setLogger() public method

Sets the logger in use by the bot.
public setLogger ( Psr\Log\LoggerInterface $logger )
$logger Psr\Log\LoggerInterface

setParser() public method

Sets the parser for generated event data in use by the bot.
public setParser ( Phergie\Irc\ParserInterface $parser )
$parser Phergie\Irc\ParserInterface

validatePluginEvents() protected method

Validates a plugin's event callbacks.
protected validatePluginEvents ( Phergie\Irc\Bot\React\PluginInterface $plugin )
$plugin Phergie\Irc\Bot\React\PluginInterface

Property Details

$client protected property

IRC client in use by the bot
protected ClientInterface,Phergie\Irc\Client\React $client
return Phergie\Irc\Client\React\ClientInterface

$config protected property

Configuration in use by the bot
protected array $config
return array

$converter protected property

Converter for event data from the IRC client's underlying parser
protected ParserConverterInterface,Phergie\Irc\Event $converter
return Phergie\Irc\Event\ParserConverterInterface

$logger protected property

Logger in use by the bot, defaults to logger in use by the IRC client
protected LoggerInterface,Psr\Log $logger
return Psr\Log\LoggerInterface

$parser protected property

Parser for converting generated IRC commands into event objects
protected ParserInterface,Phergie\Irc $parser
return Phergie\Irc\ParserInterface

$queueFactory protected property

Event queue factory for creating connection-specific event queues
protected EventQueueFactoryInterface,Phergie\Irc\Bot\React $queueFactory
return Phergie\Irc\Bot\React\EventQueueFactoryInterface