skip to Main Content

In telegram when I click Subscribers it shows me about 50 last users and about 150-200 deleted users.

I tried this:

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

This gives me only last 50 users and 6-8 deleted users. I need all 150-200 deleted users. How can I get them?

2

Answers


  1. Chosen as BEST ANSWER

    I solved this problem using GetParticipantsRequest with offset parameter somehow like this:

    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
    

  2. Not sure about iter_participants, but get_participants works in my case.

    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)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search