-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
🛠 breakingchange type: breakingchange type: breaking
Description
What kind of feature are you missing? Where do you notice a shortcoming of PTB?
The filters
argument of the MessageHandler
constructor is currently a positional argument and defaults to filters.ALL
if None
is explicitly passed:
python-telegram-bot/telegram/ext/_messagehandler.py
Lines 82 to 90 in 637cc57
def __init__( | |
self, | |
filters: filters_module.BaseFilter, | |
callback: HandlerCallback[Update, CCT, RT], | |
block: DVInput[bool] = DEFAULT_TRUE, | |
): | |
super().__init__(callback, block=block) | |
self.filters = filters if filters is not None else filters_module.ALL |
Describe the solution you'd like
Using a keyword argument instead:
def __init__(
self,
callback: HandlerCallback[Update, CCT, RT],
filters: filters_module.BaseFilter = filters.ALL,
block: DVInput[bool] = DEFAULT_TRUE,
):
super().__init__(callback, block=block)
self.filters = filters
Or something similar.
Documentation could be improved as well:
python-telegram-bot/telegram/ext/_messagehandler.py
Lines 47 to 51 in 637cc57
operators (& for and, | for or, ~ for not). This defaults to all message updates | |
being: :attr:`telegram.Update.message`, :attr:`telegram.Update.edited_message`, | |
:attr:`telegram.Update.channel_post` and :attr:`telegram.Update.edited_channel_post`. | |
If you don't want or need any of those pass ``~filters.UpdateType.*`` in the filter | |
argument. |
Seems unclear to me when it is stating pass ``~filters.UpdateType.*`` in the filter argument.
Describe alternatives you've considered
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
🛠 breakingchange type: breakingchange type: breaking