Answer the question
In order to leave comments, you need to log in
telebot. Python. How to protect yourself from spam?
The essence of the problem is that when you press the same button very quickly several times, the menu splits into two, because the handler receives two messages instead of the planned one.
I am writing a conditional code on which an error occurs, since there are a lot of lines in the original.
def menu_show (message):
# В оригинале тут работа с БД
markup = types.ReplyKeyboardMarkup(True, one_time_keyboard = True)
markup.row("menu")
bot.send_message(message.chat.id, "*Меню*", reply_markup=markup)
bot.register_next_step_handler(message, menu_processing)
def menu_processing(message):
if message.text == "menu":
menu_show(message)
else:
bot.send_message(message.chat.id, "Неправильный ввод, нажми на кнопку.")
bot.register_next_step_handler(message, menu_show)
Answer the question
In order to leave comments, you need to log in
I do not quite understand. It seems like the buttons do hold for the duration of the processing themselves.
But if not, in theory there is an id property in the message, you can globally (through the database or something else) I think it’s a good job for redis or sqlite in memory to keep those id that are being processed and release them only after the response is sent, as a consequence of the condition on handler input.
if message_id not in processing_ids:
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question