From 90b959555da61419d817673e3fcc3ee4f8a18fe2 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 12 Mar 2019 16:46:54 +0100 Subject: [PATCH] Fix flood waits generated when iterating over basic chat members --- pyrogram/client/methods/chats/iter_chat_members.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyrogram/client/methods/chats/iter_chat_members.py b/pyrogram/client/methods/chats/iter_chat_members.py index 5d0fa911..b0aeb51b 100644 --- a/pyrogram/client/methods/chats/iter_chat_members.py +++ b/pyrogram/client/methods/chats/iter_chat_members.py @@ -20,6 +20,7 @@ from string import ascii_lowercase from typing import Union, Generator import pyrogram +from pyrogram.api import types from ...ext import BaseClient @@ -82,6 +83,7 @@ class IterChatMembers(BaseClient): queries = [query] if query else QUERIES total = limit or (1 << 31) - 1 limit = min(200, total) + resolved_chat_id = self.resolve_peer(chat_id) filter = ( Filters.RECENT @@ -107,6 +109,9 @@ class IterChatMembers(BaseClient): if not chat_members: break + if isinstance(resolved_chat_id, types.InputPeerChat): + total = len(chat_members) + offset += len(chat_members) for chat_member in chat_members: