PhpBotFramework  2.0.2
A framework for Telegram Bots' APIs.
Public Member Functions | Static Public Attributes | List of all members
PhpBotFramework\Commands\MultiCharacterCommand Class Reference
Inheritance diagram for PhpBotFramework\Commands\MultiCharacterCommand:
PhpBotFramework\Commands\BasicCommand

Public Member Functions

 __construct (string $command, callable $script, string ... $chars)
 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 ()
 

Static Public Attributes

static $type = 'message'
 
static $object_class = 'PhpBotFramework\Entities\Message'
 
static $priority = 1
 

Additional Inherited Members

- Protected Attributes inherited from PhpBotFramework\Commands\BasicCommand
 $script
 

Constructor & Destructor Documentation

◆ __construct()

PhpBotFramework\Commands\MultiCharacterCommand::__construct ( string  $command,
callable  $script,
string ...  $chars 
)

Add a function that will be executed everytime a message contain the selected command.

Use this syntax to create a command:

$help_command = new PhpBotFramework\Commands\MultiCharacterCommand("help",
    function ($bot, $message) {
        $bot->sendMessage("This is a help message.");
    }, '!', '.', '/'
);

Then you can add it to the bot's commands using addCommand method:

$bot->addCommand($help_command);
Parameters
string$commandThe command that will trigger this function (e.g. start)
callable$scriptThe 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: