\Phergie\Irc\Bot\ReactBot

Class for an IRC bot that reads in configuration files, connects to IRC servers, and configures plugins to receive events of interest from those servers.

Summary

Methods
Properties
Constants
setClient()
getClient()
setConfig()
getConfig()
setLogger()
getLogger()
setParser()
getParser()
setConverter()
getConverter()
setEventQueue()
getEventQueue()
run()
processClientEvent()
processOutgoingEvents()
No public properties found
No constants found
setDependencyOverrides()
getConnections()
getPlugins()
processPlugins()
getPluginProcessors()
getDefaultPluginProcessors()
validatePluginEvents()
registerClientSubscribers()
getEventSubtype()
registerPluginSubscribers()
$client
$config
$logger
$parser
$converter
$queue
N/A
No private methods found
No private properties found
N/A

Properties

$config

$config : array

Configuration in use by the bot

Type

array

$logger

$logger : \Psr\Log\LoggerInterface

Logger in use by the bot, defaults to logger in use by the IRC client

Type

\Psr\Log\LoggerInterface

$parser

$parser : \Phergie\Irc\ParserInterface

Parser for converting generated IRC commands into event objects

Type

\Phergie\Irc\ParserInterface

Methods

setConfig()

setConfig(array $config)

Sets the configuration to be used by the bot in its operations.

See config.sample.php for an example configuration file.

Parameters

array $config

Associative array keyed by setting name

getConfig()

getConfig() : array

Returns the configuration in use by the bot.

Returns

array —

Associative array keyed by setting name

setLogger()

setLogger(\Psr\Log\LoggerInterface $logger)

Sets the logger in use by the bot.

Parameters

\Psr\Log\LoggerInterface $logger

getLogger()

getLogger() : \Psr\Log\LoggerInterface

Returns the logger in use by the bot.

Returns

\Psr\Log\LoggerInterface

setParser()

setParser(\Phergie\Irc\ParserInterface $parser)

Sets the parser for generated event data in use by the bot.

Parameters

\Phergie\Irc\ParserInterface $parser

getParser()

getParser() : \Phergie\Irc\ParserInterface

Returns the parser for generated event data in use by the bot.

Returns

\Phergie\Irc\ParserInterface

run()

run()

Initiates an event loop for the bot in which it will connect to servers and monitor those connections for events to forward to plugins.

Throws

\RuntimeException

if configuration is inconsistent with

    expected structure

processClientEvent()

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.

Parameters

string $event

Received client event

array $message

Parsed message

\Phergie\Irc\ConnectionInterface $connection

Connection on which

   the event occurred
\Phergie\Irc\Client\React\WriteStream $write

Stream used to send

   commands to the server

processOutgoingEvents()

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.

Parameters

\Phergie\Irc\ConnectionInterface $connection

Connection on which

   the event occurred
\Phergie\Irc\Client\React\WriteStream $write

Stream used to send

   commands to the server

setDependencyOverrides()

setDependencyOverrides(array $config)

Sets dependencies from configuration.

Parameters

array $config

getConnections()

getConnections(array $config) : \Phergie\Irc\ConnectionInterface[]

Extracts connections from configuration.

Parameters

array $config

Associative array keyed by setting name

Returns

\Phergie\Irc\ConnectionInterface[]

getPlugins()

getPlugins(array $config) : \Phergie\Irc\Bot\React\PluginInterface[]

Extracts plugins from configuration.

Parameters

array $config

Associative array keyed by setting name

Throws

\RuntimeException

if any plugin event callback is invalid

Returns

\Phergie\Irc\Bot\React\PluginInterface[]

processPlugins()

processPlugins(array $plugins, array $processors)

Processes a list of plugins for use.

Parameters

array $plugins
array $processors

getPluginProcessors()

getPluginProcessors(array $config)

Returns a list of processors for plugins.

Parameters

array $config

Associative array keyed by setting name

getDefaultPluginProcessors()

getDefaultPluginProcessors()

Returns a list of default plugin processors used when none are set via configuration.

validatePluginEvents()

validatePluginEvents(\Phergie\Irc\Bot\React\PluginInterface $plugin)

Validates a plugin's event callbacks.

Parameters

\Phergie\Irc\Bot\React\PluginInterface $plugin

Throws

\RuntimeException

if any event callback is invalid

registerClientSubscribers()

registerClientSubscribers(\Phergie\Irc\Client\React\Client $client)

Configures the client to emit events for specific types of messages.

Parameters

\Phergie\Irc\Client\React\Client $client

Client for which to

   configure events

getEventSubtype()

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.

Parameters

\Phergie\Irc\Event\EventInterface $event

Returns

string

registerPluginSubscribers()

registerPluginSubscribers(\Phergie\Irc\Bot\React\PluginInterface[] $plugins)

Registers event callbacks from plugins.

Parameters

\Phergie\Irc\Bot\React\PluginInterface[] $plugins

Plugins from

   which to get callbacks