|
Erebot
latest
A modular IRC bot for PHP 5.3+
|
Abstract filter that matches events based on their content (text). More...
Inheritance diagram for Erebot\Event\Match\TextAbstract:Public Member Functions | |
| __construct ($pattern, $requirePrefix=false) | |
| getPattern () | |
| getPrefixRequirement () | |
| match (\Erebot\Interfaces\Event\Base\Generic $event) | |
| setPattern ($pattern) | |
| setPrefixRequirement ($requirePrefix=false) | |
Protected Member Functions | |
| realMatch ($prefix, $text) | |
Protected Attributes | |
| $pattern | |
| Pattern used in comparisons, as a string. | |
| $requirePrefix | |
| Boolean or null indicating whether a prefix is required or not. | |
Abstract filter that matches events based on their content (text).
Subclasses must provide the logic for the matching algorithm by overriding the _match() method.
Definition at line 30 of file TextAbstract.php.
| Erebot\Event\Match\TextAbstract::__construct | ( | $pattern, | |
$requirePrefix = false |
|||
| ) |
Creates a new instance of this filter.
| string | $pattern | Pattern to use in text comparisons. |
| bool | null | $requirePrefix | (optional) Whether a prefix will be required (true), allowed (null) or disallowed (false). The default is to prohibit the use of a prefix. |
| Erebot::InvalidValueException | The given value for $pattern or $requirePrefix is invalid. |
Definition at line 52 of file TextAbstract.php.
References Erebot\Event\Match\TextAbstract\$pattern, Erebot\Event\Match\TextAbstract\$requirePrefix, Erebot\Event\Match\TextAbstract\setPattern(), and Erebot\Event\Match\TextAbstract\setPrefixRequirement().
| Erebot\Event\Match\TextAbstract::getPattern | ( | ) |
Returns the pattern associated with this filter.
| string | Pattern associated with this filter. |
Definition at line 64 of file TextAbstract.php.
References Erebot\Event\Match\TextAbstract\$pattern.
| Erebot\Event\Match\TextAbstract::getPrefixRequirement | ( | ) |
Returns the prefix requirement constraint for this filter.
| bool|null | Either true if a prefix is required, null if a prefix is allowed, false if a prefix is disallowed. |
Definition at line 95 of file TextAbstract.php.
References Erebot\Event\Match\TextAbstract\$requirePrefix.
| Erebot\Event\Match\TextAbstract::match | ( | \Erebot\Interfaces\Event\Base\Generic | $event | ) |
Decides whether the given event passes the filter or not.
| $event | An event to try to match to the criterion expressed by this filter. |
| bool | true if the event matches the criterion, false otherwise. |
Implements Erebot\Interfaces\Event\Match.
Definition at line 122 of file TextAbstract.php.
References Erebot\Event\Match\TextAbstract\realMatch().
|
abstractprotected |
Actual method used to make the comparison against the incoming event. This method is passed the contents of the event and may use the values of the $_pattern and $_requirePrefix instance attributes to make the comparison.
| string | $prefix | Current prefix for commands, as defined in the configuration file. |
| string | $text | Content of the incoming event. |
| bool | true if the event's content passes the filter, false otherwise. |
Referenced by Erebot\Event\Match\TextAbstract\match().
| Erebot\Event\Match\TextAbstract::setPattern | ( | $pattern | ) |
Sets the pattern associated with this filter.
| string | $pattern | Pattern to use in text comparisons. |
| Erebot::InvalidValueException | The given value for $pattern is invalid. |
Definition at line 78 of file TextAbstract.php.
References Erebot\Event\Match\TextAbstract\$pattern, and Erebot\Utils\stringifiable().
Referenced by Erebot\Event\Match\TextAbstract\__construct().
| Erebot\Event\Match\TextAbstract::setPrefixRequirement | ( | $requirePrefix = false | ) |
Sets the constraint on prefix requirement.
| bool | null | $requirePrefix | (optional) Whether a prefix will be required (true), allowed (null) or disallowed (false). The default is to prohibit the use of a prefix. |
| Erebot::InvalidValueException | The given value for $requirePrefix is invalid. |
Definition at line 111 of file TextAbstract.php.
References Erebot\Event\Match\TextAbstract\$requirePrefix.
Referenced by Erebot\Event\Match\TextAbstract\__construct().