diff --git a/telebot/__init__.py b/telebot/__init__.py index ce25250..e5e7c8a 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -498,8 +498,8 @@ class TeleBot: def process_new_messages(self, new_messages): self._notify_next_handlers(new_messages) - self._notify_state_handlers(new_messages) self._notify_reply_handlers(new_messages) + self._notify_state_handlers(new_messages) self.__notify_update(new_messages) self._notify_command_handlers(self.message_handlers, new_messages) @@ -2390,7 +2390,6 @@ class TeleBot: """ return self.current_states.current_state(chat_id) - def register_next_step_handler_by_chat_id( self, chat_id: Union[int, str], callback: Callable, *args, **kwargs) -> None: """ @@ -2462,6 +2461,8 @@ class TeleBot: :param new_messages: :return: """ + if not self.current_states: return + for i, message in enumerate(new_messages): need_pop = False user_state = self.current_states.current_state(message.from_user.id) @@ -3242,12 +3243,12 @@ class TeleBot: return message.content_type == 'text' and util.extract_command(message.text) in filter_value elif message_filter == 'chat_types': return message.chat.type in filter_value - elif message_filter == 'state': - return True elif message_filter == 'func': return filter_value(message) elif self.custom_filters and message_filter in self.custom_filters: return self._check_filter(message_filter,filter_value,message) + elif message_filter == 'state': + return True else: return False diff --git a/telebot/handler_backends.py b/telebot/handler_backends.py index fd55384..9a37fad 100644 --- a/telebot/handler_backends.py +++ b/telebot/handler_backends.py @@ -143,7 +143,6 @@ class RedisHandlerBackend(HandlerBackend): return handlers - class State: def __init__(self): self._states = {} @@ -213,4 +212,4 @@ class StateContext: return self.data def __exit__(self, exc_type, exc_val, exc_tb): - return \ No newline at end of file + return diff --git a/telebot/version.py b/telebot/version.py index 9001d30..c48449f 100644 --- a/telebot/version.py +++ b/telebot/version.py @@ -1,3 +1,3 @@ # Versions should comply with PEP440. # This line is parsed in setup.py: -__version__ = '4.0.1' +__version__ = '4.1.0'