使用 pyTelegramBotAPI,如何顺利编辑消息和内联标记?
Using pyTelegramBotAPI, how can I edit the message and Inline Markup smoothly?
我目前正在使用 pyTelegramBotAPI 在电报上制作一个机器人,并且具有编辑消息的功能以及它下面的 InlineKeyboardButtons 以防止它被用户发送垃圾邮件。但是,在编辑消息和正在编辑的按钮之间总是存在明显的延迟,我似乎无法找到任何相关信息。我试过使用线程,但它仍然不能同时编辑消息和按钮。为了澄清,以下是我的代码:
def test_callback(call):
if call.data == 'c':
markup = types.InlineKeyboardMarkup([[types.InlineKeyboardButton('Encode', callback_data='ce'), types.InlineKeyboardButton('Decode', callback_data='cd')]])
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text='Select Decode or Encode:')
bot.edit_message_reply_markup(call.from_user.id, call.message.message_id, reply_markup=markup)
该文档也根本没有涵盖这一点,因此我们将不胜感激。
您应该能够将 reply_markup=markup
传递给 edit_message_text
调用,而不是单独调用 edit_message_reply_markup
。
我目前正在使用 pyTelegramBotAPI 在电报上制作一个机器人,并且具有编辑消息的功能以及它下面的 InlineKeyboardButtons 以防止它被用户发送垃圾邮件。但是,在编辑消息和正在编辑的按钮之间总是存在明显的延迟,我似乎无法找到任何相关信息。我试过使用线程,但它仍然不能同时编辑消息和按钮。为了澄清,以下是我的代码:
def test_callback(call):
if call.data == 'c':
markup = types.InlineKeyboardMarkup([[types.InlineKeyboardButton('Encode', callback_data='ce'), types.InlineKeyboardButton('Decode', callback_data='cd')]])
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text='Select Decode or Encode:')
bot.edit_message_reply_markup(call.from_user.id, call.message.message_id, reply_markup=markup)
该文档也根本没有涵盖这一点,因此我们将不胜感激。
您应该能够将 reply_markup=markup
传递给 edit_message_text
调用,而不是单独调用 edit_message_reply_markup
。