|
Erebot
latest
A modular IRC bot for PHP 5.3+
|
Provides core functionalities for Erebot. More...
Inheritance diagram for Erebot\Core:Public Member Functions | |
| __clone () | |
| __construct (\Erebot\Interfaces\Config\Main $config,\Erebot\IntlInterface $translator) | |
| __destruct () | |
| addConnection (\Erebot\Interfaces\Connection $connection) | |
| addTimer (\Erebot\TimerInterface $timer) | |
| getConnections () | |
| getRunningTime () | |
| gettext ($message) | |
| getTimers () | |
| handleSIGHUP ($signum) | |
| handleSignal ($signum) | |
| reload (\Erebot\Interfaces\Config\Main $config=null) | |
| removeConnection (\Erebot\Interfaces\Connection $connection) | |
| removeTimer (\Erebot\TimerInterface $timer) | |
| start (\Erebot\Interfaces\ConnectionFactory $factory) | |
| stop () | |
Public Member Functions inherited from Erebot\Interfaces\Core | |
| addConnection (\Erebot\Interfaces\Connection $connection) | |
| removeConnection (\Erebot\Interfaces\Connection $connection) | |
| start (\Erebot\Interfaces\ConnectionFactory $factory) | |
Protected Member Functions | |
| createConnections (\Erebot\Interfaces\ConnectionFactory $factory,\Erebot\Interfaces\Config\Main $config) | |
| realStart (\Erebot\Interfaces\ConnectionFactory $factory) | |
Protected Attributes | |
| $connections | |
| Connections to handle. | |
| $mainCfg | |
| Main configuration for the bot. | |
| $running | |
| Indicates whether the bot is currently running or not. | |
| $timers | |
| Timers to trigger. | |
| $translator | |
| Translator object for messages the bot may display. | |
Provides core functionalities for Erebot.
This class is responsible for controlling the bot, from its start to its shutdown. This is the class that will create new connections, handle timers, apply multiplexing, etc.
The main method you will be interested in is Erebot::start() which starts the bot.
| Erebot\Core::__construct | ( | \Erebot\Interfaces\Config\Main | $config, |
| \Erebot\IntlInterface | $translator | ||
| ) |
Creates a new Erebot instance.
| Erebot::Interfaces::Config::MainInterface | $config | The (main) configuration to use. |
| Erebot::IntlInterface | $translator | A translator object that will provide translations for messages emitted by the core class. |
| Erebot\Core::addTimer | ( | \Erebot\TimerInterface | $timer | ) |
Registers a timer for this instance.
| Erebot::TimerInterface | $timer | A timer to register. |
Implements Erebot\Interfaces\Core.
|
protected |
Creates the connections for this instance.
| Erebot::Interfaces::ConnectionFactory | $factory | The factory to use to create the connections. |
| Erebot::Interfaces::Config::Main | $config | The main configuration for the bot. |
| Erebot\Core::getConnections | ( | ) |
Returns a list of all connections handled by the bot.
| array | A list of connections handled by this instance, as objects implementing Erebot::Interfaces::Connection. |
Implements Erebot\Interfaces\Core.
| Erebot\Core::getRunningTime | ( | ) |
Returns the number of seconds elapsed since the bot was last started.
| false | The bot is not running (Erebot::Interfaces::Core::start() has not been called yet). |
| integer | The number of seconds elapsed since the was last started. |
Implements Erebot\Interfaces\Core.
| Erebot\Core::gettext | ( | $message | ) |
Returns the translation of a message in the primary language.
Use this method to get a translated message in the primary language. That is, using the language defined in the "language" attribute of the "configuration" tag in your XML configuration file.
| string | $message | The original message to translate, in english. |
| string | The translation for this message or the original (english) message if no translation is available. |
Implements Erebot\Interfaces\Core.
| Erebot\Core::getTimers | ( | ) |
Returns a list of all timers currently registered.
| array | A list of timers registered for this instance, as objects implementing Erebot::TimerInterface. |
Implements Erebot\Interfaces\Core.
| Erebot\Core::handleSIGHUP | ( | $signum | ) |
| Erebot\Core::handleSignal | ( | $signum | ) |
Handles request for a graceful shutdown of the bot. Such requests are received as signals.
| int | $signum | The number of the signal. |
Definition at line 361 of file Core.php.
References Erebot\Utils\parseHumanSize().
|
protected |
Really starts the bot.
| Erebot::Interfaces::ConnectionFactory | $factory | Factory to use to create new connections. |
| Erebot\Core::reload | ( | \Erebot\Interfaces\Config\Main | $config = null | ) |
Reload this instance of the bot.
This method makes the bot reload most of the data it currently relies on, such as configuration files.
| Erebot::Interfaces::Config::MainInterface | $config | (optional) The new configuration to use. If omitted, the configuration file currently in use is reloaded. |
| Erebot\Core::removeTimer | ( | \Erebot\TimerInterface | $timer | ) |
Unregisters a timer.
| Erebot::TimerInterface | $timer | A timer to unregister. |
Implements Erebot\Interfaces\Core.
| Erebot\Core::stop | ( | ) |