diff --git a/pyrogram/client/ext/base_client.py b/pyrogram/client/ext/base_client.py index 7b94ae6e..d2c348a8 100644 --- a/pyrogram/client/ext/base_client.py +++ b/pyrogram/client/ext/base_client.py @@ -126,3 +126,6 @@ class BaseClient: def get_chat_members(self, *args, **kwargs): pass + + def get_chat_members_count(self, *args, **kwargs): + pass diff --git a/pyrogram/client/methods/chats/iter_chat_members.py b/pyrogram/client/methods/chats/iter_chat_members.py index 963081f8..5d0fa911 100644 --- a/pyrogram/client/methods/chats/iter_chat_members.py +++ b/pyrogram/client/methods/chats/iter_chat_members.py @@ -81,9 +81,14 @@ class IterChatMembers(BaseClient): yielded = set() queries = [query] if query else QUERIES total = limit or (1 << 31) - 1 - filter = Filters.RECENT if total <= 10000 and filter == Filters.ALL else filter limit = min(200, total) + filter = ( + Filters.RECENT + if self.get_chat_members_count(chat_id) <= 10000 and filter == Filters.ALL + else filter + ) + if filter not in QUERYABLE_FILTERS: queries = [""]