def send_callback_keyboard(self, bot, chat_id, text, buttons, action=None):
keyboard = []
for button in buttons:
keyboard.append([button])
keyboard.append([InlineKeyboardButton("cancel", callback_data="null")])
markup = InlineKeyboardMarkup(keyboard)
try:
message_id = self._sent_keyboard_message_ids[chat_id]
message = bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=text, reply_markup=markup)
except KeyError:
message = bot.send_message(chat_id=chat_id, text=text, reply_markup=markup)
self._sent_keyboard_message_ids[chat_id] = message.message_id
if action:
self._sent_keyboard[chat_id] = action
评论列表
文章目录