Skip to content

Added impementation of "prefallbacks" list. #2764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
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
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