mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Added fields to ChatMember
This commit is contained in:
parent
fe756faa2d
commit
e69aaa56ca
2 changed files with 10 additions and 26 deletions
|
|
@ -4,7 +4,6 @@ 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
|
||||
|
|
@ -68,29 +67,7 @@ class ChatMember(TelegramObject):
|
|||
"""Restricted only. True, if the user is allowed to add web page previews to their messages"""
|
||||
|
||||
def is_chat_admin(self) -> bool:
|
||||
return ChatMemberStatus.is_chat_admin(self.status)
|
||||
return self.status in {"creator", "administrator"}
|
||||
|
||||
def is_chat_member(self) -> bool:
|
||||
return ChatMemberStatus.is_chat_member(self.status)
|
||||
|
||||
|
||||
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
|
||||
|
||||
@classmethod
|
||||
def is_chat_admin(cls, role: str) -> bool:
|
||||
return role in [cls.ADMINISTRATOR, cls.CREATOR]
|
||||
|
||||
@classmethod
|
||||
def is_chat_member(cls, role: str) -> bool:
|
||||
return role in [cls.MEMBER, cls.ADMINISTRATOR, cls.CREATOR, cls.RESTRICTED]
|
||||
return self.status not in {"left", "kicked"}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ This object contains information about one member of a chat.
|
|||
| `can_invite_users` | `#!python Optional[bool]` | Optional. Administrators and restricted only. True, if the user is allowed to invite new users to the chat |
|
||||
| `can_pin_messages` | `#!python Optional[bool]` | Optional. Administrators and restricted only. True, if the user is allowed to pin messages; groups and supergroups only |
|
||||
| `is_member` | `#!python Optional[bool]` | Optional. Restricted only. True, if the user is a member of the chat at the moment of the request |
|
||||
| `is_chat_admin` | `#!python bool` | True if the user is administrator or creator of the chat |
|
||||
| `can_send_messages` | `#!python Optional[bool]` | Optional. Restricted only. True, if the user is allowed to send text messages, contacts, locations and venues |
|
||||
| `can_send_media_messages` | `#!python Optional[bool]` | Optional. Restricted only. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes |
|
||||
| `can_send_polls` | `#!python Optional[bool]` | Optional. Restricted only. True, if the user is allowed to send polls |
|
||||
|
|
@ -31,6 +30,14 @@ This object contains information about one member of a chat.
|
|||
| `can_add_web_page_previews` | `#!python Optional[bool]` | Optional. Restricted only. True, if the user is allowed to add web page previews to their messages |
|
||||
|
||||
|
||||
## Extensions
|
||||
|
||||
| Name | Type | Description |
|
||||
| - | - | - |
|
||||
| `is_chat_admin` | `#!python bool` | True if the user is administrator or creator of the chat |
|
||||
| `is_chat_member` | `#!python bool` | True if the user is member of the chat |
|
||||
|
||||
|
||||
|
||||
## Location
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue