我是python-telegram bot的新手,当我按下旧的内线键盘而无需更换旧的内线键盘时,我想创建一个新的内联键盘。我使用" EditMessAgeText"来处理回调查询。但是它仅用" Reply_markup"代替InlineKeyboard,但我想创建一个新的InlineKeyboard。如何解决这个问题呢?我在Stack Overflow中搜索了很多时间。但是我现在无法找到该解决方案吗?请帮助我解决问题!。我的图像是
这是我的开始(CommandHandler)
def start(bot, update):
bot.sendChatAction(update.message.chat_id, action=ChatAction.TYPING)
bot.send_message(chat_id=update.message.chat_id, text=Message.CLAIM,parse_mode='html')
reply_markup = telegram.InlineKeyboardMarkup([[telegram.InlineKeyboardButton("Check New Model",callback_data="New Model")],
[telegram.InlineKeyboardButton("Reasses my Insurance",callback_data="Reasses")],
[telegram.InlineKeyboardButton("File a Claim",callback_data="claim")]])
bot.sendMessage(chat_id=update.message.chat_id, text="Choose the above one?", reply_markup=reply_markup)
这是我的回调处理程序
def callback(bot,update):
query=update.callback_query
if query.data=="claim":
reply_markup = telegram.InlineKeyboardMarkup([[telegram.InlineKeyboardButton("Vehicle",callback_data="vehicle")],
[telegram.InlineKeyboardButton("Personal Accident",callback_data="accident")],
[telegram.InlineKeyboardButton("Other",callback_data="other")]])
bot.editMessageText(
message_id = update.callback_query.message.message_id,
chat_id = update.callback_query.message.chat.id,
text = "Choose the one below",
reply_markup=reply_markup
)
根据名称,bot.edit_message_text
用于编辑消息的文本。您需要使用 bot.edit_message_reply_markup
(文档)。
,如果要在现有键盘中添加一些按钮(如果我了解您的问题),请将其包含在编辑中:
reply_markup = telegram.InlineKeyboardMarkup([
[telegram.InlineKeyboardButton("Check New Model",callback_data="New Model")],
[telegram.InlineKeyboardButton("Reasses my Insurance",callback_data="Reasses")],
[telegram.InlineKeyboardButton("File a Claim",callback_data="claim")],[telegram.InlineKeyboardButton("Vehicle",callback_data="vehicle")],[telegram.InlineKeyboardButton("Personal Accident",callback_data="accident")],
[telegram.InlineKeyboardButton("Other",callback_data="other")]
])