From 9285e50c63a918975da5d1f8cc4940928886dadc Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 22 Aug 2021 13:24:02 +0200 Subject: [PATCH] Handle non-user bans when iterating banned participants Closes #3105. --- telethon/client/chats.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/telethon/client/chats.py b/telethon/client/chats.py index ca4e771b..ef7a10cb 100644 --- a/telethon/client/chats.py +++ b/telethon/client/chats.py @@ -233,6 +233,9 @@ class _ParticipantsIter(RequestIter): for participant in participants.participants: if isinstance(participant, types.ChannelParticipantBanned): + if not isinstance(participant.peer, types.PeerUser): + # May have the entire channel banned. See #3105. + continue user_id = participant.peer.user_id else: user_id = participant.user_id