diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py index ad3b7d0d..deb1248e 100644 --- a/compiler/docs/compiler.py +++ b/compiler/docs/compiler.py @@ -527,8 +527,6 @@ def pyrogram_api(): GeneralTopicHidden GeneralTopicUnhidden Reaction - ReactionCount - ReactionType MessageReactionUpdated MessageReactionCountUpdated """, diff --git a/pyrogram/enums/reaction_type.py b/pyrogram/enums/reaction_type.py index 829de1ec..0d03b74f 100644 --- a/pyrogram/enums/reaction_type.py +++ b/pyrogram/enums/reaction_type.py @@ -27,3 +27,6 @@ class ReactionType(AutoName): CUSTOM_EMOJI = auto() """Custom emoji reaction type.""" + + PAID = auto() + """Paid reaction type.""" diff --git a/pyrogram/types/messages_and_media/__init__.py b/pyrogram/types/messages_and_media/__init__.py index 2eda28f9..6d3f5a87 100644 --- a/pyrogram/types/messages_and_media/__init__.py +++ b/pyrogram/types/messages_and_media/__init__.py @@ -39,8 +39,6 @@ from .photo import Photo from .poll import Poll from .poll_option import PollOption from .reaction import Reaction -from .reaction_type import ReactionType -from .reaction_count import ReactionCount from .sticker import Sticker from .stickerset import StickerSet from .stories_privacy_rules import StoriesPrivacyRules @@ -68,5 +66,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", "ReactionCount", "ReactionType", "MessageReactionUpdated", "MessageReactionCountUpdated", "MessageStory", "Story", "StoryDeleted", "StorySkipped", "StoryViews", "StoryForwardHeader", "StoriesPrivacyRules", "ExportedStoryLink" + "Reaction", "WebAppData", "MessageReactions", "MessageReactionUpdated", "MessageReactionCountUpdated", "MessageStory", "Story", "StoryDeleted", "StorySkipped", "StoryViews", "StoryForwardHeader", "StoriesPrivacyRules", "ExportedStoryLink" ] diff --git a/pyrogram/types/messages_and_media/message_reaction_count_updated.py b/pyrogram/types/messages_and_media/message_reaction_count_updated.py index 9f923a4a..c503238e 100644 --- a/pyrogram/types/messages_and_media/message_reaction_count_updated.py +++ b/pyrogram/types/messages_and_media/message_reaction_count_updated.py @@ -40,7 +40,7 @@ class MessageReactionCountUpdated(Object, Update): date (:py:obj:`~datetime.datetime`): Date of change of the reaction - reactions (:obj:`~pyrogram.types.ReactionCount`): + reactions (:obj:`~pyrogram.types.Reaction`): List of reactions that are present on the message """ @@ -51,7 +51,7 @@ class MessageReactionCountUpdated(Object, Update): chat: "types.Chat", message_id: int, date: datetime, - reactions: List["types.ReactionCount"] + reactions: List["types.Reaction"] ): super().__init__(client) @@ -66,7 +66,7 @@ class MessageReactionCountUpdated(Object, Update): update: "raw.types.UpdateBotMessageReactions", users: Dict[int, "raw.types.User"], chats: Dict[int, "raw.types.Chat"] - ) -> "MessageReactionUpdated": + ) -> "MessageReactionCountUpdated": chat = None peer_id = utils.get_peer_id(update.peer) raw_peer_id = utils.get_raw_peer_id(update.peer) @@ -81,7 +81,8 @@ class MessageReactionCountUpdated(Object, Update): message_id=update.msg_id, date=utils.timestamp_to_datetime(update.date), reactions=[ - types.ReactionCount._parse( + types.Reaction._parse_count( + client, rt ) for rt in update.reactions ] diff --git a/pyrogram/types/messages_and_media/message_reaction_updated.py b/pyrogram/types/messages_and_media/message_reaction_updated.py index aa4eb387..03ccd346 100644 --- a/pyrogram/types/messages_and_media/message_reaction_updated.py +++ b/pyrogram/types/messages_and_media/message_reaction_updated.py @@ -48,10 +48,10 @@ class MessageReactionUpdated(Object, Update): date (:py:obj:`~datetime.datetime`): Date of change of the reaction - old_reaction (:obj:`~pyrogram.types.ReactionType`): + old_reaction (:obj:`~pyrogram.types.Reaction`): Previous list of reaction types that were set by the user - new_reaction (:obj:`~pyrogram.types.ReactionType`): + new_reaction (:obj:`~pyrogram.types.Reaction`): New list of reaction types that have been set by the user """ @@ -65,8 +65,8 @@ class MessageReactionUpdated(Object, Update): actor_chat: "types.Chat", date: datetime, chat: "types.Chat", - old_reaction: List["types.ReactionType"], - new_reaction: List["types.ReactionType"] + old_reaction: List["types.Reaction"], + new_reaction: List["types.Reaction"] ): super().__init__(client) @@ -112,13 +112,15 @@ class MessageReactionUpdated(Object, Update): chat=chat, actor_chat=actor_chat, old_reaction=[ - types.ReactionType._parse( + types.Reaction._parse( + client, rt ) for rt in update.old_reactions ], new_reaction=[ - types.ReactionType._parse( + types.Reaction._parse( + client, rt ) for rt in update.new_reactions ] - ) \ No newline at end of file + ) diff --git a/pyrogram/types/messages_and_media/reaction.py b/pyrogram/types/messages_and_media/reaction.py index 1295571e..5d57568e 100644 --- a/pyrogram/types/messages_and_media/reaction.py +++ b/pyrogram/types/messages_and_media/reaction.py @@ -20,7 +20,7 @@ from typing import Optional import pyrogram -from pyrogram import raw +from pyrogram import enums, raw from ..object import Object @@ -28,6 +28,9 @@ class Reaction(Object): """Contains information about a reaction. Parameters: + type (``enums.ReactionType``): + Reaction type. + emoji (``str``, *optional*): Reaction emoji. @@ -46,6 +49,7 @@ class Reaction(Object): self, *, client: "pyrogram.Client" = None, + type: "enums.ReactionType", emoji: Optional[str] = None, custom_emoji_id: Optional[int] = None, count: Optional[int] = None, @@ -53,6 +57,7 @@ class Reaction(Object): ): super().__init__(client) + self.type = type self.emoji = emoji self.custom_emoji_id = custom_emoji_id self.count = count @@ -66,14 +71,21 @@ class Reaction(Object): if isinstance(reaction, raw.types.ReactionEmoji): return Reaction( client=client, + type=enums.ReactionType.EMOJI, emoji=reaction.emoticon ) if isinstance(reaction, raw.types.ReactionCustomEmoji): return Reaction( client=client, + type=enums.ReactionType.CUSTOM_EMOJI, custom_emoji_id=reaction.document_id ) + if isinstance(reaction, raw.types.ReactionPaid): + return Reaction( + client=client, + type=enums.ReactionType.PAID + ) @staticmethod def _parse_count( diff --git a/pyrogram/types/messages_and_media/reaction_count.py b/pyrogram/types/messages_and_media/reaction_count.py deleted file mode 100644 index fa46cb08..00000000 --- a/pyrogram/types/messages_and_media/reaction_count.py +++ /dev/null @@ -1,63 +0,0 @@ -# PyroFork - Telegram MTProto API Client Library for Python -# 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 - -from pyrogram import raw -from .reaction_type import ReactionType -from ..object import Object - -class ReactionCount(Object): - """Represents a reaction added to a message along with the number of times it was added. - - Parameters: - - type (:obj:`~pyrogram.types.ReactionType`): - Reaction type. - - total_count (``int``): - Total reaction count. - - chosen_order (``int``): - Chosen reaction order. - Available for chosen reactions. - """ - - def __init__( - self, - *, - type: ReactionType, - total_count: int, - chosen_order: int - ): - super().__init__() - self.type = type - self.total_count = total_count - self.chosen_order = chosen_order - - @staticmethod - def _parse( - update: "raw.types.ReactionCount", - ) -> Optional["ReactionCount"]: - return ReactionCount( - type=ReactionType._parse( - update.reaction - ), - total_count=update.count, - chosen_order=update.chosen_order - ) diff --git a/pyrogram/types/messages_and_media/reaction_type.py b/pyrogram/types/messages_and_media/reaction_type.py deleted file mode 100644 index a0a9cbf4..00000000 --- a/pyrogram/types/messages_and_media/reaction_type.py +++ /dev/null @@ -1,74 +0,0 @@ -# PyroFork - Telegram MTProto API Client Library for Python -# 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 - -from pyrogram import enums, raw -from ..object import Object - -class ReactionType(Object): - """Contains information about a reaction. - - Parameters: - type (``enums.ReactionType``, *optional*): - Reaction type. - - emoji (``str``, *optional*): - Reaction emoji. - - custom_emoji_id (``int``, *optional*): - Custom emoji id. - """ - def __init__( - self, - *, - type: str = "enums.ReactionType", - emoji: str = None, - custom_emoji_id: str = None - ): - super().__init__() - self.type = type - self.emoji = emoji - self.custom_emoji_id = custom_emoji_id - - @staticmethod - def _parse( - update: "raw.types.Reaction", - ) -> Optional["ReactionType"]: - if isinstance(update, raw.types.ReactionEmpty): - return None - elif isinstance(update, raw.types.ReactionEmoji): - return ReactionType( - type=enums.ReactionType.EMOJI, - emoji=update.emoticon - ) - elif isinstance(update, raw.types.ReactionCustomEmoji): - return ReactionType( - type=enums.ReactionType.CUSTOM_EMOJI, - custom_emoji_id=update.document_id - ) - - def write(self): - if self.type == enums.ReactionType.EMOJI: - return raw.types.ReactionEmoji( - emoticon=self.emoji - ) - if self.type == enums.ReactionType.CUSTOM_EMOJI: - return raw.types.ReactionCustomEmoji( - document_id=self.custom_emoji_id - ) diff --git a/pyrogram/types/user_and_chats/chat_reactions.py b/pyrogram/types/user_and_chats/chat_reactions.py index cc36daea..7362a558 100644 --- a/pyrogram/types/user_and_chats/chat_reactions.py +++ b/pyrogram/types/user_and_chats/chat_reactions.py @@ -64,11 +64,11 @@ class ChatReactions(Object): return ChatReactions( client=client, reactions=[ - types.ReactionType._parse(reaction) + types.Reaction._parse(client, reaction) for reaction in chat_reactions.reactions ] ) if isinstance(chat_reactions, raw.types.ChatReactionsNone): return None - return None \ No newline at end of file + return None