如何编辑内联按钮?

时间:2018-05-10 07:54:52

标签: python telegram-bot

我有两个菜单按钮。取决于它使用哪个机器人必须返回不同的内联按钮。所以第一个按钮工作正常,但如果我使用第二个按钮

,如何编辑此消息
 def first(m):
    keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True)
    keyboard.add(*[types.KeyboardButton(name) for name in ['1menubutton', '2menubutton']])   
    msg = bot.send_message(m.chat.id, 'Choose button!',
        reply_markup=keyboard)

def name(m):
    if m.text == '1menubutton':
        keyboard = types.InlineKeyboardMarkup()
        keyboard.add(*[types.InlineKeyboardButton(text=name,callback_data=name) for name
                    in ['1inlinebutton']])
    elif m.text =='2menubutton':
        keyboard = types.InlineKeyboardMarkup()
        keyboard.add(*[types.InlineKeyboardButton(text=name,callback_data=name) for name
                    in ['2inlinebutton']])

我试过这样,但它不起作用:

bot.edit_message_reply_markup(m.chat.id, message_id=m.message_id, reply_markup=keyboard)

1 个答案:

答案 0 :(得分:1)

您可以像this example payload一样使用editMessageReplyMarkup。