-
Notifications
You must be signed in to change notification settings - Fork 5.7k
[BUG] Change condition in Filters.user to avoid error with empty lists #1562
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
Comments
(I can make a PR if you wish) |
@xates Hi, Please help us to understand what is the problem. As we understand it:
What is the usecase which you were trying to use? |
The problem is that currently if an empty list of either user ids or usernames is used, it is still considered by the cited precondition as if no parameter was set, because
A function of the bot that is restricted (or prohibited) to a certain group of users which may be empty at the first start of the bot or generally up to a certain moment. |
@xates Thanks for clarifying. Also, if you'd like to write the fix, we'll be happy to see the PR. |
I didn't think about thread safety, honestly. The solution I had thought of is the one in the opening post. |
Consider changing this condition
python-telegram-bot/telegram/ext/filters.py
Line 796 in 88eccc6
to something like
To avoid throwing the
ValueError
"One and only one of user_id or username must be used" when an empty list ofuser_id
s orusername
s is issued.Similarly for
Filters.chat
.PS This should also be 3 to 4 times faster.
The text was updated successfully, but these errors were encountered: