Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BotAPI7.9 #731

Open
wants to merge 1 commit into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading