From 98a27d65b19ae5f2911815cbc026c1dc7c46c270 Mon Sep 17 00:00:00 2001 From: Apolisk Date: Thu, 15 Aug 2024 16:24:48 +0300 Subject: [PATCH] BotAPI7.9 --- chat.go | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ stars.go | 1 + 2 files changed, 53 insertions(+) diff --git a/chat.go b/chat.go index 4d031797..15ea2d3c 100644 --- a/chat.go +++ b/chat.go @@ -411,6 +411,33 @@ func (b *Bot) CreateInviteLink(chat Recipient, link *ChatInviteLink) (*ChatInvit return &resp.Result, nil } +// CreateChatSubscriptionInviteLink creates a subscription invite link for a channel chat. +func (b *Bot) CreateChatSubscriptionInviteLink(chat Recipient, subscriptionPeriod, subscriptionPrice int, link *ChatInviteLink) (*ChatInviteLink, error) { + params := map[string]string{ + "chat_id": chat.Recipient(), + "subscription_period": strconv.Itoa(subscriptionPeriod), + "subscription_price": strconv.Itoa(subscriptionPrice), + } + + if link != nil { + params["name"] = link.Name + } + + data, err := b.Raw("createChatSubscriptionInviteLink", params) + if err != nil { + return nil, err + } + + var resp struct { + Result ChatInviteLink `json:"result"` + } + if err := json.Unmarshal(data, &resp); err != nil { + return nil, wrapError(err) + } + + return &resp.Result, nil +} + // EditInviteLink edits a non-primary invite link created by the bot. func (b *Bot) EditInviteLink(chat Recipient, link *ChatInviteLink) (*ChatInviteLink, error) { params := map[string]string{ @@ -445,6 +472,31 @@ func (b *Bot) EditInviteLink(chat Recipient, link *ChatInviteLink) (*ChatInviteL return &resp.Result, nil } +// EditChatSubscriptionInviteLink edits a subscription invite link created by the bot. +func (b *Bot) EditChatSubscriptionInviteLink(chat Recipient, link *ChatInviteLink) (*ChatInviteLink, error) { + params := map[string]string{ + "chat_id": chat.Recipient(), + } + if link != nil { + params["invite_link"] = link.InviteLink + params["name"] = link.Name + } + + data, err := b.Raw("editChatSubscriptionInviteLink", params) + if err != nil { + return nil, err + } + + var resp struct { + Result ChatInviteLink `json:"result"` + } + if err := json.Unmarshal(data, &resp); err != nil { + return nil, wrapError(err) + } + + return &resp.Result, nil +} + // RevokeInviteLink revokes an invite link created by the bot. func (b *Bot) RevokeInviteLink(chat Recipient, link string) (*ChatInviteLink, error) { params := map[string]string{ diff --git a/stars.go b/stars.go index 9d837c4f..89406235 100644 --- a/stars.go +++ b/stars.go @@ -49,6 +49,7 @@ type TransactionPartner struct { // (Optional) State of the transaction if the transaction is outgoing$$ Withdrawal RevenueWithdrawal `json:"withdrawal_state,omitempty"` + PaidMedia []PaidMedia `json:"paid_media"` } type RevenueWithdrawal struct {