-
-
Notifications
You must be signed in to change notification settings - Fork 837
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
feat: add ChatType builtin filter #356
Conversation
fix: rename example file name fix: str is container also lol. example fixed also
elif isinstance(obj, CallbackQuery): | ||
obj = obj.message.chat | ||
else: | ||
logger.warning("ChatTypeFilter doesn't support %s as input", type(obj)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is better to use warnings.warn
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd do assert isinstance(obj, (Message, CallbackQuery))
before if/elif
and in else return False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really see any point in breaking the whole pipeline of filters. As far as I remember, that's the reason why we didn't use raise NotImplementedError
. I'd like to keep the warning message in such case. Remember, that in other filters we don't have such way to handle unexpected input
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 0eb5a47
@JrooTJunior I fixed the merge conflicts, should we merge the PR? |
Yep |
Why |
examples/chat_types_filter.py
Outdated
dp = Dispatcher(bot) | ||
|
||
|
||
@dp.message_handler(chat_types=[ChatType.PRIVATE, ChatType.CHANNEL]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here, correct to use is chat_type= without 's', right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You’ve viewed the outdated version. Yes, the correct one is chat_type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Btw in other part of code too not work. I'll find and mark you there or open issue.
Description
Add the ChatType filter. Old filters were marked as deprecated to retain backward compatibility.
The last filter from #151.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Just used an example
Checklist: