如何检测消息具有内联按钮电报机器人

How to detect a message has inline button telegram bot

我在电报中创建了一个群组控制器机器人。 现在我遇到了一个问题:我可以检测到包含内联按钮的消息吗?

Standard Telegram API 没有检测这些消息的方法。

有什么解决办法?

由内联键盘触发的消息将具有键 callback_query

这是您将收到的结构。

{
  "update_id": 123456789,
  "callback_query": {
    "id": "123456789123456789",
    "from": { ... },
    "message": {
      "message_id": 123456789,
      "from": { ... },
      "chat": { ... },
      "date": 123456789,
      "text": "Message text"
    },
    "chat_instance": "123456789123456789",
    "data": "your_callback_data"
  }
}

Telegram Bot API CallbackQuery