From 856870c195e72ab57b9d3f1248a35e03b2704bfa Mon Sep 17 00:00:00 2001 From: kalmengr <46006289+kalmengr@users.noreply.github.com> Date: Tue, 9 Jul 2019 17:33:41 -0400 Subject: [PATCH 1/2] Add bound methods block and unblock to User object --- pyrogram/client/types/user_and_chats/user.py | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/pyrogram/client/types/user_and_chats/user.py b/pyrogram/client/types/user_and_chats/user.py index 248c4c0a..c8041cb9 100644 --- a/pyrogram/client/types/user_and_chats/user.py +++ b/pyrogram/client/types/user_and_chats/user.py @@ -214,3 +214,38 @@ class User(Object): """ return self._client.unarchive_chats(self.id) + + + def block(self): + """Bound method *block* of :obj:`User`. + Use as a shortcut for: + .. code-block:: python + client.block_user(123456789) + Example: + .. code-block:: python + user.block() + Returns: + True on success. + Raises: + RPCError: In case of a Telegram RPC error. + """ + + return self._client.block_user(self.id) + + + def unblock(self): + """Bound method *unblock* of :obj:`User`. + Use as a shortcut for: + .. code-block:: python + client.unblock_user(123456789) + Example: + .. code-block:: python + user.unblock() + Returns: + True on success. + Raises: + RPCError: In case of a Telegram RPC error. + """ + + return self._client.unblock_user(self.id) + From 92d47f17f3142f003397822fdd338e92ee1f1e5e Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 9 Jul 2019 23:39:48 +0200 Subject: [PATCH 2/2] Add new blank lines for clarity and for fixing rst --- pyrogram/client/types/user_and_chats/user.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pyrogram/client/types/user_and_chats/user.py b/pyrogram/client/types/user_and_chats/user.py index c8041cb9..9cdd9760 100644 --- a/pyrogram/client/types/user_and_chats/user.py +++ b/pyrogram/client/types/user_and_chats/user.py @@ -215,17 +215,23 @@ class User(Object): return self._client.unarchive_chats(self.id) - def block(self): """Bound method *block* of :obj:`User`. + Use as a shortcut for: + .. code-block:: python + client.block_user(123456789) + Example: .. code-block:: python + user.block() + Returns: True on success. + Raises: RPCError: In case of a Telegram RPC error. """ @@ -235,14 +241,21 @@ class User(Object): def unblock(self): """Bound method *unblock* of :obj:`User`. + Use as a shortcut for: + .. code-block:: python + client.unblock_user(123456789) + Example: .. code-block:: python + user.unblock() + Returns: True on success. + Raises: RPCError: In case of a Telegram RPC error. """