如何从频道(电视节目)中删除用户?

How to get deleted users from channel (telethon)?

在电报中,当我单击“订阅者”时,它显示了大约 50 个最后的用户和大约 150-200 个已删除的用户。

我试过这个:

async for user in client.iter_participants(chat_id):
    if user.deleted:
        print(user)

这只给我最后 50 个用户和 6-8 个已删除的用户。我需要所有 150-200 个已删除的用户。我怎样才能得到它们?

不确定 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)

我使用带有偏移参数的 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