Update Gift class: add ton_address and clarify owner info.

Signed-off-by: Ling-ex <nekochan@rizkiofficial.com>
This commit is contained in:
Ling-ex 2025-05-24 18:01:40 +00:00
parent a10dd419d7
commit b2ca66bb9e

View file

@ -77,13 +77,16 @@ class Gift(Object):
User who sent the star gift. User who sent the star gift.
owner (:obj:`~pyrogram.types.Chat`, *optional*): owner (:obj:`~pyrogram.types.Chat`, *optional*):
Current gift owner. Only available if the nfts is in telegram.
owner_name (``str``, *optional*): owner_name (``str``, *optional*):
Name of the user who received the star gift. Name of the user who received the star gift.
owner_address (``str``, *optional*): owner_address (``str``, *optional*):
Address of the gift owner in TON blockchain. Only available if the nfts is in ton network.
ton_address (``str``, *optional*):
Only available if the nfts is in ton network.
price (``int``, *optional*): price (``int``, *optional*):
Price of this gift in stars. Price of this gift in stars.
@ -163,6 +166,7 @@ class Gift(Object):
owner: Optional["types.Chat"] = None, owner: Optional["types.Chat"] = None,
owner_name: Optional[str] = None, owner_name: Optional[str] = None,
owner_address: Optional[str] = None, owner_address: Optional[str] = None,
ton_address: Optional[str] = None,
price: Optional[int] = None, price: Optional[int] = None,
convert_price: Optional[int] = None, convert_price: Optional[int] = None,
upgrade_price: Optional[int] = None, upgrade_price: Optional[int] = None,
@ -201,6 +205,7 @@ class Gift(Object):
self.owner = owner self.owner = owner
self.owner_name = owner_name self.owner_name = owner_name
self.owner_address = owner_address self.owner_address = owner_address
self.ton_address = ton_address
self.price = price self.price = price
self.convert_price = convert_price self.convert_price = convert_price
self.upgrade_price = upgrade_price self.upgrade_price = upgrade_price
@ -277,9 +282,15 @@ class Gift(Object):
) or None, ) or None,
available_amount=getattr(star_gift, "availability_issued", None), available_amount=getattr(star_gift, "availability_issued", None),
total_amount=getattr(star_gift, "availability_total", None), total_amount=getattr(star_gift, "availability_total", None),
owner=types.Chat._parse_chat(client, users.get(owner_id) or chats.get(owner_id)), owner=(
types.Chat._parse_chat(client, users.get(owner_id) or
chats.get(owner_id))
if owner_id is not None
else None
),
owner_name=getattr(star_gift, "owner_name", None), owner_name=getattr(star_gift, "owner_name", None),
owner_address=getattr(star_gift, "owner_address", None), owner_address=getattr(star_gift, "owner_address", None),
ton_address=getattr(star_gift, "gift_address", None),
is_upgraded=True, is_upgraded=True,
raw=star_gift, raw=star_gift,
client=client client=client