From f07d6563e33983ffd625edc46732dfc51450069f Mon Sep 17 00:00:00 2001 From: wulan17 Date: Sat, 7 Sep 2024 16:29:22 +0700 Subject: [PATCH] pyrofork: Add stars field to class GiveawayLaunched Signed-off-by: wulan17 --- .../messages_and_media/giveaway_launched.py | 29 +++++++++++++++++-- pyrogram/types/messages_and_media/message.py | 2 +- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/pyrogram/types/messages_and_media/giveaway_launched.py b/pyrogram/types/messages_and_media/giveaway_launched.py index 68d0c3d7..fb9fa7cc 100644 --- a/pyrogram/types/messages_and_media/giveaway_launched.py +++ b/pyrogram/types/messages_and_media/giveaway_launched.py @@ -16,13 +16,36 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrofork. If not, see . +import pyrogram + from ..object import Object +from pyrogram import raw + class GiveawayLaunched(Object): """A service message about a giveaway started in the channel. - Currently holds no information. + Parameters: + stars (``int``, *optional*): + How many stars the giveaway winner(s) get. """ - def __init__(self): - super().__init__() + def __init__( + self, + *, + client: "pyrogram.Client" = None, + stars: int = None + ): + super().__init__(client) + + self.stars = stars + + @staticmethod + def _parse( + client: "pyrogram.Client", + giveaway_launched: "raw.types.MessageActionGiveawayLaunch" + ) -> "GiveawayLaunched": + return GiveawayLaunched( + client=client, + stars=giveaway_launched.stars + ) diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 95a1093d..3546165f 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -865,7 +865,7 @@ class Message(Object, Update): gifted_premium = await types.GiftedPremium._parse(client, action, from_user.id) service_type = enums.MessageServiceType.GIFTED_PREMIUM elif isinstance(action, raw.types.MessageActionGiveawayLaunch): - giveaway_launched = types.GiveawayLaunched() + giveaway_launched = types.GiveawayLaunched._parse(client, action) service_type = enums.MessageServiceType.GIVEAWAY_LAUNCHED elif isinstance(action, raw.types.MessageActionGiveawayResults): giveaway_result = await types.GiveawayResult._parse(client, action, True)