1 | <?php |
||
30 | class MultiCharacterCommand extends BasicCommand |
||
31 | { |
||
32 | /** @} */ |
||
33 | |||
34 | public static $type = 'message'; |
||
35 | |||
36 | public static $object_class = 'PhpBotFramework\Entities\Message'; |
||
37 | |||
38 | public static $priority = 1; |
||
39 | |||
40 | private $command; |
||
41 | |||
42 | private $length; |
||
43 | |||
44 | /** |
||
45 | * \brief Add a function that will be executed everytime a message contain the selected command |
||
46 | * \details Use this syntax to create a command: |
||
47 | * |
||
48 | * $help_cpmmand = new PhpBotFramework\Commands\MultiCharacterCommand("help", |
||
49 | * function ($bot, $message) { |
||
50 | * $bot->sendMessage("This is a help message."); |
||
51 | * } |
||
52 | * ); |
||
53 | * |
||
54 | * Then you can add it to the bot's commands using <code>addCommand</code> method: |
||
55 | * |
||
56 | * $bot->addCommand($help_command); |
||
57 | * |
||
58 | * @param string $command The command that will trigger this function (e.g. start) |
||
59 | * @param callable $script The function that will be triggered by a command. |
||
60 | * Must take an object(the bot) and an array(the message received). |
||
61 | */ |
||
62 | public function __construct(string $command, callable $script, string ...$chars) |
||
86 | |||
87 | /** |
||
88 | * @internal |
||
89 | * \brief Process a message checking if it trigger any MessageCommand. |
||
90 | * @param string $message Message to process. |
||
91 | * @return bool True if the message trigger any command. |
||
92 | */ |
||
93 | public function checkCommand(array $message) : bool |
||
103 | } |
||
104 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: