Allow uploading profile photos using file-like objects

This commit is contained in:
Dan 2020-07-26 23:18:26 +02:00
parent aaedeffff9
commit 9a8057074b

View File

@ -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.