Skip to content

Commit

Permalink
BotAPI7.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Apolisk committed Aug 15, 2024
1 parent cc61a96 commit 98a27d6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
52 changes: 52 additions & 0 deletions chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down
1 change: 1 addition & 0 deletions stars.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 98a27d6

Please sign in to comment.