From ce0ddcddb2803f52880b2e5064f9a78c90c9f972 Mon Sep 17 00:00:00 2001 From: elandorr <56206745+elandorr@users.noreply.github.com> Date: Fri, 21 Aug 2020 05:30:42 +0000 Subject: [PATCH] Fix get_nearby_chats breaking with the new Layer (#446) * fix for new format This fixes the `AttributeError: 'PeerUser' object has no attribute 'channel_id'`. Maybe we should also have a method to show nearby users? * Update get_nearby_chats.py Use isinstance instead of type Co-authored-by: Dan <14043624+delivrance@users.noreply.github.com> --- pyrogram/client/methods/chats/get_nearby_chats.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pyrogram/client/methods/chats/get_nearby_chats.py b/pyrogram/client/methods/chats/get_nearby_chats.py index 6b4ab56d..4e76b7e6 100644 --- a/pyrogram/client/methods/chats/get_nearby_chats.py +++ b/pyrogram/client/methods/chats/get_nearby_chats.py @@ -64,11 +64,12 @@ class GetNearbyChats(BaseClient): peers = r.updates[0].peers for peer in peers: - chat_id = utils.get_channel_id(peer.peer.channel_id) + if isinstance(peer.peer, types.PeerChannel): + chat_id = utils.get_channel_id(peer.peer.channel_id) - for chat in chats: - if chat.id == chat_id: - chat.distance = peer.distance - break + for chat in chats: + if chat.id == chat_id: + chat.distance = peer.distance + break return chats