Skip to content

Commit

Permalink
fix Message.reactions type-hint error
Browse files Browse the repository at this point in the history
  • Loading branch information
kvrvgv committed May 5, 2023
1 parent 5c6f348 commit cf2629f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pyrogram/types/messages_and_media/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class Message(Object, Update):
views (``int``, *optional*):
Channel post views.
forwards (``int``, *optional*):
forwards (``int``, *optional*):
Channel post forwards.
via_bot (:obj:`~pyrogram.types.User`):
Expand Down Expand Up @@ -384,7 +384,7 @@ def __init__(
"types.ReplyKeyboardRemove",
"types.ForceReply"
] = None,
reactions: List["types.Reaction"] = None
reactions: Union[List["types.Reaction"], "types.MessageReactions"] = None
):
super().__init__(client)

Expand Down Expand Up @@ -456,7 +456,13 @@ def __init__(
self.video_chat_ended = video_chat_ended
self.video_chat_members_invited = video_chat_members_invited
self.web_app_data = web_app_data
self.reactions = reactions
self._reactions = reactions

@property
def reactions(self) -> Optional["types.MessageReactions"]:
if isinstance(self._reactions, types.MessageReactions):
return self._reactions
return None

@staticmethod
async def _parse(
Expand Down Expand Up @@ -756,7 +762,7 @@ async def _parse(
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)

parsed_message = Message(
id=message.id,
Expand Down

0 comments on commit cf2629f

Please sign in to comment.