diff --git a/docs/source/pyrogram/Client.rst b/docs/source/pyrogram/Client.rst index 1cd1a072..72844987 100644 --- a/docs/source/pyrogram/Client.rst +++ b/docs/source/pyrogram/Client.rst @@ -96,7 +96,8 @@ Users get_me get_users get_user_profile_photos - delete_profile_photos + set_user_profile_photos + delete_userprofile_photos Contacts -------- diff --git a/pyrogram/client/methods/users/__init__.py b/pyrogram/client/methods/users/__init__.py index f7c32b3b..11f51d19 100644 --- a/pyrogram/client/methods/users/__init__.py +++ b/pyrogram/client/methods/users/__init__.py @@ -16,15 +16,17 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from .delete_profile_photos import DeleteProfilePhotos +from .delete_user_profile_photos import DeleteUserProfilePhotos from .get_me import GetMe from .get_user_profile_photos import GetUserProfilePhotos from .get_users import GetUsers +from .set_user_profile_photo import SetUserProfilePhoto class Users( GetUserProfilePhotos, - DeleteProfilePhotos, + SetUserProfilePhoto, + DeleteUserProfilePhotos, GetUsers, GetMe ): diff --git a/pyrogram/client/methods/users/delete_profile_photos.py b/pyrogram/client/methods/users/delete_user_profile_photos.py similarity index 94% rename from pyrogram/client/methods/users/delete_profile_photos.py rename to pyrogram/client/methods/users/delete_user_profile_photos.py index 47a6682a..58c2deb4 100644 --- a/pyrogram/client/methods/users/delete_profile_photos.py +++ b/pyrogram/client/methods/users/delete_user_profile_photos.py @@ -23,8 +23,8 @@ from pyrogram.api import functions, types from ...ext import BaseClient -class DeleteProfilePhotos(BaseClient): - def delete_profile_photos(self, id: str or list): +class DeleteUserProfilePhotos(BaseClient): + def delete_user_profile_photos(self, id: str or list): """Use this method to delete your own profile photos Args: diff --git a/pyrogram/client/methods/users/set_user_profile_photo.py b/pyrogram/client/methods/users/set_user_profile_photo.py new file mode 100644 index 00000000..b107a968 --- /dev/null +++ b/pyrogram/client/methods/users/set_user_profile_photo.py @@ -0,0 +1,48 @@ +# Pyrogram - Telegram MTProto API Client Library for Python +# Copyright (C) 2017-2018 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 pyrogram.api import functions +from ...ext import BaseClient + + +class SetUserProfilePhoto(BaseClient): + def set_user_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 ` + """ + + return bool( + self.send( + functions.photos.UploadProfilePhoto( + self.save_file(photo) + ) + ) + )