2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 05:18:10 +00:00

Add set_profile_photo method

This commit is contained in:
Dan 2018-10-15 11:03:07 +02:00
parent 474388d8a4
commit 93018a7f6c
2 changed files with 49 additions and 0 deletions

View File

@ -20,10 +20,12 @@ from .delete_profile_photos import DeleteProfilePhotos
from .get_me import GetMe
from .get_user_profile_photos import GetUserProfilePhotos
from .get_users import GetUsers
from .set_profile_photo import SetProfilePhoto
class Users(
GetUserProfilePhotos,
SetProfilePhoto,
DeleteProfilePhotos,
GetUsers,
GetMe

View File

@ -0,0 +1,47 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# 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 <http://www.gnu.org/licenses/>.
from pyrogram.api import functions
from ...ext import BaseClient
class SetProfilePhoto(BaseClient):
def set_profile_photo(self, photo: str):
"""Use this method to set a new profile photo.
This method only works for Users. Bots profile photos must be set using BotFather.
Args:
photo (``str``):
Profile photo to set.
Pass a file path as string to upload a new photo that exists on your local machine.
Returns:
True on success.
Raises:
:class:`Error <pyrogram.Error>`
"""
return bool(
self.send(
functions.photos.UploadProfilePhoto(
self.save_file(photo)
)
)
)