Skip to content

Commit 6e3d8ca

Browse files
committed
Add .archive() and .unarchive() bound methods to Chat
1 parent 9b12e82 commit 6e3d8ca

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

docs/source/api/bound-methods.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ Message
5959
- :meth:`~Message.reply_video_note`
6060
- :meth:`~Message.reply_voice`
6161

62+
Chat
63+
^^^^
64+
65+
.. hlist::
66+
:columns: 2
67+
68+
- :meth:`~Chat.archive`
69+
- :meth:`~Chat.unarchive`
70+
6271
CallbackQuery
6372
^^^^^^^^^^^^^
6473

@@ -109,6 +118,10 @@ Details
109118
.. automethod:: Message.reply_video_note()
110119
.. automethod:: Message.reply_voice()
111120

121+
.. Chat
122+
.. automethod:: Chat.archive()
123+
.. automethod:: Chat.unarchive()
124+
112125
.. CallbackQuery
113126
.. automethod:: CallbackQuery.answer()
114127

pyrogram/client/types/user_and_chats/chat.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,3 +257,49 @@ def _parse_chat(client, chat: Union[types.Chat, types.User, types.Channel]) -> "
257257
return Chat._parse_user_chat(client, chat)
258258
else:
259259
return Chat._parse_channel_chat(client, chat)
260+
261+
def archive(self):
262+
"""Bound method *archive* of :obj:`Chat`.
263+
264+
Use as a shortcut for:
265+
266+
.. code-block:: python
267+
268+
client.archive_chats(-100123456789)
269+
270+
Example:
271+
.. code-block:: python
272+
273+
chat.archive()
274+
275+
Returns:
276+
True on success.
277+
278+
Raises:
279+
RPCError: In case of a Telegram RPC error.
280+
"""
281+
282+
return self._client.archive_chats(self.id)
283+
284+
def unarchive(self):
285+
"""Bound method *unarchive* of :obj:`Chat`.
286+
287+
Use as a shortcut for:
288+
289+
.. code-block:: python
290+
291+
client.unarchive_chats(-100123456789)
292+
293+
Example:
294+
.. code-block:: python
295+
296+
chat.unarchive()
297+
298+
Returns:
299+
True on success.
300+
301+
Raises:
302+
RPCError: In case of a Telegram RPC error.
303+
"""
304+
305+
return self._client.unarchive_chats(self.id)

0 commit comments

Comments
 (0)