pyrofork: Add emoji and emoji_background parameters to set_profile_photo method

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2024-09-07 19:10:46 +07:00
parent c2cd506be9
commit f7e1f214c6
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5

View file

@ -28,6 +28,8 @@ class SetProfilePhoto:
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).
@ -48,6 +50,12 @@ class SetProfilePhoto:
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
@ -66,10 +74,21 @@ class SetProfilePhoto:
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)
)
)