-
Notifications
You must be signed in to change notification settings - Fork 9
Webhook replies (quickAction)
Kyle2142 edited this page Jul 1, 2018
·
1 revision
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.
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!
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
}