amir
amir

Reputation: 183

How to get list of channels that i joined in telethon?

I want to make a script that shows the channels that i joined and then leave all of it with this example:

from telethon.tl.functions.channels import LeaveChannelRequest
await client(LeaveChannelRequest(input_channel))

Upvotes: 11

Views: 12128

Answers (1)

TheKill-996
TheKill-996

Reputation: 1069

In order to leave all the channels you're in, you have to fetch all the channels from the dialogs list and then just delete them. Here is a snippet.

async for dialog in client.iter_dialogs():
    if not dialog.is_group and dialog.is_channel:
        await dialog.delete()

Upvotes: 17

Related Questions