mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Added fields to ChatMember (#340)
* Added fields to ChatMember * Added ChatMemberStatus helper
This commit is contained in:
parent
de3c5c1a8d
commit
9f11afda5b
3 changed files with 78 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import datetime
|
|||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from .base import TelegramObject
|
||||
from ...utils import helper
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from .user import User
|
||||
|
|
@ -65,3 +66,25 @@ class ChatMember(TelegramObject):
|
|||
inline bots"""
|
||||
can_add_web_page_previews: Optional[bool] = None
|
||||
"""Restricted only. True, if the user is allowed to add web page previews to their messages"""
|
||||
|
||||
@property
|
||||
def is_chat_admin(self) -> bool:
|
||||
return self.status in {ChatMemberStatus.CREATOR, ChatMemberStatus.ADMINISTRATOR}
|
||||
|
||||
@property
|
||||
def is_chat_member(self) -> bool:
|
||||
return self.status not in {ChatMemberStatus.LEFT, ChatMemberStatus.KICKED}
|
||||
|
||||
|
||||
class ChatMemberStatus(helper.Helper):
|
||||
"""
|
||||
Chat member status
|
||||
"""
|
||||
mode = helper.HelperMode.lowercase
|
||||
|
||||
CREATOR = helper.Item() # creator
|
||||
ADMINISTRATOR = helper.Item() # administrator
|
||||
MEMBER = helper.Item() # member
|
||||
RESTRICTED = helper.Item() # restricted
|
||||
LEFT = helper.Item() # left
|
||||
KICKED = helper.Item() # kicked
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue