1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

_notify_next_handlers drops messages if empty handler list

After calling
clear_step_handler(...)
code:
self.next_step_handlers[chat_id] = []
left the key in next_step_handlers.
When a next message arrives, the old handler executes nothing (no handlers), but still remove message from message queue:
new_messages.pop(i).

Updated to pop message only when there are real handlers in the list.
This commit is contained in:
Badiboy 2018-05-27 23:24:37 +03:00
parent 9c79ba2f87
commit 78afd045d8

View File

@ -1155,10 +1155,11 @@ class TeleBot:
chat_id = message.chat.id
if chat_id in self.next_step_handlers.keys():
handlers = self.next_step_handlers[chat_id]
for handler in handlers:
self._exec_task(handler["callback"], message, *handler["args"], **handler["kwargs"])
if (handlers):
for handler in handlers:
self._exec_task(handler["callback"], message, *handler["args"], **handler["kwargs"])
new_messages.pop(i) # removing message that detects with next_step_handler
self.next_step_handlers.pop(chat_id, None)
new_messages.pop(i) # removing message that detects with next_step_handler
i += 1
@staticmethod