mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +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
|
from typing import Union, Generator
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
|
from pyrogram.api import types
|
||||||
from ...ext import BaseClient
|
from ...ext import BaseClient
|
||||||
|
|
||||||
|
|
||||||
@ -82,6 +83,7 @@ class IterChatMembers(BaseClient):
|
|||||||
queries = [query] if query else QUERIES
|
queries = [query] if query else QUERIES
|
||||||
total = limit or (1 << 31) - 1
|
total = limit or (1 << 31) - 1
|
||||||
limit = min(200, total)
|
limit = min(200, total)
|
||||||
|
resolved_chat_id = self.resolve_peer(chat_id)
|
||||||
|
|
||||||
filter = (
|
filter = (
|
||||||
Filters.RECENT
|
Filters.RECENT
|
||||||
@ -107,6 +109,9 @@ class IterChatMembers(BaseClient):
|
|||||||
if not chat_members:
|
if not chat_members:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if isinstance(resolved_chat_id, types.InputPeerChat):
|
||||||
|
total = len(chat_members)
|
||||||
|
|
||||||
offset += len(chat_members)
|
offset += len(chat_members)
|
||||||
|
|
||||||
for chat_member in chat_members:
|
for chat_member in chat_members:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user