mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
Pyrofork: Sync emoji status with layer 198
Signed-off-by: Yasir <git@yasir.id>
This commit is contained in:
parent
e9eaa48650
commit
2923328bbb
1 changed files with 68 additions and 7 deletions
|
|
@ -21,8 +21,8 @@ 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
|
||||
|
||||
|
||||
|
|
@ -30,24 +30,64 @@ class EmojiStatus(Object):
|
|||
"""A user emoji status.
|
||||
|
||||
Parameters:
|
||||
custom_emoji_id (``int``):
|
||||
custom_emoji_id (``int``, *optional*):
|
||||
Custom emoji id.
|
||||
|
||||
until_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||
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__(
|
||||
self,
|
||||
*,
|
||||
client: "pyrogram.Client" = None,
|
||||
custom_emoji_id: int,
|
||||
until_date: Optional[datetime] = None
|
||||
custom_emoji_id: Optional[int] = 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)
|
||||
|
||||
self.custom_emoji_id = custom_emoji_id
|
||||
self.gift_id = gift_id
|
||||
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
|
||||
def _parse(client, emoji_status: "raw.base.EmojiStatus") -> Optional["EmojiStatus"]:
|
||||
|
|
@ -55,13 +95,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)
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue