【发布时间】:2021-12-23 17:47:53
【问题描述】:
有这样一段代码,改变信息后打开键盘,但执行时报错。
elif (merchant_id == 2):
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text='Your request was accepted', parse_mode="Markdown", reply_markup=keyboard.main_keyboard())
错误:
对 Telegram API 的请求不成功。错误代码:400。说明:错误请求:需要内联键盘
但是当执行另一部分代码时,键盘会立即打开。这是键盘代码:
def main_keyboard():
markup = types.ReplyKeyboardMarkup(one_time_keyboard = False, resize_keyboard = True)
btn1 = types.KeyboardButton('Hello')
btn2 = types.KeyboardButton('Start')
btn3 = types.KeyboardButton('Add')
btn4 = types.KeyboardButton('Stop')
markup.add(btn1, btn3)
markup.add(btn2)
markup.add(btn4)
return markup
如何解决问题,使键盘在代码的两个部分都正确打开? 也许有必要更换或添加一些功能。
【问题讨论】:
标签: python api telegram telegram-bot py-telegram-bot-api