How can I differentiate between a 'Message' update and a 'Callback Query' update? (Telegram Bot API)

血红的双手。 提交于 2019-12-05 21:41:15
if (($update['message']) != null) {

} else if ($update['callback_query'] != Null) {

According to telegram Docs:

At most one of the optional parameters can be present in any given update.

so you just need to check which one of them is not Null.

You can simply check if CallbackQuery is null or not. See the Telegram docs:

CallbackQuery

This object represents an incoming callback query from a callback button in an inline keyboard. If the button that originated the query was attached to a message sent by the bot, the field message will be present. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be present. Exactly one of the fields data or game_short_name will be present.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!