1 | <?php |
||
28 | class MessageCommand extends BasicCommand |
||
29 | { |
||
30 | /** @} */ |
||
31 | |||
32 | public static $type = 'message'; |
||
33 | |||
34 | public static $object_class = 'PhpBotFramework\Entities\Message'; |
||
35 | |||
36 | public static $priority = 1; |
||
37 | |||
38 | private $command; |
||
39 | |||
40 | private $length; |
||
41 | |||
42 | /** |
||
43 | * \brief Add a function that will be executed everytime a message contain the selected command |
||
44 | * \details Use this syntax: |
||
45 | * |
||
46 | * addMessageCommand("start", function($bot, $message) { |
||
47 | * $bot->sendMessage("Hi"); }); |
||
48 | * @param string $command The command that will trigger this function (without slash). Eg: "start", "help", "about" |
||
49 | * @param callable $script The function that will be triggered by a command. |
||
50 | * Must take an object(the bot) and an array(the message received). |
||
51 | */ |
||
52 | 1 | public function __construct(string $command, callable $script) |
|
58 | |||
59 | /** |
||
60 | * @internal |
||
61 | * \brief Process a message checking if it trigger any MessageCommand. |
||
62 | * @param string $message Message to process. |
||
63 | * @return bool True if the message trigger any command. |
||
64 | */ |
||
65 | 1 | public function checkCommand(array $message) : bool |
|
78 | } |
||
79 |