mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-03-03 19:00:21 +03:00
Always support aggressive in iter_participants (#904)
This commit is contained in:
parent
7729a2a78f
commit
26f121060d
|
@ -34,14 +34,14 @@ class ChatMethods(UserMethods):
|
||||||
This has no effect for normal chats or users.
|
This has no effect for normal chats or users.
|
||||||
|
|
||||||
aggressive (`bool`, optional):
|
aggressive (`bool`, optional):
|
||||||
Aggressively looks for all participants in the chat in
|
Aggressively looks for all participants in the chat.
|
||||||
order to get more than 10,000 members (a hard limit
|
|
||||||
imposed by Telegram). Note that this might take a long
|
|
||||||
time (over 5 minutes), but is able to return over 90,000
|
|
||||||
participants on groups with 100,000 members.
|
|
||||||
|
|
||||||
This has no effect for groups or channels with less than
|
This is useful for channels since 20 July 2018,
|
||||||
10,000 members, or if a ``filter`` is given.
|
Telegram added a server-side limit where only the
|
||||||
|
first 200 members can be retrieved. With this flag
|
||||||
|
set, more than 200 will be often be retrieved.
|
||||||
|
|
||||||
|
This has no effect if a ``filter`` is given.
|
||||||
|
|
||||||
_total (`list`, optional):
|
_total (`list`, optional):
|
||||||
A single-item list to pass the total parameter by reference.
|
A single-item list to pass the total parameter by reference.
|
||||||
|
@ -76,20 +76,16 @@ class ChatMethods(UserMethods):
|
||||||
|
|
||||||
limit = float('inf') if limit is None else int(limit)
|
limit = float('inf') if limit is None else int(limit)
|
||||||
if isinstance(entity, types.InputPeerChannel):
|
if isinstance(entity, types.InputPeerChannel):
|
||||||
if _total or (aggressive and not filter):
|
|
||||||
total = (await self(functions.channels.GetFullChannelRequest(
|
|
||||||
entity
|
|
||||||
))).full_chat.participants_count
|
|
||||||
if _total:
|
if _total:
|
||||||
_total[0] = total
|
_total[0] = (await self(
|
||||||
else:
|
functions.channels.GetFullChannelRequest(entity)
|
||||||
total = 0
|
)).full_chat.participants_count
|
||||||
|
|
||||||
if limit == 0:
|
if limit == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
seen = set()
|
seen = set()
|
||||||
if total > 10000 and aggressive and not filter:
|
if aggressive and not filter:
|
||||||
requests = [functions.channels.GetParticipantsRequest(
|
requests = [functions.channels.GetParticipantsRequest(
|
||||||
channel=entity,
|
channel=entity,
|
||||||
filter=types.ChannelParticipantsSearch(search + chr(x)),
|
filter=types.ChannelParticipantsSearch(search + chr(x)),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user