From 88597f0da8ee348f0da2312c1f403b112c99b121 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 14 Apr 2018 12:08:50 +0200 Subject: [PATCH] Don't get full channel on iter_participants unless necessary --- telethon/telegram_client.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 72b60e61..503f1c0f 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -1247,11 +1247,14 @@ class TelegramClient(TelegramBareClient): limit = float('inf') if limit is None else int(limit) if isinstance(entity, InputPeerChannel): - total = self(GetFullChannelRequest( - entity - )).full_chat.participants_count - if _total: - _total[0] = total + if _total or (aggressive and not filter): + total = self(GetFullChannelRequest( + entity + )).full_chat.participants_count + if _total: + _total[0] = total + else: + total = 0 if limit == 0: return