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
6ec16c80b8
commit
e25f9deebd
2 changed files with 4 additions and 2 deletions
|
|
@ -67,9 +67,11 @@ class ChatMember(TelegramObject):
|
||||||
can_add_web_page_previews: Optional[bool] = None
|
can_add_web_page_previews: Optional[bool] = None
|
||||||
"""Restricted only. True, if the user is allowed to add web page previews to their messages"""
|
"""Restricted only. True, if the user is allowed to add web page previews to their messages"""
|
||||||
|
|
||||||
|
@property
|
||||||
def is_chat_admin(self) -> bool:
|
def is_chat_admin(self) -> bool:
|
||||||
return self.status in {ChatMemberStatus.CREATOR, ChatMemberStatus.ADMINISTRATOR}
|
return self.status in {ChatMemberStatus.CREATOR, ChatMemberStatus.ADMINISTRATOR}
|
||||||
|
|
||||||
|
@property
|
||||||
def is_chat_member(self) -> bool:
|
def is_chat_member(self) -> bool:
|
||||||
return self.status not in {ChatMemberStatus.LEFT, ChatMemberStatus.KICKED}
|
return self.status not in {ChatMemberStatus.LEFT, ChatMemberStatus.KICKED}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class TestChatMember:
|
||||||
)
|
)
|
||||||
def test_is_chat_admin(self, status: str, result: bool):
|
def test_is_chat_admin(self, status: str, result: bool):
|
||||||
chat_member = ChatMember(user=user, status=status)
|
chat_member = ChatMember(user=user, status=status)
|
||||||
assert chat_member.is_chat_admin() == result
|
assert chat_member.is_chat_admin == result
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"status,result",
|
"status,result",
|
||||||
|
|
@ -31,4 +31,4 @@ class TestChatMember:
|
||||||
)
|
)
|
||||||
def test_is_chat_member(self, status: str, result: bool):
|
def test_is_chat_member(self, status: str, result: bool):
|
||||||
chat_member = ChatMember(user=user, status=status)
|
chat_member = ChatMember(user=user, status=status)
|
||||||
assert chat_member.is_chat_member() == result
|
assert chat_member.is_chat_member == result
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue