File tree Expand file tree Collapse file tree
pyrogram/client/methods/users Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616# You should have received a copy of the GNU Lesser General Public License
1717# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818
19+ from .block_user import BlockUser
1920from .delete_profile_photos import DeleteProfilePhotos
2021from .get_me import GetMe
2122from .get_profile_photos import GetProfilePhotos
2425from .get_users import GetUsers
2526from .iter_profile_photos import IterProfilePhotos
2627from .set_profile_photo import SetProfilePhoto
28+ from .unblock_user import UnblockUser
2729from .update_username import UpdateUsername
2830
2931
3032class Users (
33+ BlockUser ,
3134 GetProfilePhotos ,
3235 SetProfilePhoto ,
3336 DeleteProfilePhotos ,
@@ -36,6 +39,7 @@ class Users(
3639 UpdateUsername ,
3740 GetProfilePhotosCount ,
3841 GetUserDC ,
39- IterProfilePhotos
42+ IterProfilePhotos ,
43+ UnblockUser
4044):
4145 pass
Original file line number Diff line number Diff line change 1+ # Pyrogram - Telegram MTProto API Client Library for Python
2+ # Copyright (C) 2017-2019 Dan Tès <https://github.com/delivrance>
3+ #
4+ # This file is part of Pyrogram.
5+ #
6+ # Pyrogram is free software: you can redistribute it and/or modify
7+ # it under the terms of the GNU Lesser General Public License as published
8+ # by the Free Software Foundation, either version 3 of the License, or
9+ # (at your option) any later version.
10+ #
11+ # Pyrogram is distributed in the hope that it will be useful,
12+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ # GNU Lesser General Public License for more details.
15+ #
16+ # You should have received a copy of the GNU Lesser General Public License
17+ # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+ from typing import Union
20+
21+ import pyrogram
22+ from pyrogram .api import functions , types
23+ from ...ext import BaseClient
24+
25+
26+ class BlockUser (BaseClient ):
27+ def block_user (
28+ self ,
29+ user_id : Union [int , str ]
30+ ) -> bool :
31+ """Block a user.
32+
33+ Returns:
34+ ``bool``: True on success
35+
36+ Raises:
37+ RPCError: In case of Telegram RPC Error.
38+ """
39+ return bool (
40+ self .send (
41+ functions .contact .Block (
42+ id = self .resolve_peer (user_id )
43+ )
44+ )
45+ )
Original file line number Diff line number Diff line change 1+ # Pyrogram - Telegram MTProto API Client Library for Python
2+ # Copyright (C) 2017-2019 Dan Tès <https://github.com/delivrance>
3+ #
4+ # This file is part of Pyrogram.
5+ #
6+ # Pyrogram is free software: you can redistribute it and/or modify
7+ # it under the terms of the GNU Lesser General Public License as published
8+ # by the Free Software Foundation, either version 3 of the License, or
9+ # (at your option) any later version.
10+ #
11+ # Pyrogram is distributed in the hope that it will be useful,
12+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ # GNU Lesser General Public License for more details.
15+ #
16+ # You should have received a copy of the GNU Lesser General Public License
17+ # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+ from typing import Union
20+
21+ import pyrogram
22+ from pyrogram .api import functions , types
23+ from ...ext import BaseClient
24+
25+
26+ class UnblockUser (BaseClient ):
27+ def unblock_user (
28+ self ,
29+ user_id : Union [int , str ]
30+ ) -> bool :
31+ """Unblock a user.
32+
33+ Returns:
34+ ``bool``: True on success
35+
36+ Raises:
37+ RPCError: In case of Telegram RPC Error.
38+ """
39+ return bool (
40+ self .send (
41+ functions .contact .Unblock (
42+ id = self .resolve_peer (user_id )
43+ )
44+ )
45+ )
You can’t perform that action at this time.
0 commit comments