From dda407358e6c3ac9a5062c1d8b98423c246850b6 Mon Sep 17 00:00:00 2001 From: Andrew Privalov Date: Thu, 19 Dec 2024 15:12:11 +0300 Subject: [PATCH] 8.1 (#137) * api 8.1 * readme --- CHANGELOG.md | 4 ++++ README.md | 2 +- models/star.go | 54 ++++++++++++++++++++++++++++++++++++-------------- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12efcf7..77594a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v1.12.0 (2024-12-19) + +- support API v8.1 + ## v1.11.1 (2024-11-21) - fix CreateNewStickerSetParams (#132) diff --git a/README.md b/README.md index 42a47e7..77667df 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ > [Telegram Group](https://t.me/gotelegrambotui) -> Supports Bot API version: [8.0](https://core.telegram.org/bots/api#november-17-2024) from November 17, 2024 +> Supports Bot API version: [8.1](https://core.telegram.org/bots/api#december-4-2024) from December 4, 2024 It's a Go zero-dependencies telegram bot framework diff --git a/models/star.go b/models/star.go index 6ede4ce..a8f2c48 100644 --- a/models/star.go +++ b/models/star.go @@ -8,22 +8,24 @@ import ( type TransactionPartnerType string const ( - TransactionPartnerTypeUser TransactionPartnerType = "user" - TransactionPartnerTypeFragment TransactionPartnerType = "fragment" - TransactionPartnerTypeTelegramAds TransactionPartnerType = "telegram_ads" - TransactionPartnerTypeTelegramApi TransactionPartnerType = "telegram_api" - TransactionPartnerTypeOther TransactionPartnerType = "other" + TransactionPartnerTypeUser TransactionPartnerType = "user" + TransactionPartnerTypeAffiliateProgram TransactionPartnerType = "affiliate_program" + TransactionPartnerTypeFragment TransactionPartnerType = "fragment" + TransactionPartnerTypeTelegramAds TransactionPartnerType = "telegram_ads" + TransactionPartnerTypeTelegramApi TransactionPartnerType = "telegram_api" + TransactionPartnerTypeOther TransactionPartnerType = "other" ) // TransactionPartner https://core.telegram.org/bots/api#transactionpartner type TransactionPartner struct { Type TransactionPartnerType - User *TransactionPartnerUser `json:"user,omitempty"` - Fragment *TransactionPartnerFragment `json:"fragment,omitempty"` - TelegramAds *TransactionPartnerTelegramAds `json:"telegram_ads,omitempty"` - TelegramApi *TransactionPartnerTelegramApi `json:"telegram_api,omitempty"` - Other *TransactionPartnerOther `json:"other,omitempty"` + User *TransactionPartnerUser `json:"user,omitempty"` + AffiliateProgram *TransactionPartnerAffiliateProgram `json:"affiliate_program,omitempty"` + Fragment *TransactionPartnerFragment `json:"fragment,omitempty"` + TelegramAds *TransactionPartnerTelegramAds `json:"telegram_ads,omitempty"` + TelegramApi *TransactionPartnerTelegramApi `json:"telegram_api,omitempty"` + Other *TransactionPartnerOther `json:"other,omitempty"` } func (m *TransactionPartner) UnmarshalJSON(data []byte) error { @@ -40,6 +42,10 @@ func (m *TransactionPartner) UnmarshalJSON(data []byte) error { m.Type = TransactionPartnerTypeUser m.User = &TransactionPartnerUser{} return json.Unmarshal(data, m.User) + case TransactionPartnerTypeAffiliateProgram: + m.Type = TransactionPartnerTypeAffiliateProgram + m.AffiliateProgram = &TransactionPartnerAffiliateProgram{} + return json.Unmarshal(data, m.AffiliateProgram) case TransactionPartnerTypeFragment: m.Type = TransactionPartnerTypeFragment m.Fragment = &TransactionPartnerFragment{} @@ -61,10 +67,20 @@ func (m *TransactionPartner) UnmarshalJSON(data []byte) error { return fmt.Errorf("unsupported TransactionPartner type") } +// AffiliateInfo https://core.telegram.org/bots/api#affiliateinfo +type AffiliateInfo struct { + AffiliateUser *User `json:"affiliate_user,omitempty"` + AffiliateChat *Chat `json:"affiliate_chat,omitempty"` + CommissionPerMille int `json:"commission_per_mille"` + Amount int `json:"amount"` + NanostarAmount int `json:"nanostar_amount"` +} + // TransactionPartnerUser https://core.telegram.org/bots/api#transactionpartneruser type TransactionPartnerUser struct { Type TransactionPartnerType `json:"type"` User User `json:"user"` + Affiliate *AffiliateInfo `json:"affiliate,omitempty"` InvoicePayload string `json:"invoice_payload,omitempty"` SubscriptionPeriod int `json:"subscription_period,omitempty"` PaidMedia []*PaidMedia `json:"paid_media,omitempty"` @@ -72,6 +88,13 @@ type TransactionPartnerUser struct { Gift string `json:"gift,omitempty"` } +// TransactionPartnerAffiliateProgram https://core.telegram.org/bots/api#transactionpartneraffiliateprogram +type TransactionPartnerAffiliateProgram struct { + Type TransactionPartnerType `json:"type"` + SponsorUser *User `json:"sponsor_user,omitempty"` + CommissionPerMille int `json:"commission_per_mille"` +} + // TransactionPartnerFragment https://core.telegram.org/bots/api#transactionpartnerfragment type TransactionPartnerFragment struct { Type TransactionPartnerType `json:"type"` @@ -157,11 +180,12 @@ type RevenueWithdrawalStateFailed struct { // StarTransaction https://core.telegram.org/bots/api#startransaction type StarTransaction struct { - ID string `json:"id"` - Amount int `json:"amount"` - Date int `json:"date"` - Source *TransactionPartner `json:"source,omitempty"` - Receiver *TransactionPartner `json:"receiver,omitempty"` + ID string `json:"id"` + Amount int `json:"amount"` + NanostarAmount int `json:"nanostar_amount,omitempty"` + Date int `json:"date"` + Source *TransactionPartner `json:"source,omitempty"` + Receiver *TransactionPartner `json:"receiver,omitempty"` } // StarTransactions https://core.telegram.org/bots/api#startransactions