Update iter_chat_members efficiency

This commit is contained in:
Dan 2019-01-24 17:21:41 +01:00
parent c0a5b0a2c3
commit 44deabf399
2 changed files with 9 additions and 1 deletions

View File

@ -126,3 +126,6 @@ class BaseClient:
def get_chat_members(self, *args, **kwargs):
pass
def get_chat_members_count(self, *args, **kwargs):
pass

View File

@ -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 = [""]