Answer the question
In order to leave comments, you need to log in
How to disable the processing of inline buttons in a telegram bot?
I am using the pyTelegramBotAPI library. The bot sends messages to the user with an inline button below. I need the bot to respond (when the user clicks) only to those inline buttons that are attached to the bot's last message.
Answer the question
In order to leave comments, you need to log in
Well, delete the buttons after clicking. All methods are in BotAPI.
I did not work with this library, but I can offer a solution if it is possible to implement it.
After the bot sent the last message with its inline buttons, get the message ID\id of the inline buttons from the last message or similar.
And save it to a variable (if it is an ID of inline buttons, then to an array)
When you click on an inline button, your bot should receive a request from the button, and hence its Id, check if there is such an ID in the list of the last
buttons_ID = [11,52,65]
button_pressed_ID = 11
if button_pressed_ID in buttons_ID:
print("Кнопка нажата в последнем сообщении")
else:
print('Кнопка нажата не из последнего сообщения. Игнорим')
last_message_ID = 114415
button_pressed_message_ID = 11
if button_pressed_message_ID == last_message_ID:
print("Кнопка нажата в последнем сообщении")
else:
print('Кнопка нажата не из последнего сообщения. Игнорим')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question