leave_chat()

Client.leave_chat()

Leave a group chat or channel.

Usable by Users Bots
Parameters:
  • chat_id (``int`` | ``str``) – Unique identifier for the target chat or username of the target channel/supergroup (in the format @username).

  • delete (``bool``, *optional*) – Deletes the group chat dialog after leaving (for simple group chats, not supergroups). Defaults to False.

Example

# Leave chat or channel
await app.leave_chat(chat_id)

# Leave basic chat and also delete the dialog
await app.leave_chat(chat_id, delete=True)