From 588a9d2ec659658ea17084dd53fffd611829cddc Mon Sep 17 00:00:00 2001 From: wulan17 Date: Mon, 9 Jun 2025 22:36:11 +0700 Subject: [PATCH] pyrofork: Add paid_message_price_changed field to Message Signed-off-by: wulan17 --- compiler/docs/compiler.py | 1 + pyrogram/enums/message_service_type.py | 3 ++ pyrogram/types/messages_and_media/message.py | 7 +++ pyrogram/types/payments/__init__.py | 2 + .../payments/paid_message_price_changed.py | 49 +++++++++++++++++++ 5 files changed, 62 insertions(+) create mode 100644 pyrogram/types/payments/paid_message_price_changed.py diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py index 10e20a1f..635a431e 100644 --- a/compiler/docs/compiler.py +++ b/compiler/docs/compiler.py @@ -605,6 +605,7 @@ def pyrogram_api(): Invoice LabeledPrice PaidMedia + PaidMessagePriceChanged PaymentForm PaymentInfo PaymentRefunded diff --git a/pyrogram/enums/message_service_type.py b/pyrogram/enums/message_service_type.py index a2fbc90a..5f25dd6b 100644 --- a/pyrogram/enums/message_service_type.py +++ b/pyrogram/enums/message_service_type.py @@ -132,3 +132,6 @@ class MessageServiceType(AutoName): SCREENSHOT_TAKEN = auto() "Screenshot taken" + + PAID_MESSAGE_PRICE_CHANGED = auto() + "Paid message price changed" diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 7769ec23..bb6007c2 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -480,6 +480,7 @@ class Message(Object, Update): gift_code: "types.GiftCode" = None, gift: "types.Gift" = None, screenshot_taken: "types.ScreenshotTaken" = None, + paid_message_price_changed: "types.PaidMessagePriceChanged" = None, invoice: "types.Invoice" = None, story: Union["types.MessageStory", "types.Story"] = None, alternative_videos: List["types.AlternativeVideo"] = None, @@ -596,6 +597,7 @@ class Message(Object, Update): self.gift_code = gift_code self.gift = gift self.screenshot_taken = screenshot_taken + self.paid_message_price_changed = paid_message_price_changed self.invoice = invoice self.story = story self.video = video @@ -760,6 +762,7 @@ class Message(Object, Update): gift_code = None gift = None screenshot_taken = None + paid_message_price_changed = None service_type = None chat_join_type = None @@ -881,6 +884,9 @@ class Message(Object, Update): elif isinstance(action, raw.types.MessageActionScreenshotTaken): screenshot_taken = types.ScreenshotTaken() service_type = enums.MessageServiceType.SCREENSHOT_TAKEN + elif isinstance(action, raw.types.MessageActionPaidMessagesPrice): + paid_message_price_changed = types.PaidMessagePriceChanged._parse(action) + service_type = enums.MessageServiceType.PAID_MESSAGE_PRICE_CHANGED parsed_message = Message( id=message.id, @@ -926,6 +932,7 @@ class Message(Object, Update): contact_registered=contact_registered, gift_code=gift_code, screenshot_taken=screenshot_taken, + paid_message_price_changed=paid_message_price_changed, raw=message, chat_join_type=chat_join_type, client=client diff --git a/pyrogram/types/payments/__init__.py b/pyrogram/types/payments/__init__.py index 7dc9e6bd..dbb02e4e 100644 --- a/pyrogram/types/payments/__init__.py +++ b/pyrogram/types/payments/__init__.py @@ -27,6 +27,7 @@ from .input_stars_transaction import InputStarsTransaction from .invoice import Invoice from .labeled_price import LabeledPrice from .paid_media import PaidMedia +from .paid_message_price_changed import PaidMessagePriceChanged from .payment_form import PaymentForm from .payment_info import PaymentInfo from .payment_refunded import PaymentRefunded @@ -46,6 +47,7 @@ __all__ = [ "Invoice", "LabeledPrice", "PaidMedia", + "PaidMessagePriceChanged", "PaymentForm", "PaymentInfo", "PaymentRefunded", diff --git a/pyrogram/types/payments/paid_message_price_changed.py b/pyrogram/types/payments/paid_message_price_changed.py new file mode 100644 index 00000000..d248df2d --- /dev/null +++ b/pyrogram/types/payments/paid_message_price_changed.py @@ -0,0 +1,49 @@ +# 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 List, Union + +from pyrogram import raw +from pyrogram import types +from ..object import Object + + +class PaidMessagePriceChanged(Object): + """A PaidMessagePriceChanged. + + Parameters: + stars_amount (``int``): + Amount of stars. + + extended_media (List of :obj:`~pyrogram.types.Animation` | :obj:`~pyrogram.types.ExtendedMediaPreview` | :obj:`~pyrogram.types.Photo` | :obj:`~pyrogram.types.Video`, *optional*): + Extended media. + """ + def __init__( + self, + *, + stars_amount: int, + ): + super().__init__() + + self.stars_amount = stars_amount + + @staticmethod + def _parse(action: "raw.types.MessageActionPaidMessagesPrice") -> "PaidMessagePriceChanged": + return PaidMessagePriceChanged( + stars_amount=action.stars + )