From 6b9a757ce7c5b7a2db38c480a738cecd991fa639 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 25 Dec 2017 13:02:14 +0100 Subject: [PATCH] Add delete parameter to delete the chat dialog --- pyrogram/client/client.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index e32420dd..25b99627 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -959,7 +959,7 @@ class Client: ) ) - def leave_chat(self, chat_id: int or str): + def leave_chat(self, chat_id: int or str, delete: bool = False): peer = self.resolve_peer(chat_id) if isinstance(peer, types.InputPeerChannel): @@ -969,9 +969,19 @@ class Client: ) ) elif isinstance(peer, types.InputPeerChat): - return self.send( + r = self.send( functions.messages.DeleteChatUser( chat_id=peer.chat_id, user_id=types.InputPeerSelf() ) ) + + if delete: + self.send( + functions.messages.DeleteHistory( + peer=peer, + max_id=0 + ) + ) + + return r