|
| __construct (string $command, callable $script) |
| Add a function that will be executed everytime a message contain the selected command. More...
|
|
bool | checkCommand (array $message) |
|
Public Member Functions inherited from PhpBotFramework\Commands\BasicCommand |
callable | getScript () |
|
◆ __construct()
PhpBotFramework\Commands\MessageCommand::__construct |
( |
string |
$command, |
|
|
callable |
$script |
|
) |
| |
Add a function that will be executed everytime a message contain the selected command.
Use this syntax to create a command:
$start_command = new PhpBotFramework\Commands\MessageCommand("start",
function ($bot, $message) {
$bot->sendMessage("Hello, folks!");
}
);
Then you can add it to the bot's commands using addCommand
method:
$bot->addCommand($start_command);
- Parameters
-
string | $command | The command that will trigger this function (e.g. start) |
callable | $script | The function that will be triggered by a command. Must take an object(the bot) and an array(the message received). |
The documentation for this class was generated from the following file:
- src/Commands/MessageCommand.php