diff --git a/telegram/ext/conversationhandler.py b/telegram/ext/conversationhandler.py index ba621fdeaa5..2bdb4529841 100644 --- a/telegram/ext/conversationhandler.py +++ b/telegram/ext/conversationhandler.py @@ -190,6 +190,7 @@ class ConversationHandler(Handler[Update, CCT]): '_entry_points', '_states', '_fallbacks', + '_prefallbacks', '_allow_reentry', '_per_user', '_per_chat', @@ -219,6 +220,7 @@ def __init__( entry_points: List[Handler[Update, CCT]], states: Dict[object, List[Handler[Update, CCT]]], fallbacks: List[Handler[Update, CCT]], + prefallbacks: List[Handler[Update, CCT]] = List(), allow_reentry: bool = False, per_chat: bool = True, per_user: bool = True, @@ -232,6 +234,7 @@ def __init__( self.run_async = run_async self._entry_points = entry_points + self._prefallbacks = prefallbacks self._states = states self._fallbacks = fallbacks @@ -267,6 +270,7 @@ def __init__( all_handlers: List[Handler] = [] all_handlers.extend(entry_points) + all_handlers.extend(prefallbacks) all_handlers.extend(fallbacks) for state_handlers in states.values(): @@ -323,6 +327,18 @@ def entry_points(self) -> List[Handler]: @entry_points.setter def entry_points(self, value: object) -> NoReturn: raise ValueError('You can not assign a new value to entry_points after initialization.') + + @property + def prefallbacks(self) -> List[Handler]: + """List[:class:`telegram.ext.Handler`]: A list of handlers that might be used if + the user is in a conversation. This list of handlers will be processed before all the others handlers. + This list helps to reduce usage of "and not" filters. + """ + return self._prefallbacks + + @prefallbacks.setter + def prefallbacks(self, value: object) -> NoReturn: + raise ValueError('You can not assign a new value to prefallbacks after initialization.') @property def states(self) -> Dict[object, List[Handler]]: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy