Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bound methods block and unblock to User object #274

Merged
merged 2 commits into from Jul 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 48 additions & 0 deletions pyrogram/client/types/user_and_chats/user.py
Expand Up @@ -214,3 +214,51 @@ def unarchive(self):
"""

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)