1616# You should have received a copy of the GNU Lesser General Public License
1717# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818
19- from typing import Optional
19+ from typing import Optional , Union
2020
2121import pyrogram
2222from pyrogram import raw , types
2525class SetEmojiStatus :
2626 async def set_emoji_status (
2727 self : "pyrogram.Client" ,
28+ chat_id : Optional [Union [int , str ]] = None ,
2829 emoji_status : Optional ["types.EmojiStatus" ] = None
2930 ) -> bool :
3031 """Set the emoji status.
3132
33+ .. note::
34+
35+ For Telegram Premium users only.
36+
3237 .. include:: /_includes/usable-by/users.rst
3338
3439 Parameters:
40+ chat_id (``int`` | ``str``):
41+ Unique identifier (int) or username (str) of the target chat.
42+ Defaults to the current user.
43+
3544 emoji_status (:obj:`~pyrogram.types.EmojiStatus`, *optional*):
36- The emoji status to set. None to remove.
45+ New emoji status.
46+ Pass None to remove.
3747
3848 Returns:
3949 ``bool``: On success, True is returned.
@@ -43,20 +53,40 @@ async def set_emoji_status(
4353
4454 from pyrogram import types
4555
46- # Set emoji status
47- await app.set_emoji_status(types.EmojiStatus(custom_emoji_id="1234567890987654321"))
56+ # Set emoji status of the current user
57+ await app.set_emoji_status(emoji_status= types.EmojiStatus(custom_emoji_id="1234567890987654321"))
4858
49- # Set collectible emoji status
50- await app.set_emoji_status(types.EmojiStatus(collectible_id=1234567890987654321))
59+ # Set collectible emoji status for a channel
60+ await app.set_emoji_status(
61+ chat_id="channel_username",
62+ emoji_status=types.EmojiStatus(gift_id=1234567890987654321)
63+ )
5164 """
52- await self .invoke (
53- raw .functions .account .UpdateEmojiStatus (
54- emoji_status = (
55- emoji_status .write ()
56- if emoji_status
57- else raw .types .EmojiStatusEmpty ()
65+ if chat_id is None :
66+ peer = raw .types .InputPeerSelf ()
67+ else :
68+ peer = await self .resolve_peer (chat_id )
69+
70+ if isinstance (peer , raw .types .InputPeerChannel ):
71+ await self .invoke (
72+ raw .functions .channels .UpdateEmojiStatus (
73+ channel = peer ,
74+ emoji_status = (
75+ emoji_status .write ()
76+ if emoji_status
77+ else raw .types .EmojiStatusEmpty ()
78+ )
79+ )
80+ )
81+ else :
82+ await self .invoke (
83+ raw .functions .account .UpdateEmojiStatus (
84+ emoji_status = (
85+ emoji_status .write ()
86+ if emoji_status
87+ else raw .types .EmojiStatusEmpty ()
88+ )
5889 )
5990 )
60- )
6191
6292 return True
0 commit comments