From 64fbcf223762d5e38c2aa6e0efb8ec6972bd649f Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 25 Dec 2017 12:47:08 +0100 Subject: [PATCH] Add leave_chat method --- pyrogram/client/client.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 526062e7..b252b8d6 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -962,3 +962,20 @@ class Client: channel=channel ) ) + + def leave_chat(self, chat_id: int or str): + peer = self.resolve_peer(chat_id) + + if isinstance(peer, types.InputPeerChannel): + return self.send( + functions.channels.LeaveChannel( + channel=self.resolve_peer(chat_id) + ) + ) + elif isinstance(peer, types.InputPeerChat): + return self.send( + functions.messages.DeleteChatUser( + chat_id=peer.chat_id, + user_id=types.InputPeerSelf() + ) + )