mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-31 06:16:06 +00:00
Add set_emoji_status method
This commit is contained in:
@@ -252,6 +252,7 @@ def pyrogram_api():
|
|||||||
unblock_user
|
unblock_user
|
||||||
get_common_chats
|
get_common_chats
|
||||||
get_default_emoji_statuses
|
get_default_emoji_statuses
|
||||||
|
set_emoji_status
|
||||||
""",
|
""",
|
||||||
invite_links="""
|
invite_links="""
|
||||||
Invite Links
|
Invite Links
|
||||||
|
@@ -24,6 +24,7 @@ from .get_common_chats import GetCommonChats
|
|||||||
from .get_default_emoji_statuses import GetDefaultEmojiStatuses
|
from .get_default_emoji_statuses import GetDefaultEmojiStatuses
|
||||||
from .get_me import GetMe
|
from .get_me import GetMe
|
||||||
from .get_users import GetUsers
|
from .get_users import GetUsers
|
||||||
|
from .set_emoji_status import SetEmojiStatus
|
||||||
from .set_profile_photo import SetProfilePhoto
|
from .set_profile_photo import SetProfilePhoto
|
||||||
from .set_username import SetUsername
|
from .set_username import SetUsername
|
||||||
from .unblock_user import UnblockUser
|
from .unblock_user import UnblockUser
|
||||||
@@ -42,6 +43,7 @@ class Users(
|
|||||||
GetChatPhotosCount,
|
GetChatPhotosCount,
|
||||||
UnblockUser,
|
UnblockUser,
|
||||||
UpdateProfile,
|
UpdateProfile,
|
||||||
GetDefaultEmojiStatuses
|
GetDefaultEmojiStatuses,
|
||||||
|
SetEmojiStatus
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
56
pyrogram/methods/users/set_emoji_status.py
Normal file
56
pyrogram/methods/users/set_emoji_status.py
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrogram.
|
||||||
|
#
|
||||||
|
# Pyrogram is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Pyrogram is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram import raw, types
|
||||||
|
|
||||||
|
|
||||||
|
class SetEmojiStatus:
|
||||||
|
async def set_emoji_status(
|
||||||
|
self: "pyrogram.Client",
|
||||||
|
emoji_status: Optional["types.EmojiStatus"] = None
|
||||||
|
) -> bool:
|
||||||
|
"""Set the emoji status.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
emoji_status (:obj:`~pyrogram.types.EmojiStatus`, *optional*):
|
||||||
|
The emoji status to set. None to remove.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
``bool``: On success, True is returned.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from pyrogram import types
|
||||||
|
|
||||||
|
await app.set_emoji_status(types.EmojiStatus(custom_emoji_id=1234567890987654321))
|
||||||
|
"""
|
||||||
|
await self.invoke(
|
||||||
|
raw.functions.account.UpdateEmojiStatus(
|
||||||
|
emoji_status=(
|
||||||
|
emoji_status.write()
|
||||||
|
if emoji_status
|
||||||
|
else raw.types.EmojiStatusEmpty()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
@@ -64,3 +64,14 @@ class EmojiStatus(Object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def write(self):
|
||||||
|
if self.until_date:
|
||||||
|
return raw.types.EmojiStatusUntil(
|
||||||
|
document_id=self.custom_emoji_id,
|
||||||
|
until=utils.datetime_to_timestamp(self.until_date)
|
||||||
|
)
|
||||||
|
|
||||||
|
return raw.types.EmojiStatus(
|
||||||
|
document_id=self.custom_emoji_id
|
||||||
|
)
|
||||||
|
Reference in New Issue
Block a user