Add leave_chat method

This commit is contained in:
Dan 2017-12-25 12:47:08 +01:00
parent c7f7825c92
commit 64fbcf2237

View File

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