mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 04:35:24 +00:00
Add leave_chat method
This commit is contained in:
parent
c7f7825c92
commit
64fbcf2237
@ -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()
|
||||
)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user