How to leave private group on telegram with Python

603 views Asked by At

The following code is for joining a group on telegram:

from telethon.sync import TelegramClient
from telethon import functions, types

with TelegramClient(name, api_id, api_hash) as client:
    result = client(functions.messages.ImportChatInviteRequest(
        hash='A4LmkR23G0IGxBE71zZfo1'
    ))
    print(result.stringify())

How to leave that group after the work is done?

1

There are 1 answers

0
sabby On

You could use client.delete_dialog

await client.delete_dialog('username')
# can accept chat ID too