@@ -98,33 +98,31 @@ class Gift(Object):
9898 transfer_price (``int``, *optional*):
9999 The number of stars you need to transfer this gift.
100100
101- resale_price (``int``, *optional*):
102- Number of Telegram Stars that must be paid to buy the gift and send it to someone else.
103-
104- last_resale_star_count (``int``, *optional*):
105- Number of Telegram Stars that were paid by the sender for the gift.
106-
107- last_resale_ton_count (``int``, *optional*):
108- Number of TON that were paid by the sender for the gift.
109-
110101 number (``int``, *optional*):
111102 Unique number of the upgraded gift among gifts upgraded from the same gift.
112103
104+ total_upgraded_count (``int``, *optional*):
105+ Total number of gifts that were upgraded from the same gift.
106+
107+ max_upgraded_count (``int``, *optional*):
108+ The maximum number of gifts that can be upgraded from the same gift.
109+
113110 available_resale_amount (``int``, *optional*):
114111 The number of gifts available for resale.
115112 Returned only if is_limited is True.
116113
117- available_amount (``int``, *optional*):
118- The number of gifts available for purchase.
119- Returned only if is_limited is True.
114+ user_limits (:obj:`~pyrogram.types.GiftPurchaseLimit`, *optional*):
115+ Number of times the gift can be purchased by the current user.
120116
121- total_amount (``int``, *optional*):
122- Total amount of gifts.
123- Returned only if is_limited is True.
117+ overall_limits (:obj:`~pyrogram.types.GiftPurchaseLimit`, *optional*):
118+ Number of times the gift can be purchased all users.
124119
125120 publisher_chat (:obj:`~pyrogram.types.Chat`, *optional*):
126121 Information about the chat that published the gift.
127122
123+ resale_parameters (:obj:`~pyrogram.types.GiftResaleParameters`, *optional*):
124+ Resale parameters of the gift.
125+
128126 can_upgrade (``bool``, *optional*):
129127 True, if the gift can be upgraded.
130128
@@ -162,9 +160,12 @@ class Gift(Object):
162160 is_transferred (``bool``, *optional*):
163161 True, if the gift was transferred.
164162
165- is_birthday (``bool``, *optional*):
163+ is_for_birthday (``bool``, *optional*):
166164 True, if the gift is a birthday gift.
167165
166+ is_premium (``bool``, *optional*):
167+ True, if the gift can be bought only by Telegram Premium users.
168+
168169 is_pinned (``bool``, *optional*):
169170 True, if the gift is pinned.
170171
@@ -197,19 +198,19 @@ def __init__(
197198 convert_price : Optional [int ] = None ,
198199 upgrade_price : Optional [int ] = None ,
199200 transfer_price : Optional [int ] = None ,
200- resale_price : Optional [int ] = None ,
201- last_resale_star_count : Optional [int ] = None ,
202- last_resale_ton_count : Optional [int ] = None ,
203201 upgrade_message_id : Optional [int ] = None ,
204202 name : Optional [str ] = None ,
205203 title : Optional [str ] = None ,
206204 collectible_id : Optional [int ] = None ,
207205 attributes : Optional [List ["types.GiftAttribute" ]] = None ,
208206 number : Optional [int ] = None ,
207+ total_upgraded_count : Optional [int ] = None ,
208+ max_upgraded_count : Optional [int ] = None ,
209209 available_resale_amount : Optional [int ] = None ,
210- available_amount : Optional [int ] = None ,
211- total_amount : Optional [int ] = None ,
210+ user_limits : Optional ["types.GiftPurchaseLimit" ] = None ,
211+ overall_limits : Optional ["types.GiftPurchaseLimit" ] = None ,
212212 publisher_chat : Optional ["types.Chat" ] = None ,
213+ resale_parameters : Optional ["types.GiftResaleParameters" ] = None ,
213214 can_upgrade : Optional [bool ] = None ,
214215 can_export_at : Optional [datetime ] = None ,
215216 can_transfer_at : Optional [datetime ] = None ,
@@ -222,7 +223,8 @@ def __init__(
222223 is_upgraded : Optional [bool ] = None ,
223224 is_refunded : Optional [bool ] = None ,
224225 is_transferred : Optional [bool ] = None ,
225- is_birthday : Optional [bool ] = None ,
226+ is_for_birthday : Optional [bool ] = None ,
227+ is_premium : Optional [bool ] = None ,
226228 is_pinned : Optional [bool ] = None ,
227229 raw : Optional ["raw.base.StarGift" ] = None
228230 ):
@@ -245,19 +247,19 @@ def __init__(
245247 self .convert_price = convert_price
246248 self .upgrade_price = upgrade_price
247249 self .transfer_price = transfer_price
248- self .resale_price = resale_price
249- self .last_resale_star_count = last_resale_star_count
250- self .last_resale_ton_count = last_resale_ton_count
251250 self .upgrade_message_id = upgrade_message_id
252251 self .name = name
253252 self .title = title
254253 self .collectible_id = collectible_id
255254 self .attributes = attributes
256255 self .number = number
256+ self .total_upgraded_count = total_upgraded_count
257+ self .max_upgraded_count = max_upgraded_count
257258 self .available_resale_amount = available_resale_amount
258- self .available_amount = available_amount
259- self .total_amount = total_amount
259+ self .user_limits = user_limits
260+ self .overall_limits = overall_limits
260261 self .publisher_chat = publisher_chat
262+ self .resale_parameters = resale_parameters
261263 self .can_upgrade = can_upgrade
262264 self .can_export_at = can_export_at
263265 self .can_transfer_at = can_transfer_at
@@ -270,7 +272,8 @@ def __init__(
270272 self .is_upgraded = is_upgraded
271273 self .is_refunded = is_refunded
272274 self .is_transferred = is_transferred
273- self .is_birthday = is_birthday
275+ self .is_for_birthday = is_for_birthday
276+ self .is_premium = is_premium
274277 self .is_pinned = is_pinned
275278 self .raw = raw
276279
@@ -304,12 +307,13 @@ async def _parse_regular(
304307 price = star_gift .stars ,
305308 convert_price = star_gift .convert_stars ,
306309 upgrade_price = star_gift .upgrade_stars ,
307- available_amount = star_gift .availability_remains ,
308310 available_resale_amount = star_gift .availability_resale ,
309- total_amount = star_gift .availability_total ,
311+ user_limits = types .GiftPurchaseLimit ._parse (star_gift .per_user_total , star_gift .per_user_remains ),
312+ overall_limits = types .GiftPurchaseLimit ._parse (star_gift .availability_total , star_gift .availability_remains ),
310313 is_limited = star_gift .limited ,
311314 is_sold_out = star_gift .sold_out ,
312- is_birthday = star_gift .birthday ,
315+ is_for_birthday = star_gift .birthday ,
316+ is_premium = star_gift .require_premium ,
313317 first_sale_date = utils .timestamp_to_datetime (star_gift .first_sale_date ),
314318 last_sale_date = utils .timestamp_to_datetime (star_gift .last_sale_date ),
315319 publisher_chat = types .Chat ._parse_chat (client , chats .get (utils .get_raw_peer_id (star_gift .released_by ))),
@@ -329,16 +333,6 @@ async def _parse_unique(
329333
330334 owner_id = utils .get_raw_peer_id (star_gift .owner_id )
331335
332- last_resale_star_count = None
333- last_resale_ton_count = None
334-
335- if star_gift .resell_amount :
336- for currency in star_gift .resell_amount :
337- if isinstance (currency , raw .types .StarsAmount ):
338- last_resale_star_count = currency .amount
339- elif isinstance (currency , raw .types .StarsTonAmount ):
340- last_resale_ton_count = currency .amount
341-
342336 return Gift (
343337 id = star_gift .id ,
344338 name = star_gift .slug ,
@@ -348,13 +342,14 @@ async def _parse_unique(
348342 [await types .GiftAttribute ._parse (client , attr , users , chats ) for attr in star_gift .attributes ]
349343 ) or None ,
350344 number = star_gift .availability_issued ,
351- total_amount = star_gift .availability_total ,
345+ total_upgraded_count = star_gift .availability_total ,
346+ max_upgraded_count = star_gift .availability_issued ,
347+ is_premium = star_gift .require_premium ,
352348 owner = types .Chat ._parse_chat (client , users .get (owner_id ) or chats .get (owner_id )),
353349 owner_name = star_gift .owner_name ,
354350 owner_address = star_gift .owner_address ,
355351 gift_address = star_gift .gift_address ,
356- last_resale_star_count = last_resale_star_count ,
357- last_resale_ton_count = last_resale_ton_count ,
352+ resale_parameters = types .GiftResaleParameters ._parse (star_gift .resell_amount , star_gift .resale_ton_only ),
358353 publisher_chat = types .Chat ._parse_chat (client , chats .get (utils .get_raw_peer_id (star_gift .released_by ))),
359354 is_upgraded = True ,
360355 raw = star_gift ,
@@ -626,7 +621,7 @@ async def wear(self) -> bool:
626621 )
627622 )
628623
629- async def buy (self , new_owner_chat_id : Optional [Union [int , str ]] = None , star_count : Optional [int ] = None ) -> Optional ["types.Message" ]:
624+ async def buy (self , new_owner_chat_id : Optional [Union [int , str ]] = None , price : Optional ["types.GiftResalePrice" ] = None ) -> Optional ["types.Message" ]:
630625 """Bound method *buy* of :obj:`~pyrogram.types.Gift`.
631626
632627 .. note::
@@ -650,10 +645,16 @@ async def buy(self, new_owner_chat_id: Optional[Union[int, str]] = None, star_co
650645 if new_owner_chat_id is None :
651646 new_owner_chat_id = "me"
652647
648+ if price is None :
649+ if self .resale_parameters .toncoin_only :
650+ price = types .GiftResalePriceTon (toncoin_cent_count = self .resale_parameters .toncoin_cent_count )
651+ else :
652+ price = types .GiftResalePriceStar (star_count = self .resale_parameters .star_count )
653+
653654 return await self ._client .send_resold_gift (
654655 gift_link = self .link ,
655656 new_owner_chat_id = new_owner_chat_id ,
656- star_count = star_count
657+ price = price
657658 )
658659
659660 async def send (
0 commit comments