8

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))
amir
  • 143
  • 3
  • 10
  • Question is unclear please explain more – Alen Paul Varghese Aug 29 '20 at 17:08
  • Really simple a user joined many channels and get too many channels error from a telethon script well need a script to leave all of them first get a list of all channels that he/she joined and second leave all of it – amir Aug 29 '20 at 19:41

1 Answers1

15

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()
TheKill-996
  • 953
  • 5
  • 10