From be8d1068c053a476e2264a79ae92f2a98b01b82f Mon Sep 17 00:00:00 2001 From: kalmengr <46006289+kalmengr@users.noreply.github.com> Date: Wed, 10 Jul 2019 10:39:07 -0400 Subject: [PATCH 1/2] Add join and leave methods to Chat object --- pyrogram/client/types/user_and_chats/chat.py | 48 ++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/pyrogram/client/types/user_and_chats/chat.py b/pyrogram/client/types/user_and_chats/chat.py index 586b49fe..304eb8d2 100644 --- a/pyrogram/client/types/user_and_chats/chat.py +++ b/pyrogram/client/types/user_and_chats/chat.py @@ -673,3 +673,51 @@ class Chat(Object): can_pin_messages=can_pin_messages, can_promote_members=can_promote_members ) + + + + + def join(self): + """Bound method *join* of :obj:`Chat`. + + Use as a shortcut for: + + .. code-block:: python + + client.join_chat(123456789) + + Example: + .. code-block:: python + + chat.join() + + Returns: + :obj:`Chat`: On success, a chat object is returned. + + Raises: + RPCError: In case of a Telegram RPC error. + """ + + return self._client.join_chat(self.id) + + + def leave(self): + """Bound method *leave* of :obj:`Chat`. + + Use as a shortcut for: + + .. code-block:: python + + client.leave_chat(123456789) + + Example: + .. code-block:: python + + chat.leave() + + Raises: + RPCError: In case of a Telegram RPC error. + """ + + return self._client.leave_chat(self.id) + From efe564064bd5cdff5de09e55eb0746e94c03ebd3 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Thu, 11 Jul 2019 14:29:41 +0200 Subject: [PATCH 2/2] Update chat.py --- pyrogram/client/types/user_and_chats/chat.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pyrogram/client/types/user_and_chats/chat.py b/pyrogram/client/types/user_and_chats/chat.py index 304eb8d2..ee8aacb8 100644 --- a/pyrogram/client/types/user_and_chats/chat.py +++ b/pyrogram/client/types/user_and_chats/chat.py @@ -674,9 +674,6 @@ class Chat(Object): can_promote_members=can_promote_members ) - - - def join(self): """Bound method *join* of :obj:`Chat`. @@ -700,7 +697,6 @@ class Chat(Object): return self._client.join_chat(self.id) - def leave(self): """Bound method *leave* of :obj:`Chat`.