diff --git a/telebot/__init__.py b/telebot/__init__.py index 6e4ef40..fd8ed16 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -6,6 +6,7 @@ import time import re import sys import six +import copy import os import pickle @@ -1287,18 +1288,16 @@ class TeleBot: chat_id = message.chat.id was_poped = False if chat_id in self.next_step_handlers.keys(): - handlers = self.next_step_handlers[chat_id] + handlers = copy.deepcopy(self.next_step_handlers[chat_id]) + self.next_step_handlers.pop(chat_id, None) 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 was_poped = True - self.next_step_handlers.pop(chat_id, None) new_messages.pop(i) # removing message that detects with next_step_handler if self.next_step_saver is not None: self.next_step_saver.start_save_timer() - i += 1 - if (not was_poped): i += 1