mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
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:
parent
d179789ea7
commit
81b36bd192
6 changed files with 90 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue