mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Add the field is_member to the ChatMember type
This can be used to find whether a restricted user is a member of the chat at the moment of the request.
This commit is contained in:
parent
bcef74c574
commit
b056aa8d7f
@ -36,6 +36,9 @@ class ChatMember(PyrogramType):
|
||||
date (``int``, *optional*):
|
||||
Date when the user joined, unix time. Not available for creator.
|
||||
|
||||
is_member (``bool``, *optional*):
|
||||
Restricted only. True, if the user is a member of the chat at the moment of the request.
|
||||
|
||||
invited_by (:obj:`User <pyrogram.User>`, *optional*):
|
||||
Administrators and self member only. Information about the user who invited this member.
|
||||
In case the user joined by himself this will be the same as "user".
|
||||
@ -51,7 +54,7 @@ class ChatMember(PyrogramType):
|
||||
Information about the member permissions.
|
||||
"""
|
||||
|
||||
__slots__ = ["user", "status", "date", "invited_by", "promoted_by", "restricted_by", "permissions"]
|
||||
__slots__ = ["user", "status", "date", "is_member", "invited_by", "promoted_by", "restricted_by", "permissions"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@ -60,6 +63,7 @@ class ChatMember(PyrogramType):
|
||||
user: "pyrogram.User",
|
||||
status: str,
|
||||
date: int = None,
|
||||
is_member: bool = None,
|
||||
invited_by: "pyrogram.User" = None,
|
||||
promoted_by: "pyrogram.User" = None,
|
||||
restricted_by: "pyrogram.User" = None,
|
||||
@ -70,6 +74,7 @@ class ChatMember(PyrogramType):
|
||||
self.user = user
|
||||
self.status = status
|
||||
self.date = date
|
||||
self.is_member = is_member
|
||||
self.invited_by = invited_by
|
||||
self.promoted_by = promoted_by
|
||||
self.restricted_by = restricted_by
|
||||
@ -121,14 +126,17 @@ class ChatMember(PyrogramType):
|
||||
)
|
||||
|
||||
if isinstance(member, types.ChannelParticipantBanned):
|
||||
return ChatMember(
|
||||
user=user,
|
||||
status=(
|
||||
status = (
|
||||
"kicked" if member.banned_rights.view_messages
|
||||
else "left" if member.left
|
||||
else "restricted"
|
||||
),
|
||||
)
|
||||
|
||||
return ChatMember(
|
||||
user=user,
|
||||
status=status,
|
||||
date=member.date,
|
||||
is_member=not member.left if status == "restricted" else None,
|
||||
restricted_by=pyrogram.User._parse(client, users[member.kicked_by]),
|
||||
permissions=pyrogram.ChatPermissions._parse(member),
|
||||
client=client
|
||||
|
Loading…
x
Reference in New Issue
Block a user