Skip to content
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

Filters for Category and file types #1046

Merged
merged 9 commits into from Mar 16, 2018

Conversation

Projects
None yet
2 participants
@code1mountain
Copy link
Contributor

code1mountain commented Mar 14, 2018

Basically PR #889 , without the file_size Filter.

Filters for file Category and Mime Type, based on the mime_type of the file.

        Note:
            This Filter only filters by the mime_type of the document,
                it doesn't check the validity of document.
            The user can manipulate the mime-type of a message and
                send media with wrong types that don't fit to this handler.

Here is my fixed version of my previous PR. I'm not sure how detailed the tests have to be.

code1mountain added some commits Mar 14, 2018

Added extra Filters for File Type and Category
Added extra Filters for File Type and Category, based on the provided Mime-Type
Added tests for the new Filters
Added Tests for the Category and File Types Filters.
Fixed Tests
Fixed the Tests from the last commit

@JosXa JosXa referenced this pull request Mar 14, 2018

Closed

Add Filters.gif #875

Args:
category (str, optional): category of the media you want to filter"""
self.category = category
self.name = 'Filters.document.category(\'{}\')'.format(self.category)

This comment has been minimized.

@jh0ker

jh0ker Mar 16, 2018

Member

Please use double-quotes on the string instead of escaping single-quotes inside the string

video = category('video/')
text = category('text/')

class file_type(BaseFilter):

This comment has been minimized.

@jh0ker

jh0ker Mar 16, 2018

Member

I believe in one of your previous PRs we had agreed to rename this filter to mime_type to prevent misunderstandings. Is there a reason you changed this back?

@@ -277,7 +350,7 @@ def filter(self, message):
return bool(message.new_chat_members)

new_chat_members = _NewChatMembers()
""":obj:`Filter`: Messages that contain :attr:`telegram.Message.new_chat_members`."""
""":obj:`Filter`: Messages that contain :attr:`telegram.Message.new_chat_member`."""

This comment has been minimized.

@jh0ker

jh0ker Mar 16, 2018

Member

Please revert this change

@@ -368,7 +441,7 @@ def filter(self, message):
"""Subset for messages containing a status update.
Examples:
Use these filters like: ``Filters.status_update.new_chat_members`` etc. Or use just
Use these filters like: ``Filters.status_update.new_chat_member`` etc. Or use just

This comment has been minimized.

@jh0ker

jh0ker Mar 16, 2018

Member

Please revert this change

@@ -384,7 +457,7 @@ def filter(self, message):
:attr:`telegram.Message.migrate_from_chat_id` or
:attr: `telegram.Message.migrate_from_chat_id`.
new_chat_members (:obj:`Filter`): Messages that contain
:attr:`telegram.Message.new_chat_members`.
:attr:`telegram.Message.new_chat_member`.

This comment has been minimized.

@jh0ker

jh0ker Mar 16, 2018

Member

Please revert this change

@jh0ker jh0ker referenced this pull request Mar 16, 2018

Closed

Fixed version to PR #880 #889

code1mountain added some commits Mar 16, 2018

@jh0ker

jh0ker approved these changes Mar 16, 2018

@jh0ker

This comment has been minimized.

Copy link
Member

jh0ker commented Mar 16, 2018

Failing tests are due to unrelated derp, merging...

@jh0ker jh0ker merged commit 38e3b91 into python-telegram-bot:master Mar 16, 2018

1 of 3 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
hound No violations found. Woof!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.