Erebot  latest
A modular IRC bot for PHP 5.3+
Erebot\Interfaces\Core Interface Reference

Interface for core features. More...

+ Inheritance diagram for Erebot\Interfaces\Core:

Public Member Functions

 addConnection (\Erebot\Interfaces\Connection $connection)
 
 addTimer (\Erebot\TimerInterface $timer)
 
 getConnections ()
 
 getRunningTime ()
 
 gettext ($message)
 
 getTimers ()
 
 removeConnection (\Erebot\Interfaces\Connection $connection)
 
 removeTimer (\Erebot\TimerInterface $timer)
 
 start (\Erebot\Interfaces\ConnectionFactory $factory)
 
 stop ()
 

Detailed Description

Interface for core features.

This interface provides the necessary methods to get a basic instance of the bot running.

Definition at line 30 of file Core.php.

Member Function Documentation

Erebot\Interfaces\Core::addConnection ( \Erebot\Interfaces\Connection  $connection)

Adds a (new) connection to the bot.

Once a new connection has been created, use this method to add it to the pool of connections the bot must process. This enables the connection to send and receive messages.

Parameters
Erebot::Interfaces::Connection$connectionAdds a connection to the list of connections handled by this instance of the bot.
Exceptions
Erebot::InvalidValueExceptionThis connection is already part of the connection pool handled by this instance of the bot.
Erebot\Interfaces\Core::addTimer ( \Erebot\TimerInterface  $timer)

Registers a timer for this instance.

Parameters
Erebot::TimerInterface$timerA timer to register.

Implemented in Erebot\Core.

Erebot\Interfaces\Core::getConnections ( )

Returns a list of all connections handled by the bot.

Return values
arrayA list of connections handled by this instance, as objects implementing Erebot::Interfaces::Connection.
Note
There is not much use for this method actually. The only case where you might need it is when you're willing to broadcast a message/command to all connections (such as to signal the bot shutting down).

Implemented in Erebot\Core.

Erebot\Interfaces\Core::getRunningTime ( )

Returns the number of seconds elapsed since the bot was last started.

Return values
falseThe bot is not running (Erebot::Interfaces::Core::start() has not been called yet).
integerThe number of seconds elapsed since the was last started.

Implemented in Erebot\Core.

Erebot\Interfaces\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.

Parameters
string$messageThe original message to translate, in english.
Return values
stringThe translation for this message or the original (english) message if no translation is available.

Implemented in Erebot\Core.

Erebot\Interfaces\Core::getTimers ( )

Returns a list of all timers currently registered.

Return values
arrayA list of timers registered for this instance, as objects implementing Erebot::TimerInterface.

Implemented in Erebot\Core.

Erebot\Interfaces\Core::removeConnection ( \Erebot\Interfaces\Connection  $connection)

Removes a connection from the bot.

Use this method to remove a connection from the pool of connections the bot must process, such as when the connection is lost with the remote IRC server.

Parameters
Erebot::Interfaces::Connection$connectionRemoves a connection from the list of connections handled by this instance of the bot.
Exceptions
Erebot::NotFoundExceptionThe given connection is not part of the connection pool handled by this instance of the bot.
Erebot\Interfaces\Core::removeTimer ( \Erebot\TimerInterface  $timer)

Unregisters a timer.

Parameters
Erebot::TimerInterface$timerA timer to unregister.

Implemented in Erebot\Core.

Erebot\Interfaces\Core::start ( \Erebot\Interfaces\ConnectionFactory  $factory)

Starts the bot.

Parameters
Erebot::Interfaces::ConnectionFactory$factoryFactory to use to create new connections.
Attention
This method does not return until the bot drops its connections. Therefore, this MUST be the last method you call in your script.
Erebot\Interfaces\Core::stop ( )

Stops the bot.

Implemented in Erebot\Core.


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