Add delete parameter to delete the chat dialog

This commit is contained in:
Dan 2017-12-25 13:02:14 +01:00
parent 924302aed5
commit 6b9a757ce7

View File

@ -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) peer = self.resolve_peer(chat_id)
if isinstance(peer, types.InputPeerChannel): if isinstance(peer, types.InputPeerChannel):
@ -969,9 +969,19 @@ class Client:
) )
) )
elif isinstance(peer, types.InputPeerChat): elif isinstance(peer, types.InputPeerChat):
return self.send( r = self.send(
functions.messages.DeleteChatUser( functions.messages.DeleteChatUser(
chat_id=peer.chat_id, chat_id=peer.chat_id,
user_id=types.InputPeerSelf() user_id=types.InputPeerSelf()
) )
) )
if delete:
self.send(
functions.messages.DeleteHistory(
peer=peer,
max_id=0
)
)
return r