Erebot  latest
A modular IRC bot for PHP 7.0+
Erebot\Prompt Class Reference

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 ()
 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

 A bot object implementing the Erebot::Interfaces::Core interface.
 I/O manager for the socket.
 The underlying socket, represented as a stream.

Detailed Description

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/ to #Erebot on all servers the bot is currently connected to:

/some/ | sed 's/^/* PRIVMSG #Erebot :/' | \
* socat - UNIX-SENDTO:/path/to/the/prompt.sock

Definition at line 45 of file Prompt.php.

Constructor & Destructor Documentation

Erebot\Prompt::__construct ( \Erebot\Interfaces\Core  $bot,
  $connector = null,
  $group = null,
  $perms = 0660 

Constructs the UNIX socket that represents the prompt.

Erebot::Interfaces::Core$botInstance 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).
On most systems, only the superuser may change the group of a file arbitrarily, while other users may only change it to a group they are a member of.
Using the wrong combination of $group and $perms may lead to security issues. Use with caution. The default values are safe as long as you trust users belonging to the same group as the main group of the user running Erebot.
See Also provides more information on the meaning of $perms' value (see the description for mode).

Definition at line 99 of file Prompt.php.

Member Function Documentation

Erebot\Prompt::handleMessage (   $line)

Handles a line received from the prompt.

string$lineA single line of text received from the prompt, with the end-of-line sequence stripped.

Definition at line 224 of file Prompt.php.

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