From 9a8057074bacbd1983c379b30a447808f52ee3af Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 26 Jul 2020 23:18:26 +0200 Subject: [PATCH] Allow uploading profile photos using file-like objects --- pyrogram/client/methods/users/set_profile_photo.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyrogram/client/methods/users/set_profile_photo.py b/pyrogram/client/methods/users/set_profile_photo.py index ae627110..e7357030 100644 --- a/pyrogram/client/methods/users/set_profile_photo.py +++ b/pyrogram/client/methods/users/set_profile_photo.py @@ -18,22 +18,26 @@ from pyrogram.api import functions from ...ext import BaseClient +from typing import Union, BinaryIO class SetProfilePhoto(BaseClient): def set_profile_photo( self, - photo: str + photo: Union[str, BinaryIO] ) -> bool: """Set a new profile photo. + If you want to set a profile video instead, use :meth:`~Client.set_profile_video` + This method only works for Users. Bots profile photos must be set using BotFather. Parameters: photo (``str``): Profile photo to set. - Pass a file path as string to upload a new photo that exists on your local machine. + Pass a file path as string to upload a new photo that exists on your local machine or + pass a binary file-like object with its attribute ".name" set for in-memory uploads. Returns: ``bool``: True on success.