From db6042e91b1b8dfafa2ae51e9e2b8c4d07b6a329 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 2 Sep 2018 13:04:29 +0200 Subject: [PATCH] Fetch ChatForbidden and ChannelForbidden peers This fixes unwanted PEER_ID_INVALID errors in cases where a user or a bot was kicked/banned from a group, supergroup or channel --- pyrogram/client/client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index e9be7a4e..a3cbd93b 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -615,7 +615,7 @@ class Client(Methods, BaseClient): if phone is not None: self.peers_by_phone[phone] = input_peer - if isinstance(entity, types.Chat): + if isinstance(entity, (types.Chat, types.ChatForbidden)): chat_id = entity.id peer_id = -chat_id @@ -625,7 +625,7 @@ class Client(Methods, BaseClient): self.peers_by_id[peer_id] = input_peer - if isinstance(entity, types.Channel): + if isinstance(entity, (types.Channel, types.ChannelForbidden)): channel_id = entity.id peer_id = int("-100" + str(channel_id)) @@ -634,7 +634,7 @@ class Client(Methods, BaseClient): if access_hash is None: continue - username = entity.username + username = getattr(entity, "username", None) input_peer = types.InputPeerChannel( channel_id=channel_id,