Skip to content

Commit

Permalink
Add upgrade_star_count and is_for_birthday in Gift
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe committed Jan 3, 2025
1 parent f4fb1f4 commit a240b7b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/source/releases/changes-in-this-fork.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
12 changes: 12 additions & 0 deletions pyrogram/types/messages_and_media/gift.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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
)
9 changes: 7 additions & 2 deletions pyrogram/types/messages_and_media/user_gift.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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))),
Expand All @@ -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
)
Expand Down

0 comments on commit a240b7b

Please sign in to comment.