Webhook replies (quickAction) - Kyle2142/PHPBot GitHub Wiki
What is quickAction?
If you are using webhooks (you should), Telegram makes a connection to your bot for each update. You can use the same connection to make a one-time request to Telegram.
For more info, read this
In summary:
Pros | Cons |
---|---|
Faster | One-time |
Less requests | Less readable |
No result |
Basically we can use this as a way to have one action done a bit faster than the others.
Usage
To use this, have your method as a string, and your arguments as an array like so:
$bot->quickAction('sendMessage', ['chat_id' => $chat_id, 'text' => $text]);
Note: trying to use this method twice in one instance of kyle2142\PHPBot
will throw an Exception!
Example
I usually use this for a /ping
command, as below:
switch($command){
case 'ping': //simple check for bot responsiveness
$bot->quickAction('sendMessage', ['chat_id' => $chat_id, 'text' => 'Pong!', 'reply_to_message_id' => $message['message_id']]);
break;
//others go here
}