Skip to content

Commit 5d11c03

Browse files
committed
Add set_emoji_status method
1 parent 04b343f commit 5d11c03

4 files changed

Lines changed: 71 additions & 1 deletion

File tree

compiler/docs/compiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ def get_title_list(s: str) -> list:
252252
unblock_user
253253
get_common_chats
254254
get_default_emoji_statuses
255+
set_emoji_status
255256
""",
256257
invite_links="""
257258
Invite Links

pyrogram/methods/users/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from .get_default_emoji_statuses import GetDefaultEmojiStatuses
2525
from .get_me import GetMe
2626
from .get_users import GetUsers
27+
from .set_emoji_status import SetEmojiStatus
2728
from .set_profile_photo import SetProfilePhoto
2829
from .set_username import SetUsername
2930
from .unblock_user import UnblockUser
@@ -42,6 +43,7 @@ class Users(
4243
GetChatPhotosCount,
4344
UnblockUser,
4445
UpdateProfile,
45-
GetDefaultEmojiStatuses
46+
GetDefaultEmojiStatuses,
47+
SetEmojiStatus
4648
):
4749
pass
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
from typing import Optional
20+
21+
import pyrogram
22+
from pyrogram import raw, types
23+
24+
25+
class SetEmojiStatus:
26+
async def set_emoji_status(
27+
self: "pyrogram.Client",
28+
emoji_status: Optional["types.EmojiStatus"] = None
29+
) -> bool:
30+
"""Set the emoji status.
31+
32+
Parameters:
33+
emoji_status (:obj:`~pyrogram.types.EmojiStatus`, *optional*):
34+
The emoji status to set. None to remove.
35+
36+
Returns:
37+
``bool``: On success, True is returned.
38+
39+
Example:
40+
.. code-block:: python
41+
42+
from pyrogram import types
43+
44+
await app.set_emoji_status(types.EmojiStatus(custom_emoji_id=1234567890987654321))
45+
"""
46+
await self.invoke(
47+
raw.functions.account.UpdateEmojiStatus(
48+
emoji_status=(
49+
emoji_status.write()
50+
if emoji_status
51+
else raw.types.EmojiStatusEmpty()
52+
)
53+
)
54+
)
55+
56+
return True

pyrogram/types/user_and_chats/emoji_status.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,14 @@ def _parse(client, emoji_status: "raw.base.EmojiStatus") -> Optional["EmojiStatu
6464
)
6565

6666
return None
67+
68+
def write(self):
69+
if self.until_date:
70+
return raw.types.EmojiStatusUntil(
71+
document_id=self.custom_emoji_id,
72+
until=utils.datetime_to_timestamp(self.until_date)
73+
)
74+
75+
return raw.types.EmojiStatus(
76+
document_id=self.custom_emoji_id
77+
)

0 commit comments

Comments
 (0)