Skip to content

Commit fb3b24d

Browse files
committed
Added Support For Set Chat Reaction
1 parent 9b9944f commit fb3b24d

2 files changed

Lines changed: 59 additions & 1 deletion

File tree

pyrogram/methods/chats/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
from .set_chat_description import SetChatDescription
4949
from .set_chat_permissions import SetChatPermissions
5050
from .set_chat_photo import SetChatPhoto
51+
from .set_chat_reactions import SetChatReaction
5152
from .set_chat_title import SetChatTitle
5253
from .set_send_as_chat import SetSendAsChat
5354
from .set_slow_mode import SetSlowMode
@@ -98,6 +99,7 @@ class Chats(
9899
GetChatEventLog,
99100
GetChatOnlineCount,
100101
GetSendAsChats,
101-
SetSendAsChat
102+
SetSendAsChat,
103+
SetChatReaction
102104
):
103105
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-2021 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+
from typing import Union
19+
20+
from pyrogram import raw
21+
from pyrogram.scaffold import Scaffold
22+
23+
24+
class SetChatReaction(Scaffold):
25+
async def set_chat_reactions(
26+
self,
27+
chat_id: Union[int, str],
28+
available_reactions: list
29+
) -> bool:
30+
"""Set the default emoji to use in chat.
31+
32+
Use :meth:`~pyrogram.Client.set_chat_reactions` to set one or more emoji for the chat to react to messages..
33+
34+
Parameters:
35+
chat_id (``int`` | ``str``):
36+
Unique identifier (int) or username (str) of the target chat.
37+
38+
available_reactions: List of ``str``
39+
40+
Returns:
41+
``bool``: On success, true is returned
42+
43+
Example:
44+
.. code-block:: python
45+
46+
app.set_chat_reactions(chat_id, [❤️, 👍])
47+
"""
48+
try:
49+
await self.send(
50+
raw.functions.messages.SetChatAvailableReactions(
51+
peer=await self.resolve_peer(chat_id),
52+
available_reactions=available_reactions,
53+
)
54+
)
55+
except Exception:
56+
return False

0 commit comments

Comments
 (0)