From 302a823c88918219c0a5f184f7f6a7f17c76e972 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 27 Mar 2018 17:15:22 +0200 Subject: [PATCH] Fix invalid access to .participants on chat forbidden result --- telethon/telegram_client.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 4eb33801..7998d0ed 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -83,7 +83,7 @@ from .tl.types import ( InputMessageEntityMentionName, DocumentAttributeVideo, UpdateEditMessage, UpdateEditChannelMessage, UpdateShort, Updates, MessageMediaWebPage, ChannelParticipantsSearch, PhotoSize, PhotoCachedSize, - PhotoSizeEmpty, MessageService + PhotoSizeEmpty, MessageService, ChatParticipants ) from .tl.types.messages import DialogsSlice from .extensions import markdown, html @@ -1278,6 +1278,11 @@ class TelegramClient(TelegramBareClient): elif isinstance(entity, InputPeerChat): # TODO We *could* apply the `filter` here ourselves full = self(GetFullChatRequest(entity.chat_id)) + if not isinstance(full.full_chat.participants, ChatParticipants): + # ChatParticipantsForbidden won't have ``.participants`` + _total[0] = 0 + return + if _total: _total[0] = len(full.full_chat.participants.participants)