Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions telegram/ext/conversationhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ class ConversationHandler(Handler[Update, CCT]):
'_entry_points',
'_states',
'_fallbacks',
'_prefallbacks',
'_allow_reentry',
'_per_user',
'_per_chat',
Expand Down Expand Up @@ -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,
Expand All @@ -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

Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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]]:
Expand Down