Skip to content

Commit 34616eb

Browse files
committed
Add .archive() and .unarchive() bound methods to User
1 parent 6e3d8ca commit 34616eb

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

docs/source/api/bound-methods.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ Chat
6868
- :meth:`~Chat.archive`
6969
- :meth:`~Chat.unarchive`
7070

71+
User
72+
^^^^
73+
74+
.. hlist::
75+
:columns: 2
76+
77+
- :meth:`~User.archive`
78+
- :meth:`~User.unarchive`
79+
7180
CallbackQuery
7281
^^^^^^^^^^^^^
7382

@@ -122,6 +131,10 @@ Details
122131
.. automethod:: Chat.archive()
123132
.. automethod:: Chat.unarchive()
124133

134+
.. User
135+
.. automethod:: User.archive()
136+
.. automethod:: User.unarchive()
137+
125138
.. CallbackQuery
126139
.. automethod:: CallbackQuery.answer()
127140

pyrogram/client/types/user_and_chats/user.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,49 @@ def _parse(client, user: types.User) -> "User" or None:
160160
restriction_reason=user.restriction_reason,
161161
client=client
162162
)
163+
164+
def archive(self):
165+
"""Bound method *archive* of :obj:`User`.
166+
167+
Use as a shortcut for:
168+
169+
.. code-block:: python
170+
171+
client.archive_chats(123456789)
172+
173+
Example:
174+
.. code-block:: python
175+
176+
user.archive()
177+
178+
Returns:
179+
True on success.
180+
181+
Raises:
182+
RPCError: In case of a Telegram RPC error.
183+
"""
184+
185+
return self._client.archive_chats(self.id)
186+
187+
def unarchive(self):
188+
"""Bound method *unarchive* of :obj:`User`.
189+
190+
Use as a shortcut for:
191+
192+
.. code-block:: python
193+
194+
client.unarchive_chats(123456789)
195+
196+
Example:
197+
.. code-block:: python
198+
199+
user.unarchive()
200+
201+
Returns:
202+
True on success.
203+
204+
Raises:
205+
RPCError: In case of a Telegram RPC error.
206+
"""
207+
208+
return self._client.unarchive_chats(self.id)

0 commit comments

Comments
 (0)