1 | <?php |
||
30 | class MessageRegexCommand extends BasicCommand |
||
31 | { |
||
32 | /** @} */ |
||
33 | |||
34 | private $regex_rule; |
||
35 | |||
36 | /** |
||
37 | * \brief Add a function that will be executed everytime a message contain a command |
||
38 | * that match the regular expression. |
||
39 | * |
||
40 | * \details Use this syntax: |
||
41 | * |
||
42 | * addMessageCommandRegex("number\d", function($bot, $message, $result) { |
||
43 | * $bot->sendMessage("You sent me a number"); }); |
||
44 | * @param string $regex_rule Regex rule that will called for evalueting the command received. |
||
45 | * @param callable $script The function that will be triggered by a command. |
||
46 | * Must take an object(the bot) and an array(the message received). |
||
47 | */ |
||
48 | public function __construct(string $regex_rule, callable $script) |
||
53 | |||
54 | /** |
||
55 | * @internal |
||
56 | * \brief Process the message to check if it triggers a command of this type. |
||
57 | * @param array $message Message to process. |
||
58 | * @return bool True if the message triggered a command. |
||
59 | */ |
||
60 | public function checkCommand(array $message) : bool |
||
72 | } |
||
73 |