feat: add ChatType builtin filter (#356)

* feat: ChatTypesFilter

* feat: add example of usage

* feat: docs

* fix: add import in filters/__init__

* fix: remove some of event_handlers

* fix

* fix imports

* fix: rename to ChatTypeFilter

* fix: rename argument to chat_type

fix: rename example file name

fix: str is container also lol. example fixed also

* fix: respect type hints

* fix: add warning with respect to type hint

* fix: use warnings instead of logging
This commit is contained in:
Egor 2020-07-02 14:17:48 +03:00 committed by GitHub
parent d179789ea7
commit 81b36bd192
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 90 additions and 5 deletions

View file

@ -10,6 +10,7 @@ from .chat_member import ChatMember
from .chat_permissions import ChatPermissions
from .chat_photo import ChatPhoto
from .input_file import InputFile
from ..utils.deprecated import deprecated
class Chat(base.TelegramObject):
@ -512,6 +513,7 @@ class ChatType(helper.Helper):
return obj.type in chat_types
@classmethod
@deprecated("This filter was moved to ChatTypeFilter, and will be removed in aiogram v3.0")
def is_private(cls, obj) -> bool:
"""
Check chat is private
@ -522,6 +524,7 @@ class ChatType(helper.Helper):
return cls._check(obj, [cls.PRIVATE])
@classmethod
@deprecated("This filter was moved to ChatTypeFilter, and will be removed in aiogram v3.0")
def is_group(cls, obj) -> bool:
"""
Check chat is group
@ -532,6 +535,7 @@ class ChatType(helper.Helper):
return cls._check(obj, [cls.GROUP])
@classmethod
@deprecated("This filter was moved to ChatTypeFilter, and will be removed in aiogram v3.0")
def is_super_group(cls, obj) -> bool:
"""
Check chat is super-group
@ -542,6 +546,7 @@ class ChatType(helper.Helper):
return cls._check(obj, [cls.SUPER_GROUP])
@classmethod
@deprecated("This filter was moved to ChatTypeFilter, and will be removed in aiogram v3.0")
def is_group_or_super_group(cls, obj) -> bool:
"""
Check chat is group or super-group
@ -552,6 +557,7 @@ class ChatType(helper.Helper):
return cls._check(obj, [cls.GROUP, cls.SUPER_GROUP])
@classmethod
@deprecated("This filter was moved to ChatTypeFilter, and will be removed in aiogram v3.0")
def is_channel(cls, obj) -> bool:
"""
Check chat is channel