Add .archive() and .unarchive() bound methods to User

This commit is contained in:
Dan 2019-06-08 19:29:55 +02:00
parent 6e3d8ca20b
commit 34616ebf61
2 changed files with 59 additions and 0 deletions

View File

@ -68,6 +68,15 @@ Chat
- :meth:`~Chat.archive`
- :meth:`~Chat.unarchive`
User
^^^^
.. hlist::
:columns: 2
- :meth:`~User.archive`
- :meth:`~User.unarchive`
CallbackQuery
^^^^^^^^^^^^^
@ -122,6 +131,10 @@ Details
.. automethod:: Chat.archive()
.. automethod:: Chat.unarchive()
.. User
.. automethod:: User.archive()
.. automethod:: User.unarchive()
.. CallbackQuery
.. automethod:: CallbackQuery.answer()

View File

@ -160,3 +160,49 @@ class User(Object):
restriction_reason=user.restriction_reason,
client=client
)
def archive(self):
"""Bound method *archive* of :obj:`User`.
Use as a shortcut for:
.. code-block:: python
client.archive_chats(123456789)
Example:
.. code-block:: python
user.archive()
Returns:
True on success.
Raises:
RPCError: In case of a Telegram RPC error.
"""
return self._client.archive_chats(self.id)
def unarchive(self):
"""Bound method *unarchive* of :obj:`User`.
Use as a shortcut for:
.. code-block:: python
client.unarchive_chats(123456789)
Example:
.. code-block:: python
user.unarchive()
Returns:
True on success.
Raises:
RPCError: In case of a Telegram RPC error.
"""
return self._client.unarchive_chats(self.id)