-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Refactor msg_in #1631
Merged
Merged
Refactor msg_in #1631
Conversation
This file contains 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
About failing tests:
|
Eldinnie
requested changes
Nov 24, 2019
Eldinnie
requested changes
Nov 25, 2019
@Eldinnie Are you okay with the changes? And do you have any clue, what codecov wants? |
Bibo-Joshi
added a commit
that referenced
this pull request
Feb 6, 2020
tsnoam
pushed a commit
that referenced
this pull request
Feb 8, 2020
* Make Filters.command only accept MessageEntitie commands * Add option to filters.command to allow cmds anywhere in the message * Make codecov happy, also retroactive for #1631
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed offline, this refactors the
Filters.msg_in
filter to work as__call__
ofFilters.text
, thus closing #1625I encountered two (and a half) obstacles:
BaseFilter
s__call__
is used to perform the update checks, i.e. it executesfilter()
. To allow forFilters.text({'foo', 'bar'})
anyway,Filters.text
s__call__
now checks, if the argument is of typeUpdate
. If it's not, it returns an instance of a subclass that works like the formermsg_in
. An alternative way would be to do something likeHowever calling
Filters.text(iterable={'foo', 'bar'})
seemed neither convenient nor intuitive for me. Also, usually you won't have to callFilter.text(update)
manually anyway …To recreate the caption filter functionality, I needed to add the base class
Filters.caption
that allows only messages that have a caption. Including caption filtering intoFilters.text
likedidn't seem very natural to me …
If you feel like
Filters.caption
is unneeded, we can just remove it. The main usecase for this PR isFilters.text(buttons)
anyway …I wasn't very original in naming the subclasses (
_TextIterable
and_CaptionIterable
). If you have a better naming idea, please tell :)