diff --git a/pyrogram/client/methods/users/__init__.py b/pyrogram/client/methods/users/__init__.py index 20b50ce9..f30245d7 100644 --- a/pyrogram/client/methods/users/__init__.py +++ b/pyrogram/client/methods/users/__init__.py @@ -16,6 +16,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . +from .block_user import BlockUser from .delete_profile_photos import DeleteProfilePhotos from .get_me import GetMe from .get_profile_photos import GetProfilePhotos @@ -24,10 +25,12 @@ from .get_user_dc import GetUserDC from .get_users import GetUsers from .iter_profile_photos import IterProfilePhotos from .set_profile_photo import SetProfilePhoto +from .unblock_user import UnblockUser from .update_username import UpdateUsername class Users( + BlockUser, GetProfilePhotos, SetProfilePhoto, DeleteProfilePhotos, @@ -36,6 +39,7 @@ class Users( UpdateUsername, GetProfilePhotosCount, GetUserDC, - IterProfilePhotos + IterProfilePhotos, + UnblockUser ): pass diff --git a/pyrogram/client/methods/users/block_user.py b/pyrogram/client/methods/users/block_user.py new file mode 100644 index 00000000..1b4cc31a --- /dev/null +++ b/pyrogram/client/methods/users/block_user.py @@ -0,0 +1,45 @@ +# Pyrogram - Telegram MTProto API Client Library for Python +# Copyright (C) 2017-2019 Dan Tès +# +# This file is part of Pyrogram. +# +# Pyrogram is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrogram is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrogram. If not, see . + +from typing import Union + +import pyrogram +from pyrogram.api import functions, types +from ...ext import BaseClient + + +class BlockUser(BaseClient): + def block_user( + self, + user_id: Union[int, str] + ) -> bool: + """Block a user. + + Returns: + ``bool``: True on success + + Raises: + RPCError: In case of Telegram RPC Error. + """ + return bool( + self.send( + functions.contact.Block( + id=self.resolve_peer(user_id) + ) + ) + ) diff --git a/pyrogram/client/methods/users/unblock_user.py b/pyrogram/client/methods/users/unblock_user.py new file mode 100644 index 00000000..b2212762 --- /dev/null +++ b/pyrogram/client/methods/users/unblock_user.py @@ -0,0 +1,45 @@ +# Pyrogram - Telegram MTProto API Client Library for Python +# Copyright (C) 2017-2019 Dan Tès +# +# This file is part of Pyrogram. +# +# Pyrogram is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrogram is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrogram. If not, see . + +from typing import Union + +import pyrogram +from pyrogram.api import functions, types +from ...ext import BaseClient + + +class UnblockUser(BaseClient): + def unblock_user( + self, + user_id: Union[int, str] + ) -> bool: + """Unblock a user. + + Returns: + ``bool``: True on success + + Raises: + RPCError: In case of Telegram RPC Error. + """ + return bool( + self.send( + functions.contact.Unblock( + id=self.resolve_peer(user_id) + ) + ) + )