From a240b7bf572e0485aaba1f8f743ea254881c56c2 Mon Sep 17 00:00:00 2001 From: shriMADhav U k Date: Fri, 3 Jan 2025 18:13:10 +0100 Subject: [PATCH] Add `upgrade_star_count` and `is_for_birthday` in Gift --- docs/source/releases/changes-in-this-fork.rst | 1 + pyrogram/types/messages_and_media/gift.py | 12 ++++++++++++ pyrogram/types/messages_and_media/user_gift.py | 9 +++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/source/releases/changes-in-this-fork.rst b/docs/source/releases/changes-in-this-fork.rst index 74ff395df..14689ead8 100644 --- a/docs/source/releases/changes-in-this-fork.rst +++ b/docs/source/releases/changes-in-this-fork.rst @@ -25,6 +25,7 @@ Changes in this Fork | Scheme layer used: 196 | +------------------------+ +- Added the parameters ``upgrade_star_count`` and ``is_for_birthday`` in :obj:`~pyrogram.types.Gift`. - Added the :meth:`~pyrogram.Client.on_bot_purchased_paid_media` and :meth:`~pyrogram.Client.on_bot_business_connection`. - Added the parameters ``can_be_upgraded``, ``was_refunded``, ``prepaid_upgrade_star_count``, ``can_be_transferred``, ``transfer_star_count``, ``export_date`` in :obj:`~pyrogram.types.UserGift`. - Renamed the parameter ``only_in_channels`` to ``chat_type_filter`` in the :meth:`~pyrogram.Client.search_global_count` and :meth:`~pyrogram.Client.search_global`. diff --git a/pyrogram/types/messages_and_media/gift.py b/pyrogram/types/messages_and_media/gift.py index cc4d1719d..ae2fb27e1 100644 --- a/pyrogram/types/messages_and_media/gift.py +++ b/pyrogram/types/messages_and_media/gift.py @@ -46,6 +46,12 @@ class Gift(Object): default_sell_star_count (``int``): Number of Telegram Stars that can be claimed by the receiver instead of the gift by default. If the gift was paid with just bought Telegram Stars, then full value can be claimed. + upgrade_star_count (``int``, *optional*): + Number of Telegram Stars that must be paid to upgrade the gift; 0 if upgrade isn't possible. + + is_for_birthday (``bool``, *optional*): + True, if the gift is a birthday gift. + first_send_date (:py:obj:`~datetime.datetime`, *optional*): Point in time (Unix timestamp) when the gift was send for the first time; for sold out gifts only. @@ -70,6 +76,8 @@ def __init__( total_count: Optional[int] = None, remaining_count: Optional[int] = None, default_sell_star_count: int, + upgrade_star_count: int, + is_for_birthday: Optional[bool] = None, first_send_date: Optional[datetime] = None, last_send_date: Optional[datetime] = None, is_limited: Optional[bool] = None, @@ -83,6 +91,8 @@ def __init__( self.total_count = total_count self.remaining_count = remaining_count self.default_sell_star_count = default_sell_star_count + self.upgrade_star_count = upgrade_star_count + self.is_for_birthday = is_for_birthday self.first_send_date = first_send_date self.last_send_date = last_send_date self.is_limited = is_limited @@ -107,5 +117,7 @@ async def _parse( last_send_date=utils.timestamp_to_datetime(getattr(star_gift, "last_sale_date", None)), is_limited=getattr(star_gift, "limited", None), is_sold_out=getattr(star_gift, "sold_out", None), + upgrade_star_count=getattr(star_gift, "upgrade_stars", 0), + is_for_birthday=getattr(star_gift, "birthday", None), client=client ) diff --git a/pyrogram/types/messages_and_media/user_gift.py b/pyrogram/types/messages_and_media/user_gift.py index 2ea6c9f84..f1ba4011a 100644 --- a/pyrogram/types/messages_and_media/user_gift.py +++ b/pyrogram/types/messages_and_media/user_gift.py @@ -171,7 +171,9 @@ async def _parse_action( total_count=getattr(action.gift, "availability_total", None), remaining_count=getattr(action.gift, "availability_remains", None), default_sell_star_count=action.gift.convert_stars, - is_limited=getattr(action.gift, "limited", None), + is_limited=getattr(action.gift, "limited", None),upgrade_star_count=getattr(star_gift, "upgrade_stars", 0), + is_for_birthday=getattr(star_gift, "birthday", None), + client=client ), date=utils.timestamp_to_datetime(message.date), is_private=getattr(action, "name_hidden", None), @@ -198,6 +200,9 @@ async def _parse_action( remaining_count=getattr(action.gift, "availability_remains", None), default_sell_star_count=action.gift.convert_stars, is_limited=getattr(action.gift, "limited", None), + upgrade_star_count=getattr(star_gift, "upgrade_stars", 0), + is_for_birthday=getattr(star_gift, "birthday", None), + client=client ), date=utils.timestamp_to_datetime(message.date), sender_user=types.User._parse(client, users.get(utils.get_raw_peer_id(message.peer_id))), @@ -207,7 +212,7 @@ async def _parse_action( can_be_transferred=getattr(action, "transferred", None), was_refunded=getattr(action, "refunded", None), prepaid_upgrade_star_count=getattr(action, "upgrade_stars", None), - export_date=utils.timestamp_to_datetime(action.can_export_at) if action.can_export_at else None, + export_date=utils.timestamp_to_datetime(getattr(action, "can_export_at", None), transfer_star_count=getattr(action, "transfer_stars", None), client=client )