|
| 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