Skip to content

Commit

Permalink
Add fallback parameter to set_profile_photo method.
Browse files Browse the repository at this point in the history
Signed-off-by: Aliwoto <[email protected]>
  • Loading branch information
ALiwoto committed Mar 26, 2024
1 parent 625f91a commit 79cbad9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pyrogram/methods/users/set_profile_photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# 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 typing import Union, BinaryIO
from typing import Union, BinaryIO, Optional

import pyrogram
from pyrogram import raw
Expand All @@ -26,6 +26,7 @@ class SetProfilePhoto:
async def set_profile_photo(
self: "pyrogram.Client",
*,
fallback: Optional[bool] = None,
photo: Union[str, BinaryIO] = None,
video: Union[str, BinaryIO] = None
) -> bool:
Expand All @@ -42,6 +43,11 @@ async def set_profile_photo(
.. include:: /_includes/usable-by/users.rst
Parameters:
fallback (``bool``, *optional*):
If set to True, the chosen profile photo will be shown to users that can't display
your main profile photo due to your privacy settings.
Defaults to None.
photo (``str`` | ``BinaryIO``, *optional*):
Profile photo to set.
Pass a file path as string to upload a new photo that exists on your local machine or
Expand All @@ -61,13 +67,17 @@ async def set_profile_photo(
# Set a new profile photo
await app.set_profile_photo(photo="new_photo.jpg")
# Set/update your account's public profile photo
await app.set_profile_photo(fallback=True, photo="new_photo.jpg")
# Set a new profile video
await app.set_profile_photo(video="new_video.mp4")
"""

return bool(
await self.invoke(
raw.functions.photos.UploadProfilePhoto(
fallback=fallback,
file=await self.save_file(photo),
video=await self.save_file(video)
)
Expand Down

0 comments on commit 79cbad9

Please sign in to comment.