FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Added impementation of "prefallbacks" list. by david-shiko · Pull Request #2764 · python-telegram-bot/python-telegram-bot · GitHub

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
16 changes: 16 additions & 0 deletions telegram/ext/conversationhandler.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL