From 34616ebf613802c767e78a6b5404684e41060d00 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 8 Jun 2019 19:29:55 +0200 Subject: [PATCH] Add .archive() and .unarchive() bound methods to User --- docs/source/api/bound-methods.rst | 13 ++++++ pyrogram/client/types/user_and_chats/user.py | 46 ++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/docs/source/api/bound-methods.rst b/docs/source/api/bound-methods.rst index ac348d03..d01a4383 100644 --- a/docs/source/api/bound-methods.rst +++ b/docs/source/api/bound-methods.rst @@ -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() diff --git a/pyrogram/client/types/user_and_chats/user.py b/pyrogram/client/types/user_and_chats/user.py index 50dd8361..05877b63 100644 --- a/pyrogram/client/types/user_and_chats/user.py +++ b/pyrogram/client/types/user_and_chats/user.py @@ -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)