pyrofork: Add stars and is_star_giveaway field to class GiveawayResult

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2024-09-07 16:21:15 +07:00
parent 2faae08064
commit 02eed79861
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5

View file

@ -46,6 +46,9 @@ class GiveawayResult(Object):
months (``int``, *optional*):
How long the telegram premium last (in month).
stars (``int``, *optional*):
How many stars the giveaway winner(s) get.
expire_date (:py:obj:`~datetime.datetime`, *optional*):
Date the giveaway winner(s) choosen.
@ -55,6 +58,9 @@ class GiveawayResult(Object):
is_refunded (``bool``, *optional*):
True, if the giveaway was refunded.
is_star_giveaway (``bool``, *optional*):
True, if the giveaway is a star giveaway.
is_winners_hidden (``bool``):
True, if the giveaway winners are hidden.
"""
@ -69,9 +75,11 @@ class GiveawayResult(Object):
unclaimed_quantity: int,
winners: List["types.User"] = None,
months: int = None,
stars: int = None,
expire_date: datetime = None,
new_subscribers : bool = None,
is_refunded: bool = None,
is_star_giveaway: bool = None,
is_winners_hidden: bool
):
super().__init__(client)
@ -82,9 +90,11 @@ class GiveawayResult(Object):
self.unclaimed_quantity = unclaimed_quantity
self.winners = winners
self.months = months
self.stars = stars
self.expire_date = expire_date
self.new_subscribers = new_subscribers
self.is_refunded = is_refunded
self.is_star_giveaway = is_star_giveaway
self.is_winners_hidden = is_winners_hidden
@staticmethod
@ -113,6 +123,8 @@ class GiveawayResult(Object):
winners = []
for winner in giveaway_result.winners:
winners.append(await client.get_users(winner))
stars = getattr(giveaway_result, "stars", None)
return GiveawayResult(
chat=chat,
@ -121,9 +133,11 @@ class GiveawayResult(Object):
unclaimed_quantity=getattr(giveaway_result, "unclaimed_count", None),
winners=winners,
months=getattr(giveaway_result, "months", None),
stars=stars if isinstance(giveaway_result, raw.types.MessageMediaGiveawayResults) else None,
expire_date=expired_date,
new_subscribers=getattr(giveaway_result, "only_new_subscribers", None),
is_refunded=getattr(giveaway_result, "refunded", None),
is_star_giveaway=bool(stars),
is_winners_hidden=hide_winners,
client=client
)