如何使用python在电报中留下私人小组

问题描述

此电报加入组代码

但是工作完成后如何离开该小组

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())

解决方法

您可以使用client.delete_dialog

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