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

States minor update

This commit is contained in:
Badiboy 2021-09-25 21:15:24 +03:00
parent be7317cc86
commit b35f17124f
2 changed files with 6 additions and 7 deletions

View File

@ -498,8 +498,8 @@ class TeleBot:
def process_new_messages(self, new_messages): def process_new_messages(self, new_messages):
self._notify_next_handlers(new_messages) self._notify_next_handlers(new_messages)
self._notify_state_handlers(new_messages)
self._notify_reply_handlers(new_messages) self._notify_reply_handlers(new_messages)
self._notify_state_handlers(new_messages)
self.__notify_update(new_messages) self.__notify_update(new_messages)
self._notify_command_handlers(self.message_handlers, 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) return self.current_states.current_state(chat_id)
def register_next_step_handler_by_chat_id( def register_next_step_handler_by_chat_id(
self, chat_id: Union[int, str], callback: Callable, *args, **kwargs) -> None: self, chat_id: Union[int, str], callback: Callable, *args, **kwargs) -> None:
""" """
@ -2462,6 +2461,8 @@ class TeleBot:
:param new_messages: :param new_messages:
:return: :return:
""" """
if not self.current_states: return
for i, message in enumerate(new_messages): for i, message in enumerate(new_messages):
need_pop = False need_pop = False
user_state = self.current_states.current_state(message.from_user.id) 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 return message.content_type == 'text' and util.extract_command(message.text) in filter_value
elif message_filter == 'chat_types': elif message_filter == 'chat_types':
return message.chat.type in filter_value return message.chat.type in filter_value
elif message_filter == 'state':
return True
elif message_filter == 'func': elif message_filter == 'func':
return filter_value(message) return filter_value(message)
elif self.custom_filters and message_filter in self.custom_filters: elif self.custom_filters and message_filter in self.custom_filters:
return self._check_filter(message_filter,filter_value,message) return self._check_filter(message_filter,filter_value,message)
elif message_filter == 'state':
return True
else: else:
return False return False

View File

@ -143,7 +143,6 @@ class RedisHandlerBackend(HandlerBackend):
return handlers return handlers
class StateMachine: class StateMachine:
def __init__(self): def __init__(self):
self._states = {} self._states = {}
@ -172,7 +171,6 @@ class StateMachine:
def _get_data(self, chat_id): def _get_data(self, chat_id):
return self._states[chat_id]['data'] return self._states[chat_id]['data']
class State: class State:
""" """
Base class for state managing. Base class for state managing.