Skip to content

Conversation

@spontanurlaub
Copy link
Contributor

@spontanurlaub spontanurlaub 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.

Added extra Filters for File Type and Category, based on the provided Mime-Type
Added Tests for the Category and File Types Filters.
Fixed the Tests from the last commit
@JosXa JosXa mentioned this pull request Mar 14, 2018
Args:
category (str, optional): category of the media you want to filter"""
self.category = category
self.name = 'Filters.document.category(\'{}\')'.format(self.category)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?


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`."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this change

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this change

: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`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this change

@jh0ker jh0ker mentioned this pull request Mar 16, 2018
@jh0ker
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
@github-actions github-actions bot locked and limited conversation to collaborators Aug 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants