diff --git a/telebot/__init__.py b/telebot/__init__.py index 8f9b60b..2204bfa 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -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