Skip to content

Commit be8d106

Browse files
authored
Add join and leave methods to Chat object
1 parent 6a62d1b commit be8d106

File tree

1 file changed

+48
-0
lines changed
  • pyrogram/client/types/user_and_chats

1 file changed

+48
-0
lines changed

pyrogram/client/types/user_and_chats/chat.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,3 +673,51 @@ def promote_member(
673673
can_pin_messages=can_pin_messages,
674674
can_promote_members=can_promote_members
675675
)
676+
677+
678+
679+
680+
def join(self):
681+
"""Bound method *join* of :obj:`Chat`.
682+
683+
Use as a shortcut for:
684+
685+
.. code-block:: python
686+
687+
client.join_chat(123456789)
688+
689+
Example:
690+
.. code-block:: python
691+
692+
chat.join()
693+
694+
Returns:
695+
:obj:`Chat`: On success, a chat object is returned.
696+
697+
Raises:
698+
RPCError: In case of a Telegram RPC error.
699+
"""
700+
701+
return self._client.join_chat(self.id)
702+
703+
704+
def leave(self):
705+
"""Bound method *leave* of :obj:`Chat`.
706+
707+
Use as a shortcut for:
708+
709+
.. code-block:: python
710+
711+
client.leave_chat(123456789)
712+
713+
Example:
714+
.. code-block:: python
715+
716+
chat.leave()
717+
718+
Raises:
719+
RPCError: In case of a Telegram RPC error.
720+
"""
721+
722+
return self._client.leave_chat(self.id)
723+

0 commit comments

Comments
 (0)