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 2020from .get_me import GetMe
2121from .get_user_profile_photos import GetUserProfilePhotos
2222from .get_users import GetUsers
23+ from .set_profile_photo import SetProfilePhoto
2324
2425
2526class Users (
2627 GetUserProfilePhotos ,
28+ SetProfilePhoto ,
2729 DeleteProfilePhotos ,
2830 GetUsers ,
2931 GetMe
Original file line number Diff line number Diff line change 1+ # Pyrogram - Telegram MTProto API Client Library for Python
2+ # Copyright (C) 2017-2018 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 pyrogram .api import functions
20+ from ...ext import BaseClient
21+
22+
23+ class SetProfilePhoto (BaseClient ):
24+ def set_profile_photo (self , photo : str ):
25+ """Use this method to set a new profile photo.
26+
27+ This method only works for Users. Bots profile photos must be set using BotFather.
28+
29+ Args:
30+ photo (``str``):
31+ Profile photo to set.
32+ Pass a file path as string to upload a new photo that exists on your local machine.
33+
34+ Returns:
35+ True on success.
36+
37+ Raises:
38+ :class:`Error <pyrogram.Error>`
39+ """
40+
41+ return bool (
42+ self .send (
43+ functions .photos .UploadProfilePhoto (
44+ self .save_file (photo )
45+ )
46+ )
47+ )
You can’t perform that action at this time.
0 commit comments