Disabled ContentTypesFilter by default (#668)

* Disabled ContentTypesFilter by default

* Rename file

* Update docs
This commit is contained in:
Alex Root Junior 2021-08-20 02:39:03 +03:00 committed by GitHub
parent 5851e32266
commit 18a93aab60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 18 deletions

View file

@ -11,10 +11,9 @@ from .base import BaseFilter
class ContentTypesFilter(BaseFilter):
"""
Is useful for handling specific types of messages (For example separate text and stickers handlers).
This is always automatically adds to the filters list for message handlers.
"""
content_types: Optional[Union[Sequence[str], str]] = None
content_types: Union[Sequence[str], str]
"""Sequence of allowed content types"""
@validator("content_types")
@ -32,7 +31,4 @@ class ContentTypesFilter(BaseFilter):
return value
async def __call__(self, message: Message) -> Union[bool, Dict[str, Any]]:
if not self.content_types: # pragma: no cover
# Is impossible but needed for valid typechecking
self.content_types = [ContentType.TEXT]
return ContentType.ANY in self.content_types or message.content_type in self.content_types