mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-09-28 03:45:55 +00:00
Add support for multiple reactions in send_reaction
This commit is contained in:
parent
bae74f68ec
commit
d5622b4e82
@ -16,7 +16,7 @@
|
||||
# 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 Union
|
||||
from typing import Union, List
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw
|
||||
@ -28,10 +28,10 @@ class SendReaction:
|
||||
chat_id: Union[int, str],
|
||||
message_id: int = None,
|
||||
story_id: int = None,
|
||||
emoji: Union[int, str] = None,
|
||||
emoji: Union[int, str, List[Union[int, str]]] = None,
|
||||
big: bool = False
|
||||
) -> bool:
|
||||
"""Send a reaction to a message.
|
||||
"""Send a reaction to a message or story.
|
||||
|
||||
.. include:: /_includes/usable-by/users.rst
|
||||
|
||||
@ -45,9 +45,10 @@ class SendReaction:
|
||||
story_id (``int``, *optional*):
|
||||
Identifier of the story.
|
||||
|
||||
emoji (``int`` | ``str``, *optional*):
|
||||
emoji (``int`` | ``str`` | List of ``int`` | ``str``, *optional*):
|
||||
Reaction emoji.
|
||||
Pass None as emoji (default) to retract the reaction.
|
||||
Pass list of int or str to react multiple emojis.
|
||||
|
||||
big (``bool``, *optional*):
|
||||
Pass True to show a bigger and longer reaction.
|
||||
@ -62,6 +63,9 @@ class SendReaction:
|
||||
# Send a reaction
|
||||
await app.send_reaction(chat_id, message_id=message_id, emoji="🔥")
|
||||
|
||||
# Send a multiple reactions
|
||||
await app.send_reaction(chat_id, message_id=message_id, emoji=["🔥", "❤️"])
|
||||
|
||||
# Send a reaction with premium emoji
|
||||
await app.send_reaction(chat_id, message_id=message_id, emoji=5319161050128459957)
|
||||
|
||||
@ -71,6 +75,14 @@ class SendReaction:
|
||||
# Retract a reaction
|
||||
await app.send_reaction(chat_id, message_id=message_id)
|
||||
"""
|
||||
if isinstance(emoji, list):
|
||||
emoji = [
|
||||
raw.types.ReactionCustomEmoji(document_id=i)
|
||||
if isinstance(i, int)
|
||||
else raw.types.ReactionEmoji(emoticon=i)
|
||||
for i in emoji
|
||||
] if emoji else None
|
||||
else:
|
||||
if isinstance(emoji, int):
|
||||
emoji = [raw.types.ReactionCustomEmoji(document_id=emoji)]
|
||||
else:
|
||||
|
@ -4010,7 +4010,7 @@ class Message(Object, Update):
|
||||
else:
|
||||
await self.reply(button, quote=quote)
|
||||
|
||||
async def react(self, emoji: Union[int, str] = None, big: bool = False) -> bool:
|
||||
async def react(self, emoji: Union[int, str, List[Union[int, str]]] = None, big: bool = False) -> bool:
|
||||
"""Bound method *react* of :obj:`~pyrogram.types.Message`.
|
||||
|
||||
Use as a shortcut for:
|
||||
@ -4029,9 +4029,10 @@ class Message(Object, Update):
|
||||
await message.react(emoji="🔥")
|
||||
|
||||
Parameters:
|
||||
emoji (``str``, *optional*):
|
||||
emoji (``int`` | ``str`` | List of ``int`` | ``str``, *optional*):
|
||||
Reaction emoji.
|
||||
Pass "" as emoji (default) to retract the reaction.
|
||||
Pass None as emoji (default) to retract the reaction.
|
||||
Pass list of int or str to react multiple emojis.
|
||||
|
||||
big (``bool``, *optional*):
|
||||
Pass True to show a bigger and longer reaction.
|
||||
|
Loading…
Reference in New Issue
Block a user