mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Fix flood waits generated when iterating over basic chat members
This commit is contained in:
parent
6d00e9cfd8
commit
90b959555d
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user