Skip to content

Commit

Permalink
8.1 (#137)
Browse files Browse the repository at this point in the history
* api 8.1

* readme
  • Loading branch information
negasus authored Dec 19, 2024
1 parent 2ca1689 commit dda4073
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.12.0 (2024-12-19)

- support API v8.1

## v1.11.1 (2024-11-21)

- fix CreateNewStickerSetParams (#132)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
54 changes: 39 additions & 15 deletions models/star.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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{}
Expand All @@ -61,17 +67,34 @@ 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"`
PaidMediaPayload string `json:"paid_media_payload,omitempty"`
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"`
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dda4073

Please sign in to comment.