mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-23 02:17:21 +00:00
Add message_reactions.py
This commit is contained in:
parent
9eb7589a7f
commit
6496a87029
@ -38,9 +38,10 @@ from .video_note import VideoNote
|
||||
from .voice import Voice
|
||||
from .web_app_data import WebAppData
|
||||
from .web_page import WebPage
|
||||
from .message_reactions import MessageReactions
|
||||
|
||||
__all__ = [
|
||||
"Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Photo", "Thumbnail",
|
||||
"StrippedThumbnail", "Poll", "PollOption", "Sticker", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice",
|
||||
"Reaction", "WebAppData"
|
||||
"Reaction", "WebAppData", "MessageReactions"
|
||||
]
|
||||
|
@ -742,8 +742,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.Reaction(emoji=r.reaction, count=r.count, chosen=r.chosen)
|
||||
for r in message.reactions.results] if message.reactions else None
|
||||
reactions = types.MessageReactions._parse(client, message.reactions)
|
||||
|
||||
parsed_message = Message(
|
||||
id=message.id,
|
||||
|
56
pyrogram/types/messages_and_media/message_reactions.py
Normal file
56
pyrogram/types/messages_and_media/message_reactions.py
Normal file
@ -0,0 +1,56 @@
|
||||
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||
#
|
||||
# This file is part of Pyrogram.
|
||||
#
|
||||
# Pyrogram 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.
|
||||
#
|
||||
# Pyrogram 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 Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from typing import Optional, List
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw, types
|
||||
from ..object import Object
|
||||
|
||||
|
||||
class MessageReactions(Object):
|
||||
"""Contains information about a message reactions.
|
||||
|
||||
Parameters:
|
||||
reactions (List of :obj:`~pyrogram.types.Reaction`):
|
||||
Reactions list.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
client: "pyrogram.Client" = None,
|
||||
reactions: Optional[List["types.Reaction"]] = None,
|
||||
):
|
||||
super().__init__(client)
|
||||
|
||||
self.reactions = reactions
|
||||
|
||||
@staticmethod
|
||||
def _parse(
|
||||
client: "pyrogram.Client",
|
||||
message_reactions: Optional["raw.base.MessageReactions"] = None
|
||||
) -> Optional["MessageReactions"]:
|
||||
if not message_reactions:
|
||||
return None
|
||||
|
||||
return MessageReactions(
|
||||
client=client,
|
||||
reactions=[types.Reaction._parse_count(client, reaction)
|
||||
for reaction in message_reactions.results]
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user