From 89e6f4137b5a9aa5dbe0d3bcfaf458109c5949ac Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Fri, 7 Jun 2019 18:00:00 +0200 Subject: [PATCH] Fix get_chat_member always returning self for basic groups --- .../client/methods/chats/get_chat_member.py | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/pyrogram/client/methods/chats/get_chat_member.py b/pyrogram/client/methods/chats/get_chat_member.py index 4deab9ec..b84836c6 100644 --- a/pyrogram/client/methods/chats/get_chat_member.py +++ b/pyrogram/client/methods/chats/get_chat_member.py @@ -47,26 +47,30 @@ class GetChatMember(BaseClient): Raises: RPCError: In case of a Telegram RPC error. """ - chat_id = self.resolve_peer(chat_id) - user_id = self.resolve_peer(user_id) + chat = self.resolve_peer(chat_id) + user = self.resolve_peer(user_id) - if isinstance(chat_id, types.InputPeerChat): + if isinstance(chat, types.InputPeerChat): full_chat = self.send( functions.messages.GetFullChat( - chat_id=chat_id.chat_id + chat_id=chat.chat_id ) ) for member in pyrogram.ChatMembers._parse(self, full_chat).chat_members: - if member.user.is_self: - return member + if isinstance(user, types.InputPeerSelf): + if member.user.is_self: + return member + else: + if member.user.id == user.user_id: + return member else: raise UserNotParticipant - elif isinstance(chat_id, types.InputPeerChannel): + elif isinstance(chat, types.InputPeerChannel): r = self.send( functions.channels.GetParticipant( - channel=chat_id, - user_id=user_id + channel=chat, + user_id=user ) )