Update emoji_status.py

This commit is contained in:
Yasir Aris M 2025-02-02 16:51:37 +07:00 committed by GitHub
parent 83b647e6fa
commit a4b3e3ae28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,8 +21,7 @@ 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
@ -35,6 +34,30 @@ class EmojiStatus(Object):
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.
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__( def __init__(
@ -42,12 +65,28 @@ class EmojiStatus(Object):
*, *,
client: "pyrogram.Client" = None, client: "pyrogram.Client" = None,
custom_emoji_id: int, 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) super().__init__(client)
self.custom_emoji_id = custom_emoji_id self.custom_emoji_id = custom_emoji_id
self.until_date = until_date 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 @staticmethod
def _parse(client, emoji_status: "raw.base.EmojiStatus") -> Optional["EmojiStatus"]: def _parse(client, emoji_status: "raw.base.EmojiStatus") -> Optional["EmojiStatus"]:
@ -55,13 +94,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)
) )