From a4b3e3ae28d55ee2827a54253cb807865075d954 Mon Sep 17 00:00:00 2001 From: Yasir Aris M Date: Sun, 2 Feb 2025 16:51:37 +0700 Subject: [PATCH] Update emoji_status.py --- pyrogram/types/user_and_chats/emoji_status.py | 72 +++++++++++++++++-- 1 file changed, 66 insertions(+), 6 deletions(-) diff --git a/pyrogram/types/user_and_chats/emoji_status.py b/pyrogram/types/user_and_chats/emoji_status.py index 363d5339..ea98b065 100644 --- a/pyrogram/types/user_and_chats/emoji_status.py +++ b/pyrogram/types/user_and_chats/emoji_status.py @@ -21,8 +21,7 @@ from datetime import datetime from typing import Optional import pyrogram -from pyrogram import raw -from pyrogram import utils +from pyrogram import raw, utils from ..object import Object @@ -35,6 +34,30 @@ class EmojiStatus(Object): until_date (:py:obj:`~datetime.datetime`, *optional*): Valid until date. + + title (``str``, *optional*): + Title of the collectible. + + collectible_id (``int``, *optional*): + Collectible id. + + name (``str``, *optional*): + Name of the collectible. + + pattern_custom_emoji_id (``int``, *optional*): + Pattern emoji id. + + center_color (``int``, *optional*): + Center color of the collectible emoji in decimal format. + + edge_color (``int``, *optional*): + Edge color of the collectible emoji in decimal format. + + pattern_color (``int``, *optional*): + Pattern color of the collectible emoji in decimal format. + + text_color (``int``, *optional*): + Text color of the collectible emoji in decimal format. """ def __init__( @@ -42,12 +65,28 @@ class EmojiStatus(Object): *, client: "pyrogram.Client" = None, custom_emoji_id: int, - until_date: Optional[datetime] = None + until_date: Optional[datetime] = None, + title: Optional[str] = None, + collectible_id: Optional[int] = None, + name: Optional[str] = None, + pattern_custom_emoji_id: Optional[int] = None, + center_color: Optional[int] = None, + edge_color: Optional[int] = None, + pattern_color: Optional[int] = None, + text_color: Optional[int] = None ): super().__init__(client) self.custom_emoji_id = custom_emoji_id self.until_date = until_date + self.title = title + self.collectible_id = collectible_id + self.name = name + self.pattern_custom_emoji_id = pattern_custom_emoji_id + self.center_color = center_color + self.edge_color = edge_color + self.pattern_color = pattern_color + self.text_color = text_color @staticmethod def _parse(client, emoji_status: "raw.base.EmojiStatus") -> Optional["EmojiStatus"]: @@ -55,13 +94,34 @@ class EmojiStatus(Object): return EmojiStatus( client=client, custom_emoji_id=emoji_status.document_id, - until_date=utils.timestamp_to_datetime(emoji_status.until) if emoji_status.until else None + until_date=utils.timestamp_to_datetime(getattr(emoji_status, "until", None)) + ) + + if isinstance(emoji_status, raw.types.EmojiStatusCollectible): + return EmojiStatus( + client=client, + custom_emoji_id=emoji_status.document_id, + gift_id=emoji_status.collectible_id, + until_date=utils.timestamp_to_datetime(getattr(emoji_status, "until", None)), + title=emoji_status.title, + name=emoji_status.slug, + pattern_custom_emoji_id=emoji_status.pattern_document_id, + center_color=emoji_status.center_color, + edge_color=emoji_status.edge_color, + pattern_color=emoji_status.pattern_color, + text_color=emoji_status.text_color ) return None def write(self): + if self.gift_id: + return raw.types.InputEmojiStatusCollectible( + collectible_id=self.gift_id, + until=utils.datetime_to_timestamp(self.until_date) + ) + return raw.types.EmojiStatus( document_id=self.custom_emoji_id, - until=utils.datetime_to_timestamp(self.until_date) if self.until_date else None - ) + until=utils.datetime_to_timestamp(self.until_date) + )