Python电报Bot编辑自定义键盘

问题描述 投票:1回答:1

我正在使用Python Telegram BOT API来构建演示应用程序。我要实现的任务是创建一个自定义键盘,然后在每次与用户交互时继续编辑键盘键。我尝试使用“ edit_message_reply_markup”,但收到错误消息“消息无法编辑”。无法编辑自定义键盘吗?

这是我为任务编写的示例代码。

初始任务:

FirstKeyboard = [[KeyboardButton(text = "FRUITS"), KeyboardButton(text = "VEGITABLES"), KeyboardButton(text = "DRINKS")],[KeyboardButton(text = "SNACKS"), KeyboardButton(text = "CHIPS"), KeyboardButton(text = "NOTHING")],[KeyboardButton(text = "DONE")]]
menu = ReplyKeyboardMarkup(FirstKeyboard)
KeyboardMessageID = context.bot.send_message(chat_id = chatID, text = "Select What you Like", reply_markup = menu)

编辑任务:

SecondKeyBoard = [[KeyboardButton(text = "APPLE"), KeyboardButton(text = "BANANA"), KeyboardButton(text = "PUMPKIN")],[KeyboardButton(text = "ORANGES"), KeyboardButton(text = "GRAPES"), KeyboardButton(text = "WINE")],[KeyboardButton(text = "DONE")]]
menu = ReplyKeyboardMarkup(SecondKeyBoard)
KeyboardMessageID = context.bot.edit_message_reply_markup(chat_id = chatID, message_id = KeyboardMessageID, reply_markup = menu)

我收到错误消息“无法编辑消息”

telegram telegram-bot python-telegram-bot
1个回答
0
投票

https://core.telegram.org/bots/api#updating-messages

目前看来我们可以编辑嵌入式键盘,而不能编辑回复键盘

© www.soinside.com 2019 - 2024. All rights reserved.