Pyrofork: Sync emoji status with layer 198

Signed-off-by: Yasir <git@yasir.id>
This commit is contained in:
KurimuzonAkuma 2025-02-02 17:03:13 +07:00 committed by Yasir
parent e9eaa48650
commit 2923328bbb

View file

@ -21,8 +21,8 @@ from datetime import datetime
from typing import Optional from typing import Optional
import pyrogram import pyrogram
from pyrogram import raw from pyrogram import raw, utils
from pyrogram import utils
from ..object import Object from ..object import Object
@ -30,24 +30,64 @@ class EmojiStatus(Object):
"""A user emoji status. """A user emoji status.
Parameters: Parameters:
custom_emoji_id (``int``): custom_emoji_id (``int``, *optional*):
Custom emoji id. Custom emoji id.
until_date (:py:obj:`~datetime.datetime`, *optional*): until_date (:py:obj:`~datetime.datetime`, *optional*):
Valid until date. Valid until date.
title (``str``, *optional*):
Title of the collectible.
gift_id (``int``, *optional*):
Gift 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__( def __init__(
self, self,
*, *,
client: "pyrogram.Client" = None, client: "pyrogram.Client" = None,
custom_emoji_id: int, custom_emoji_id: Optional[int] = None,
until_date: Optional[datetime] = None gift_id: Optional[int] = None,
until_date: Optional[datetime] = None,
title: Optional[str] = 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) super().__init__(client)
self.custom_emoji_id = custom_emoji_id self.custom_emoji_id = custom_emoji_id
self.gift_id = gift_id
self.until_date = until_date self.until_date = until_date
self.title = title
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 @staticmethod
def _parse(client, emoji_status: "raw.base.EmojiStatus") -> Optional["EmojiStatus"]: def _parse(client, emoji_status: "raw.base.EmojiStatus") -> Optional["EmojiStatus"]:
@ -55,13 +95,34 @@ class EmojiStatus(Object):
return EmojiStatus( return EmojiStatus(
client=client, client=client,
custom_emoji_id=emoji_status.document_id, 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 return None
def write(self): 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( return raw.types.EmojiStatus(
document_id=self.custom_emoji_id, 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)
) )