Skip to content

Commit

Permalink
pyrofork: Add emoji and emoji_background parameters to set_profile_ph…
Browse files Browse the repository at this point in the history
…oto method

Signed-off-by: wulan17 <wulan17@nusantararom.org>
  • Loading branch information
wulan17 committed Sep 7, 2024
1 parent c2cd506 commit f7e1f21
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pyrogram/methods/users/set_profile_photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ async def set_profile_photo(
self: "pyrogram.Client",
*,
photo: Union[str, BinaryIO] = None,
emoji: int = None,
emoji_background: Union[int, list[int]] = None,
video: Union[str, BinaryIO] = None
) -> bool:
"""Set a new profile photo or video (H.264/MPEG-4 AVC video, max 5 seconds).
Expand All @@ -48,6 +50,12 @@ async def set_profile_photo(
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.
emoji (``int``, *optional*):
Unique identifier (int) of the emoji to be used as the profile photo.
emoji_background (``int`` | ``List[int]``, *optional*):
hexadecimal colors or List of hexadecimal colors to be used as the chat photo background.
video (``str`` | ``BinaryIO``, *optional*):
Profile video to set.
Pass a file path as string to upload a new video that exists on your local machine or
Expand All @@ -66,10 +74,21 @@ async def set_profile_photo(
await app.set_profile_photo(video="new_video.mp4")
"""

emoji_id = None
if emoji:
background_colors = emoji_background if emoji_background is not None else [0xFFFFFF]
if isinstance(background_colors, int):
background_colors = [background_colors]
emoji_id = raw.types.VideoSizeEmojiMarkup(
emoji_id=emoji,
background_colors=background_colors
)

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

0 comments on commit f7e1f21

Please sign in to comment.