Skip to content

Commit c71a6c2

Browse files
committed
fix: chnage EmojiStatusUntil to EmojiStatusCollectible
1 parent dd3e77d commit c71a6c2

2 files changed

Lines changed: 70 additions & 17 deletions

File tree

.github/workflows/check_api_updates.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ jobs:
6767
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6868
run: |
6969
BRANCH_NAME="update/mtproto-api-updates"
70-
70+
7171
# Check if there's an open PR for this branch
7272
PR_NUMBER=$(gh pr list --head "$BRANCH_NAME" --state open --json number -q '.[0].number')
73-
73+
7474
if [ -n "$PR_NUMBER" ]; then
7575
echo "existing_pr=true" >> $GITHUB_OUTPUT
7676
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
@@ -119,14 +119,14 @@ jobs:
119119
run: |
120120
LAYER_VERSION="${{ steps.check-updates.outputs.layer_version }}"
121121
BRANCH_NAME="update/mtproto-api-updates"
122-
122+
123123
# Create a new branch based on the current main branch
124124
git checkout -b $BRANCH_NAME-temp origin/main
125-
125+
126126
# Add the changes and commit
127127
git add compiler/api/source/main_api.tl hydrogram/raw/ hydrogram/errors/ news/
128128
git commit -m "Update MTProto API schema to Layer ${LAYER_VERSION}"
129-
129+
130130
# Force push to update the branch
131131
git push --force origin $BRANCH_NAME-temp:$BRANCH_NAME
132132
@@ -157,8 +157,8 @@ jobs:
157157
PR_NUMBER="${{ steps.check-pr.outputs.pr_number }}"
158158
PR_TITLE="Update MTProto API schema"
159159
PR_BODY="This PR automatically updates the MTProto API schema to Layer ${LAYER_VERSION}.\n\n- Updated main schema file\n- Recompiled raw and errors modules\n- Created news entry for changelog"
160-
160+
161161
gh pr edit $PR_NUMBER --title "$PR_TITLE" --body "$PR_BODY"
162-
162+
163163
PR_COMMENT="Updated the MTProto API schema to Layer ${LAYER_VERSION}.\n\n- Updated main schema file\n- Recompiled raw and errors modules\n- Added new news entry for changelog"
164164
gh pr comment $PR_NUMBER --body "$PR_COMMENT"

hydrogram/types/user_and_chats/emoji_status.py

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,44 +33,97 @@ class EmojiStatus(Object):
3333
"""A user emoji status.
3434
3535
Parameters:
36-
custom_emoji_id (``int``):
36+
custom_emoji_id (``int``, *optional*):
3737
Custom emoji id.
3838
3939
until_date (:py:obj:`~datetime.datetime`, *optional*):
4040
Valid until date.
41+
42+
title (``str``, *optional*):
43+
Title of the collectible.
44+
45+
gift_id (``int``, *optional*):
46+
Gift collectible id.
47+
48+
name (``str``, *optional*):
49+
Name of the collectible.
50+
51+
pattern_custom_emoji_id (``int``, *optional*):
52+
Pattern emoji id.
53+
54+
center_color (``int``, *optional*):
55+
Center color of the collectible emoji in decimal format.
56+
57+
edge_color (``int``, *optional*):
58+
Edge color of the collectible emoji in decimal format.
59+
60+
pattern_color (``int``, *optional*):
61+
Pattern color of the collectible emoji in decimal format.
62+
63+
text_color (``int``, *optional*):
64+
Text color of the collectible emoji in decimal format.
4165
"""
4266

4367
def __init__(
4468
self,
4569
*,
4670
client: hydrogram.Client = None,
47-
custom_emoji_id: int,
71+
custom_emoji_id: int | None = None,
72+
gift_id: int | None = None,
4873
until_date: datetime | None = None,
74+
title: str | None = None,
75+
name: str | None = None,
76+
pattern_custom_emoji_id: int | None = None,
77+
center_color: int | None = None,
78+
edge_color: int | None = None,
79+
pattern_color: int | None = None,
80+
text_color: int | None = None,
4981
):
5082
super().__init__(client)
5183

5284
self.custom_emoji_id = custom_emoji_id
85+
self.gift_id = gift_id
5386
self.until_date = until_date
87+
self.title = title
88+
self.name = name
89+
self.pattern_custom_emoji_id = pattern_custom_emoji_id
90+
self.center_color = center_color
91+
self.edge_color = edge_color
92+
self.pattern_color = pattern_color
93+
self.text_color = text_color
5494

5595
@staticmethod
5696
def _parse(client, emoji_status: raw.base.EmojiStatus) -> EmojiStatus | None:
5797
if isinstance(emoji_status, raw.types.EmojiStatus):
58-
return EmojiStatus(client=client, custom_emoji_id=emoji_status.document_id)
98+
return EmojiStatus(
99+
client=client,
100+
custom_emoji_id=emoji_status.document_id,
101+
until_date=utils.timestamp_to_datetime(getattr(emoji_status, "until", None)),
102+
)
59103

60-
if isinstance(emoji_status, raw.types.EmojiStatusUntil):
104+
if isinstance(emoji_status, raw.types.EmojiStatusCollectible):
61105
return EmojiStatus(
62106
client=client,
63107
custom_emoji_id=emoji_status.document_id,
64-
until_date=utils.timestamp_to_datetime(emoji_status.until),
108+
gift_id=emoji_status.collectible_id,
109+
until_date=utils.timestamp_to_datetime(getattr(emoji_status, "until", None)),
110+
title=emoji_status.title,
111+
name=emoji_status.slug,
112+
pattern_custom_emoji_id=emoji_status.pattern_document_id,
113+
center_color=emoji_status.center_color,
114+
edge_color=emoji_status.edge_color,
115+
pattern_color=emoji_status.pattern_color,
116+
text_color=emoji_status.text_color,
65117
)
66118

67119
return None
68120

69121
def write(self):
70-
if self.until_date:
71-
return raw.types.EmojiStatusUntil(
72-
document_id=self.custom_emoji_id,
73-
until=utils.datetime_to_timestamp(self.until_date),
122+
if self.gift_id:
123+
return raw.types.InputEmojiStatusCollectible(
124+
collectible_id=self.gift_id, until=utils.datetime_to_timestamp(self.until_date)
74125
)
75126

76-
return raw.types.EmojiStatus(document_id=self.custom_emoji_id)
127+
return raw.types.EmojiStatus(
128+
document_id=self.custom_emoji_id, until=utils.datetime_to_timestamp(self.until_date)
129+
)

0 commit comments

Comments
 (0)