A class that can parse IRC messages and produce events to match the commands in those messages.
More...
|
|
const | STRIP_ALL = 0xFF |
| | Strip all forms of styles from the text.
|
| |
|
const | STRIP_BOLD = 0x02 |
| | Strip the bold attribute from the text.
|
| |
|
const | STRIP_COLORS = 0x01 |
| | Strip (mIRC/pIRCh) colors from the text.
|
| |
|
const | STRIP_NONE = 0x00 |
| | Do not strip anything from the text.
|
| |
|
const | STRIP_RESET = 0x10 |
| | Strip the reset control character from the text.
|
| |
|
const | STRIP_REVERSE = 0x08 |
| | Strip the reverse attribute from the text.
|
| |
|
const | STRIP_UNDERLINE = 0x04 |
| | Strip the underline attribute from the text.
|
| |
|
| | handle255 ($origin, $msg) |
| |
| | handle600 ($origin, $msg) |
| |
| | handle601 ($origin, $msg) |
| |
| | handle604 ($origin, $msg) |
| |
| | handle605 ($origin, $msg) |
| |
| | handleINVITE ($origin, $msg) |
| |
| | handleJOIN ($origin, $msg) |
| |
| | handleKICK ($origin, $msg) |
| |
| | handleMODE ($origin, $msg) |
| |
| | handleNICK ($origin, $msg) |
| |
| | handleNOTICE ($origin, $msg) |
| |
| | handlePART ($origin, $msg) |
| |
| | handlePING ($origin, $msg) |
| |
| | handlePONG ($origin, $msg) |
| |
| | handlePRIVMSG ($origin, $msg) |
| |
| | handleQUIT ($origin, $msg) |
| |
| | handleTOPIC ($origin, $msg) |
| |
| | noticeOrPrivmsg ($origin, $msg, $mapping) |
| |
| | watchList ($event, $msg) |
| |
|
|
| $connection |
| | IRC connection that will send us some messages to parse.
|
| |
|
| $eventsMapping |
| | Mappings from (lowercase) interface names to actual classes.
|
| |
A class that can parse IRC messages and produce events to match the commands in those messages.
Definition at line 29 of file IrcParser.php.
Constructor.
- Parameters
-
| Erebot::Interfaces::Connection | $connection | The connection associated with this parser. Every event created by this parser will reference this connection. |
- Warning
- Do not ask this parser to parse messages coming from a different connection that the one it was constructed with or the results will be unpredictable.
Definition at line 68 of file IrcParser.php.
| static Erebot\IrcParser::ctcpUnquote |
( |
|
$msg | ) |
|
|
staticprotected |
| Erebot\IrcParser::getEventClass |
( |
|
$iface | ) |
|
Returns the name of the class used to create events for a certain interface.
- Parameters
-
| string | $iface | The name of the interface describing the type of event. |
- Return values
-
| string | Name of the class to use to create events for the given interface. |
| null | Returned when no class has been registered yet to create events for the given interface. |
- Note
- The name of the interface is case-insensitive.
-
As a special shortcut, you may use an exclamation point ("!") in the interface name, which will be replaced by the text "\\Erebot\\Interfaces\\Event\\". Hence, to retrieve the class used to create events with the "Erebot::Interfaces::Event::Op" interface, it is enough to simply pass "!Op" as the value for $iface.
Implements Erebot\Interfaces\IrcParser.
Definition at line 196 of file IrcParser.php.
| Erebot\IrcParser::getEventClasses |
( |
| ) |
|
Returns the mapping of interface names to their factory.
- Return values
-
| array | Mapping of event interfaces names to their factory. |
- Note
- The interfaces' name will be returned in lowercase, while the classes' name is returned using the same spelling as when it was set.
Implements Erebot\Interfaces\IrcParser.
Definition at line 215 of file IrcParser.php.
| Erebot\IrcParser::handle255 |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a message with numeric 255.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
- Todo:
- Use a NumericEventHandler instead, even though it is less effective.
Definition at line 726 of file IrcParser.php.
| Erebot\IrcParser::handle600 |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a message with numeric 600.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
- Todo:
- Use a NumericEventHandler instead, even though it is less effective.
Definition at line 752 of file IrcParser.php.
| Erebot\IrcParser::handle601 |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a message with numeric 601.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
- Todo:
- Use a NumericEventHandler instead, even though it is less effective.
Definition at line 772 of file IrcParser.php.
| Erebot\IrcParser::handle604 |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a message with numeric 604.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
- Todo:
- Use a NumericEventHandler instead, even though it is less effective.
Definition at line 792 of file IrcParser.php.
| Erebot\IrcParser::handle605 |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a message with numeric 605.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
- Todo:
- Use a NumericEventHandler instead, even though it is less effective.
Definition at line 812 of file IrcParser.php.
| Erebot\IrcParser::handleINVITE |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a message of type INVITE.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
Definition at line 415 of file IrcParser.php.
| Erebot\IrcParser::handleJOIN |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a message of type JOIN.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
Definition at line 434 of file IrcParser.php.
| Erebot\IrcParser::handleKICK |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a message of type KICK.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
Definition at line 453 of file IrcParser.php.
| Erebot\IrcParser::handleMODE |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a (user or channel-related) message of type MODE.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
Definition at line 473 of file IrcParser.php.
| Erebot\IrcParser::handleNICK |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a message of type NICK.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
Definition at line 558 of file IrcParser.php.
| Erebot\IrcParser::handleNOTICE |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a (user or channel-related) message of type NOTICE.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
Definition at line 578 of file IrcParser.php.
| Erebot\IrcParser::handlePART |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a message of type PART.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
Definition at line 600 of file IrcParser.php.
| Erebot\IrcParser::handlePING |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a message of type PING.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
Definition at line 624 of file IrcParser.php.
| Erebot\IrcParser::handlePONG |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a message of type PONG.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
Definition at line 643 of file IrcParser.php.
| Erebot\IrcParser::handlePRIVMSG |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a (user or channel-related) message of type PRIVMSG.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
Definition at line 663 of file IrcParser.php.
| Erebot\IrcParser::handleQUIT |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a message of type QUIT.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
Definition at line 685 of file IrcParser.php.
| Erebot\IrcParser::handleTOPIC |
( |
|
$origin, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a message of type TOPIC.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
Definition at line 704 of file IrcParser.php.
| Erebot\IrcParser::makeEvent |
( |
|
$iface | ) |
|
Factory to create an event matching the given interface, passing any additional parameters given to this method to the constructor for that event.
- Parameters
-
| string | $iface | Name of the interface describing the type of event to create. |
- Return values
-
- Note
- You may pass additional parameters to this method. They will be passed as is to the event's constructor.
-
This method can also use the same shortcuts as Erebot::IrcParser::getEventClass().
-
The name of the interface to use is case-insensitive.
Implements Erebot\Interfaces\IrcParser.
Definition at line 127 of file IrcParser.php.
| Erebot\IrcParser::noticeOrPrivmsg |
( |
|
$origin, |
|
|
|
$msg, |
|
|
|
$mapping |
|
) |
| |
|
protected |
Process a NOTICE or PRIVMSG message.
- Parameters
-
| string | $origin | Origin of the message to process. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
| array | $mapping | A mapping of types to a list of event names. Each list should contain two items. The first one if the name of the event to use when the message is targeted at an IRC user. The second one is used for messages targeted at IRC channels. The following (case-sensitive) types must appear in the mapping: 'ctcp' (for CTCP messages), 'action' (for the special ACTION CTCP message) and 'normal' for regular messages. |
Definition at line 347 of file IrcParser.php.
| Erebot\IrcParser::parseLine |
( |
|
$msg | ) |
|
Parses a single message from an IRC server.
- Parameters
-
| string | $msg | A single IRC message to parse, with the trailing "\r\n" sequence already removed. |
- Note
- Events are dispatched as necessary by this method.
- Warning
- Do not ask this parser to parse messages coming from a different connection that the one it was constructed with or the results will be unpredictable.
Implements Erebot\Interfaces\IrcParser.
Definition at line 276 of file IrcParser.php.
| Erebot\IrcParser::setEventClass |
( |
|
$iface, |
|
|
|
$cls |
|
) |
| |
Sets the class to use when creating events for a certain interface.
- Parameters
-
| string | $iface | Interface to associate the class with. |
| string | $cls | Class to use when creating events for that interface. |
- Exceptions
-
- Note
- The name of the interface is case-insensitive.
-
As a special shortcut, you may use an exclamation point ("!") in the interface name, which will be replaced by the text "\\Erebot\\Interfaces\\Event\\". Hence, to change the class used to create events with the "Erebot::Interfaces::Event::Op" interface, it is enough to simply pass "!Op" as the value for $iface. The $cls is always left unaffected.
Implements Erebot\Interfaces\IrcParser.
Definition at line 247 of file IrcParser.php.
| Erebot\IrcParser::setEventClasses |
( |
|
$events | ) |
|
Sets the mapping from event interfaces names to their factory.
- Parameters
-
| array | $events | Mapping from interfaces names to their factory. |
- Note
- As a special shortcut, you may use an exclamation point ("!") in any interface name, which will be replaced by the text "\\Erebot\\Interfaces\\Event\\".
Implements Erebot\Interfaces\IrcParser.
Definition at line 228 of file IrcParser.php.
| static Erebot\IrcParser::stripCodes |
( |
|
$text, |
|
|
|
$strip = self::STRIP_ALL |
|
) |
| |
|
static |
Strips IRC styles from a text.
- Parameters
-
| string | $text | The text from which styles must be stripped. |
| int | $strip | A bitwise OR of the codes of the styles we want to strip. The default is to strip all forms of styles from the text. See also the Erebot::IrcParser::STRIP_* constants. |
- Return values
-
| string | The text with all the styles specified in $strip stripped. |
Definition at line 88 of file IrcParser.php.
| Erebot\IrcParser::watchList |
( |
|
$event, |
|
|
|
$msg |
|
) |
| |
|
protected |
Processes a message related to the WATCH list.
- Parameters
-
| string | $event | Interface name for the event to produce. |
| Erebot::Interfaces::IrcTextWrapper | $msg | The message to process, wrapped in a special object that makes it easier to analyze each token separately. |
Definition at line 829 of file IrcParser.php.
The documentation for this class was generated from the following file: