diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py
index 2e928a32..08b5b429 100644
--- a/compiler/docs/compiler.py
+++ b/compiler/docs/compiler.py
@@ -520,6 +520,7 @@ def pyrogram_api():
VideoChatMembersInvited
WebAppData
MessageReactions
+ MessageReactor
ChatReactions
ForumTopicCreated
ForumTopicEdited
diff --git a/pyrogram/methods/messages/send_paid_reaction.py b/pyrogram/methods/messages/send_paid_reaction.py
index c9995dba..052ddcbe 100644
--- a/pyrogram/methods/messages/send_paid_reaction.py
+++ b/pyrogram/methods/messages/send_paid_reaction.py
@@ -67,6 +67,8 @@ class SendPaidReaction:
private=anonymous
)
)
+ users = {i.id: i for i in r.users}
+
for i in r.updates:
if isinstance(i, raw.types.UpdateMessageReactions):
- return types.MessageReactions._parse(self, i.reactions)
+ return types.MessageReactions._parse(self, i.reactions, users)
diff --git a/pyrogram/types/messages_and_media/__init__.py b/pyrogram/types/messages_and_media/__init__.py
index 6d3f5a87..72fa293a 100644
--- a/pyrogram/types/messages_and_media/__init__.py
+++ b/pyrogram/types/messages_and_media/__init__.py
@@ -55,6 +55,7 @@ from .web_page_preview import WebPagePreview
from .message_reactions import MessageReactions
from .message_reaction_updated import MessageReactionUpdated
from .message_reaction_count_updated import MessageReactionCountUpdated
+from .message_reactor import MessageReactor
from .message_story import MessageStory
from .story import Story
from .story_deleted import StoryDeleted
@@ -66,5 +67,5 @@ from .exported_story_link import ExportedStoryLink
__all__ = [
"Animation", "Audio", "AvailableEffect", "Contact", "Document", "Game", "GiftedPremium", "Giveaway", "GiveawayLaunched", "GiveawayResult", "LabeledPrice", "Location", "MediaArea", "MediaAreaChannelPost", "MediaAreaCoordinates", "Message", "MessageEntity", "Photo", "Thumbnail",
"StrippedThumbnail", "Poll", "PollOption", "Sticker", "StickerSet", "Venue", "Video", "VideoNote", "Voice", "WebPage", "WebPageEmpty", "WebPagePreview", "Dice",
- "Reaction", "WebAppData", "MessageReactions", "MessageReactionUpdated", "MessageReactionCountUpdated", "MessageStory", "Story", "StoryDeleted", "StorySkipped", "StoryViews", "StoryForwardHeader", "StoriesPrivacyRules", "ExportedStoryLink"
+ "Reaction", "WebAppData", "MessageReactions", "MessageReactionUpdated", "MessageReactionCountUpdated", "MessageReactor", "MessageStory", "Story", "StoryDeleted", "StorySkipped", "StoryViews", "StoryForwardHeader", "StoriesPrivacyRules", "ExportedStoryLink"
]
diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py
index 36d0b950..ea281a63 100644
--- a/pyrogram/types/messages_and_media/message.py
+++ b/pyrogram/types/messages_and_media/message.py
@@ -1100,7 +1100,7 @@ class Message(Object, Update):
from_user = types.User._parse(client, users.get(user_id, None))
sender_chat = types.Chat._parse(client, message, users, chats, is_chat=False) if not from_user else None
- reactions = types.MessageReactions._parse(client, message.reactions)
+ reactions = types.MessageReactions._parse(client, message.reactions, users)
if message.via_business_bot_id:
sender_business_bot = types.User._parse(client, users.get(message.via_business_bot_id, None))
diff --git a/pyrogram/types/messages_and_media/message_reactions.py b/pyrogram/types/messages_and_media/message_reactions.py
index 79835dac..e61bb2ef 100644
--- a/pyrogram/types/messages_and_media/message_reactions.py
+++ b/pyrogram/types/messages_and_media/message_reactions.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see .
-from typing import Optional, List
+from typing import Optional, List, Dict
import pyrogram
from pyrogram import raw, types
@@ -30,6 +30,9 @@ class MessageReactions(Object):
Parameters:
reactions (List of :obj:`~pyrogram.types.Reaction`):
Reactions list.
+
+ top_reactors (List of :obj:`~pyrogram.types.MessageReactor`):
+ Top reactors.
"""
def __init__(
@@ -37,15 +40,18 @@ class MessageReactions(Object):
*,
client: "pyrogram.Client" = None,
reactions: Optional[List["types.Reaction"]] = None,
+ top_reactors: Optional[List["types.MessageReactor"]] = None
):
super().__init__(client)
self.reactions = reactions
+ self.top_reactors = top_reactors
@staticmethod
def _parse(
client: "pyrogram.Client",
- message_reactions: Optional["raw.base.MessageReactions"] = None
+ message_reactions: Optional["raw.base.MessageReactions"] = None,
+ users: Optional[Dict[int, "raw.types.User"]] = None
) -> Optional["MessageReactions"]:
if not message_reactions:
return None
@@ -55,5 +61,9 @@ class MessageReactions(Object):
reactions=[
types.Reaction._parse_count(client, reaction)
for reaction in message_reactions.results
+ ],
+ top_reactors=[
+ types.MessageReactor._parse(client, reactor, users)
+ for reactor in message_reactions.top_reactors
]
)
diff --git a/pyrogram/types/messages_and_media/message_reactor.py b/pyrogram/types/messages_and_media/message_reactor.py
new file mode 100644
index 00000000..4198ed03
--- /dev/null
+++ b/pyrogram/types/messages_and_media/message_reactor.py
@@ -0,0 +1,85 @@
+# Pyrofork - Telegram MTProto API Client Library for Python
+# Copyright (C) 2017-present Dan
+# Copyright (C) 2022-present Mayuri-Chan
+#
+# This file is part of Pyrofork.
+#
+# Pyrofork 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.
+#
+# Pyrofork 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 Pyrofork. If not, see .
+
+from typing import Optional, Dict
+
+import pyrogram
+from pyrogram import raw, types
+from ..object import Object
+
+
+class MessageReactor(Object):
+ """Contains information about a message reactor.
+
+ Parameters:
+ amount (``int``):
+ Stars amount.
+
+ is_top (``bool``, *optional*):
+ True, if reactor is top.
+
+ is_my (``bool``, *optional*):
+ True, if the reaction is mine.
+
+ is_anonymous (``bool``, *optional*):
+ True, if reactor is anonymous.
+
+ from_user (:obj:`~pyrogram.types.User`, *optional*):
+ Information about the reactor.
+ """
+ def __init__(
+ self,
+ *,
+ client: "pyrogram.Client" = None,
+ amount: int,
+ is_top: bool = None,
+ is_my: bool = None,
+ is_anonymous: bool = None,
+ from_user: "types.User" = None
+ ):
+ super().__init__(client)
+
+ self.amount = amount
+ self.is_top = is_top
+ self.is_my = is_my
+ self.is_anonymous = is_anonymous
+ self.from_user = from_user
+
+ @staticmethod
+ def _parse(
+ client: "pyrogram.Client",
+ message_reactor: Optional["raw.base.MessageReactor"] = None,
+ users: Dict[int, "raw.types.User"] = None
+ ) -> Optional["MessageReactor"]:
+ if not message_reactor:
+ return None
+
+ is_anonymous = message_reactor.anonymous
+ from_user = None
+ if not is_anonymous:
+ from_user = types.User._parse(client, users.get(message_reactor.peer_id.user_id))
+
+ return MessageReactor(
+ client=client,
+ amount=message_reactor.count,
+ is_top=message_reactor.top,
+ is_my=message_reactor.my,
+ is_anonymous=is_anonymous,
+ from_user=from_user
+ )