【问题标题】:Telegram inline keyboard button not working电报内联键盘按钮不起作用
【发布时间】:2020-11-02 15:50:53
【问题描述】:

我的机器人将内联键盘发送到电报组。键盘发送没有问题,但是当用户单击时,电报没有响应。我使用heroku logs -t 检查了我的heroku 日志。电报没有ping通。这怎么可能发生?这可能是电报方面的问题吗?
附加信息:所有其他功能都运行良好。

TELEGRAM_WEBSITE = "https://api.telegram.org/" + <BOT_TOKEN>
response_body=requests.post(TELEGRAM_WEBSITE + "/sendmessage",
                              data={"text": "{}".format(TEXT), "parse_mode": "HTML",
                                    "chat_id": "{}".format(CHAT_ID),
                                    "reply_markup": json.dumps(
                                        {"inline_keyboard": [[{"text": "{}".format(BET_POSITION),
                                        "callback_data": "{};{};{};{};{};{}".format(BET_SUM,CHALLENGE_TYPE,RIVAL_TELE_ID,TELE_ID,BET_POSITION,USERNAME)}]]})})
response_body=response_body.json()
requests.post(TELEGRAM_WEBSITE + "/sendmessage?chat_id={}&text={}".format(<my telegram id>, response_body))

^这是我发送的键盘。

{'ok': True, 'result': {'message_id': 769, 'from': {'id': <>, 'is_bot': True, 'first_name': '<bot name>', 'username': '<bot username>'}, 'chat': {'id': <group chai id >, 'title': '<group title>', 'username': '<group username>', 'type': 'supergroup'}, 'date': 1594645500, 'text': 'CHALLENGE-\nChallenged by:<my username>\nBet:500', 'entities': [{'offset': 27, 'length': 8, 'type': 'text_mention', 'user': {'id': <id>, 'is_bot': False, 'first_name': '<my first name>', 'username': '<my username>', 'language_code': 'en'}}], 'reply_markup': {'inline_keyboard': [[{'text': 'call', 'callback_data': '10;open;;<my telegram id>;9 bets;<my username>'}]]}}}

^这里是发送response_body的确认信息。 第二个确认显然是我可以在手机上看到键盘了。

【问题讨论】:

  • 如果您不显示代码,我们将无法帮助您...
  • @0stone0 做到了。代码有 500 行长,所以我只发布了相关部分。

标签: python heroku callback telegram


【解决方案1】:

问题出在 Telegram 方面。我更改了机器人令牌并且键盘工作了。

【讨论】:

  • 你是个英雄。哇,一个为 50 亿用户提供动力的信使,需要撤销令牌才能让按钮工作......
猜你喜欢
  • 1970-01-01
  • 2017-06-04
  • 2018-02-09
  • 2017-08-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-28
  • 1970-01-01
  • 2018-04-05
相关资源
最近更新 更多