在电报中,当我点击订阅者时,它显示了大约50个最后的用户和大约150-200个被删除的用户。
我试过这个:
async for user in client.iter_participants(chat_id):
if user.deleted:
print(user)这只给了我最后50个用户和6-8个删除用户。我需要所有150-200个被删除的用户。我怎么弄到它们?
发布于 2021-12-20 10:07:42
我使用带有偏移参数的GetParticipantsRequest解决了这个问题,具体如下:
from telethon.tl.functions.channels import GetParticipantsRequest
from telethon.tl.types import ChannelParticipantsSearch
chat_id = -123456
offset = 0
while True:
participants = await client(GetParticipantsRequest(
channel=chat_id,
filter=ChannelParticipantsSearch(''),
offset=offset,
limit=10000,
hash=0
))
deleted_users = []
for user in participants:
if user.deleted:
deleted_users.append(user)
if not deleted_users:
break
# doings with deleted_users发布于 2021-12-20 08:29:29
不确定iter_participants,但get_participants适用于我的情况。
channel_id = -1234567890 # TODO: add channel id
users = client.get_participants(client.get_input_entity(channel_id))
for user in users:
if user.deleted:
print(user)https://stackoverflow.com/questions/70410762
复制相似问题