mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Allow uploading profile photos using file-like objects
This commit is contained in:
parent
aaedeffff9
commit
9a8057074b
@ -18,22 +18,26 @@
|
|||||||
|
|
||||||
from pyrogram.api import functions
|
from pyrogram.api import functions
|
||||||
from ...ext import BaseClient
|
from ...ext import BaseClient
|
||||||
|
from typing import Union, BinaryIO
|
||||||
|
|
||||||
|
|
||||||
class SetProfilePhoto(BaseClient):
|
class SetProfilePhoto(BaseClient):
|
||||||
def set_profile_photo(
|
def set_profile_photo(
|
||||||
self,
|
self,
|
||||||
photo: str
|
photo: Union[str, BinaryIO]
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Set a new profile photo.
|
"""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.
|
This method only works for Users.
|
||||||
Bots profile photos must be set using BotFather.
|
Bots profile photos must be set using BotFather.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
photo (``str``):
|
photo (``str``):
|
||||||
Profile photo to set.
|
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:
|
Returns:
|
||||||
``bool``: True on success.
|
``bool``: True on success.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user