Skip to content

Commit cf26fc2

Browse files
authored
Merge pull request #2427 from coder2020official/botapi-81
Bot API 8.1
2 parents 64baf03 + d234089 commit cf26fc2

File tree

2 files changed

+94
-4
lines changed

2 files changed

+94
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.</p>
1111
<p align="center">Both synchronous and asynchronous.</p>
1212

13-
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#november-17-2024"><img src="https://img.shields.io/badge/Bot%20API-8.0-blue?logo=telegram" alt="Supported Bot API version"></a>
13+
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#november-17-2024"><img src="https://img.shields.io/badge/Bot%20API-8.1-blue?logo=telegram" alt="Supported Bot API version"></a>
1414

1515
<h2><a href='https://pytba.readthedocs.io/en/latest/index.html'>Official documentation</a></h2>
1616
<h2><a href='https://pytba.readthedocs.io/ru/latest/index.html'>Official ru documentation</a></h2>

telebot/types.py

Lines changed: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10411,6 +10411,8 @@ def de_json(cls, json_string):
1041110411
return TransactionPartnerTelegramAds.de_json(obj)
1041210412
elif obj["type"] == "telegram_api":
1041310413
return TransactionPartnerTelegramApi.de_json(obj)
10414+
elif obj["type"] == "affiliate_program":
10415+
return TransactionPartnerAffiliateProgram.de_json(obj)
1041410416
elif obj["type"] == "other":
1041510417
return TransactionPartnerOther.de_json(obj)
1041610418

@@ -10486,6 +10488,9 @@ class TransactionPartnerUser(TransactionPartner):
1048610488
:param user: Information about the user
1048710489
:type user: :class:`User`
1048810490
10491+
:param affiliate: Optional. Information about the affiliate that received a commission via this transaction
10492+
:type affiliate: :class:`AffiliateInfo`
10493+
1048910494
:param invoice_payload: Optional, Bot-specified invoice payload
1049010495
:type invoice_payload: :obj:`str`
1049110496
@@ -10502,10 +10507,11 @@ class TransactionPartnerUser(TransactionPartner):
1050210507
:rtype: :class:`TransactionPartnerUser`
1050310508
"""
1050410509

10505-
def __init__(self, type, user, invoice_payload=None, paid_media: Optional[List[PaidMedia]] = None,
10510+
def __init__(self, type, user, affiliate=None, invoice_payload=None, paid_media: Optional[List[PaidMedia]] = None,
1050610511
subscription_period=None, gift: Optional[Gift] = None, **kwargs):
1050710512
self.type: str = type
1050810513
self.user: User = user
10514+
self.affiliate: Optional[AffiliateInfo] = affiliate
1050910515
self.invoice_payload: Optional[str] = invoice_payload
1051010516
self.paid_media: Optional[List[PaidMedia]] = paid_media
1051110517
self.subscription_period: Optional[int] = subscription_period
@@ -10520,6 +10526,8 @@ def de_json(cls, json_string):
1052010526
obj['paid_media'] = [PaidMedia.de_json(media) for media in obj['paid_media']]
1052110527
if 'gift' in obj:
1052210528
obj['gift'] = Gift.de_json(obj['gift'])
10529+
if 'affiliate' in obj:
10530+
obj['affiliate'] = AffiliateInfo.de_json(obj['affiliate'])
1052310531
return cls(**obj)
1052410532

1052510533

@@ -10584,6 +10592,9 @@ class StarTransaction(JsonDeserializable):
1058410592
:param amount: Number of Telegram Stars transferred by the transaction
1058510593
:type amount: :obj:`int`
1058610594
10595+
:param nanostar_amount: Optional. The number of 1/1000000000 shares of Telegram Stars transferred by the transaction; from 0 to 999999999
10596+
:type nanostar_amount: :obj:`int`
10597+
1058710598
:param date: Date the transaction was created in Unix time
1058810599
:type date: :obj:`int`
1058910600
@@ -10607,12 +10618,13 @@ def de_json(cls, json_string):
1060710618
obj['receiver'] = TransactionPartner.de_json(obj['receiver'])
1060810619
return cls(**obj)
1060910620

10610-
def __init__(self, id, amount, date, source=None, receiver=None, **kwargs):
10621+
def __init__(self, id, amount, date, source=None, receiver=None, nanostar_amount=None, **kwargs):
1061110622
self.id: str = id
1061210623
self.amount: int = amount
1061310624
self.date: int = date
1061410625
self.source: Optional[TransactionPartner] = source
1061510626
self.receiver: Optional[TransactionPartner] = receiver
10627+
self.nanostar_amount: Optional[int] = nanostar_amount
1061610628

1061710629

1061810630
class StarTransactions(JsonDeserializable):
@@ -11093,4 +11105,82 @@ def de_json(cls, json_string):
1109311105
obj = cls.check_json(json_string)
1109411106
obj['gifts'] = [Gift.de_json(gift) for gift in obj['gifts']]
1109511107
return cls(**obj)
11096-
11108+
11109+
11110+
class TransactionPartnerAffiliateProgram(TransactionPartner):
11111+
"""
11112+
Describes the affiliate program that issued the affiliate commission received via this transaction.
11113+
11114+
Telegram documentation: https://core.telegram.org/bots/api#transactionpartneraffiliateprogram
11115+
11116+
:param type: Type of the transaction partner, always “affiliate_program”
11117+
:type type: :obj:`str`
11118+
11119+
:param sponsor_user: Optional. Information about the bot that sponsored the affiliate program
11120+
:type sponsor_user: :class:`User`
11121+
11122+
:param commission_per_mille: The number of Telegram Stars received by the bot for each 1000 Telegram Stars received by the affiliate program sponsor from referred users
11123+
:type commission_per_mille: :obj:`int`
11124+
11125+
:return: Instance of the class
11126+
:rtype: :class:`TransactionPartnerAffiliateProgram`
11127+
"""
11128+
11129+
def __init__(self, type, commission_per_mille, sponsor_user=None, **kwargs):
11130+
self.type: str = type
11131+
self.sponsor_user: Optional[User] = sponsor_user
11132+
self.commission_per_mille: int = commission_per_mille
11133+
11134+
@classmethod
11135+
def de_json(cls, json_string):
11136+
if json_string is None: return None
11137+
obj = cls.check_json(json_string)
11138+
if 'sponsor_user' in obj:
11139+
obj['sponsor_user'] = User.de_json(obj['sponsor_user'])
11140+
11141+
return cls(**obj)
11142+
11143+
11144+
class AffiliateInfo(JsonDeserializable):
11145+
"""
11146+
Contains information about the affiliate that received a commission via this transaction.
11147+
11148+
Telegram documentation: https://core.telegram.org/bots/api#affiliateinfo
11149+
11150+
:param affiliate_user: Optional. The bot or the user that received an affiliate commission if it was received by a bot or a user
11151+
:type affiliate_user: :class:`User`
11152+
11153+
:param affiliate_chat: Optional. The chat that received an affiliate commission if it was received by a chat
11154+
:type affiliate_chat: :class:`Chat`
11155+
11156+
:param commission_per_mille: The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the bot from referred users
11157+
:type commission_per_mille: :obj:`int`
11158+
11159+
:param amount: Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for refunds
11160+
:type amount: :obj:`int`
11161+
11162+
:param nanostar_amount: Optional. The number of 1/1000000000 shares of Telegram Stars received by the affiliate; from -999999999 to 999999999; can be negative for refunds
11163+
:type nanostar_amount: :obj:`int`
11164+
11165+
:return: Instance of the class
11166+
:rtype: :class:`AffiliateInfo`
11167+
"""
11168+
11169+
def __init__(self, commission_per_mille, amount, affiliate_user=None, affiliate_chat=None, nanostar_amount=None, **kwargs):
11170+
self.affiliate_user: Optional[User] = affiliate_user
11171+
self.affiliate_chat: Optional[Chat] = affiliate_chat
11172+
self.commission_per_mille: int = commission_per_mille
11173+
self.amount: int = amount
11174+
self.nanostar_amount: Optional[int] = nanostar_amount
11175+
11176+
@classmethod
11177+
def de_json(cls, json_string):
11178+
if json_string is None: return None
11179+
obj = cls.check_json(json_string)
11180+
if 'affiliate_user' in obj:
11181+
obj['affiliate_user'] = User.de_json(obj['affiliate_user'])
11182+
if 'affiliate_chat' in obj:
11183+
obj['affiliate_chat'] = Chat.de_json(obj['affiliate_chat'])
11184+
return cls(**obj)
11185+
11186+

0 commit comments

Comments
 (0)