|
Erebot
latest
A modular IRC bot for PHP 5.3+
|
A simple prompt which can be used to send commands remotely. More...
Inheritance diagram for Erebot\Prompt:Public Member Functions | |
| __construct (\Erebot\Interfaces\Core $bot, $connector=null, $group=null, $perms=0660) | |
| __destruct () | |
| Destructor. | |
| connect () | |
| disconnect ($quitMessage=null) | |
| getBot () | |
| getConfig ($chan) | |
| getIO () | |
| getSocket () | |
| isConnected () | |
| process () | |
| Processes commands queued in the input buffer. | |
| read () | |
Protected Member Functions | |
| handleMessage ($line) | |
Protected Attributes | |
| $bot | |
| A bot object implementing the Erebot::Interfaces::Core interface. | |
| $io | |
| I/O manager for the socket. | |
| $socket | |
| The underlying socket, represented as a stream. | |
A simple prompt which can be used to send commands remotely.
This class can be used by external processes to send commands through the bot. It creates a UNIX socket other programs can send commands to whenever they want the bot to send certain commands to an IRC server.
Such commands must be prefixed by a pattern (which accepts '*' and '?' as wildcards, but not the full grammar of regular expressions) to indicate which server(s) the command must be sent to (hint: '*' can be used to refer to all servers the bot is connected to).
This makes in possible to display the output of some shell script on IRC. For example, the following command would display the output of /some/command.sh to #Erebot on all servers the bot is currently connected to:
Definition at line 45 of file Prompt.php.
| Erebot\Prompt::__construct | ( | \Erebot\Interfaces\Core | $bot, |
$connector = null, |
|||
$group = null, |
|||
$perms = 0660 |
|||
| ) |
Constructs the UNIX socket that represents the prompt.
| Erebot::Interfaces::Core | $bot | Instance of the bot to operate on. |
| string | $connector | (optional) Path where the newly-created UNIX socket will be made accessible. The default is to create a UNIX socket named "Erebot.sock" in the system's temporary directory (usually "/tmp/"). |
| mixed | $group | (optional) Either the name or the identifier of the UNIX group the socket will belong to. The default is to not change the group of the socket (i.e. to keep whatever is the main group for the user running Erebot). |
| int | $perms | (optional) UNIX permissions the newly-created socket will receive. The default is to give read/write access to the user running Erebot and to the group the socket belongs to (see $group). |
mode). Definition at line 99 of file Prompt.php.
| Erebot\Prompt::connect | ( | ) |
Makes the actual connection to an IRC server, using the configuration data passed to the constructor.
| Erebot::ConnectionFailureException | Thrown whenever the bot fails to establish a connection to the given server. |
Implements Erebot\Interfaces\Connection.
Definition at line 171 of file Prompt.php.
| Erebot\Prompt::disconnect | ( | $quitMessage = null | ) |
Disconnects the bot from that particular IRC server.
| string | $quitMessage | (optional) A message which will be visible by other users when the bot gets disconnected. If no message is given, the IrcConnector module is probed for its "quit_message" parameter. If no message is available, the bot quits with an empty string as its quit message. |
Implements Erebot\Interfaces\Connection.
Definition at line 176 of file Prompt.php.
| Erebot\Prompt::getBot | ( | ) |
Returns the bot instance this connection is associated with.
| Erebot::Interfaces::Core | An instance of the core class (Erebot). |
Implements Erebot\Interfaces\Connection.
Definition at line 251 of file Prompt.php.
| Erebot\Prompt::getConfig | ( | $chan | ) |
Retrieves the configuration for a given channel.
| null | string | $chan | The name of the IRC channel for which a configuration must be retrieved. If $chan is null, the configuration associated with this object is returned instead (an instance of the Erebot::Interfaces::Config::Server). |
| Erebot::Interfaces::Config::Channel | The configuration for the given channel, if there is one. |
| Erebot::Interfaces::Config::Server | Otherwise, the configuration for the associated IRC server. |
| Erebot::NotFoundException | No Erebot::Interfaces::Config::Channel object exists for the given channel. |
Implements Erebot\Interfaces\Connection.
Definition at line 256 of file Prompt.php.
| Erebot\Prompt::getIO | ( | ) |
Returns the object used to handle I/O (input/output) with this connection.
Implements Erebot\Interfaces\Connection.
Definition at line 195 of file Prompt.php.
| Erebot\Prompt::getSocket | ( | ) |
Returns the underlying transport implementation for this connection.
| stream | Returns this connection's socket, as a PHP stream. |
Implements Erebot\Interfaces\Connection.
Definition at line 190 of file Prompt.php.
|
protected |
Handles a line received from the prompt.
| string | $line | A single line of text received from the prompt, with the end-of-line sequence stripped. |
Definition at line 224 of file Prompt.php.
| Erebot\Prompt::isConnected | ( | ) |
Returns whether this connection object is currently connected to a server.
| bool | true if the connection is really connected, false otherwise. |
Implements Erebot\Interfaces\Connection.
Definition at line 185 of file Prompt.php.
| Erebot\Prompt::read | ( | ) |
Processes data from the incoming buffer.
Once this method has been called, all lines awaiting processing in the incoming buffer have been transferred to the incoming FIFO. You must call Erebot::Connection::processQueuedData() after that in order to process the lines in the FIFO. This is done so that a throttling policy may be put in place if needed (eg. for an anti-flood system).
Implements Erebot\Interfaces\ReceivingConnection.
Definition at line 200 of file Prompt.php.