From bac89c30137cc81e943bee2e6f2fd43b9fcdbbcb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 14 Jun 2025 21:44:59 +0000 Subject: [PATCH] chore(deps): bump github.com/PaulSonOfLars/gotgbot/v2 Bumps [github.com/PaulSonOfLars/gotgbot/v2](https://github.com/PaulSonOfLars/gotgbot) from 2.0.0-rc.30 to 2.0.0-rc.32. - [Release notes](https://github.com/PaulSonOfLars/gotgbot/releases) - [Commits](https://github.com/PaulSonOfLars/gotgbot/compare/v2.0.0-rc.30...v2.0.0-rc.32) --- updated-dependencies: - dependency-name: github.com/PaulSonOfLars/gotgbot/v2 dependency-version: 2.0.0-rc.32 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- .../PaulSonOfLars/gotgbot/v2/.golangci.yaml | 8 +- .../PaulSonOfLars/gotgbot/v2/entities.go | 49 +- .../PaulSonOfLars/gotgbot/v2/gen_helpers.go | 55 + .../PaulSonOfLars/gotgbot/v2/gen_methods.go | 1272 +++++++++++++++- .../PaulSonOfLars/gotgbot/v2/gen_types.go | 1277 ++++++++++++++++- .../PaulSonOfLars/gotgbot/v2/spec_commit | 2 +- vendor/modules.txt | 4 +- 9 files changed, 2568 insertions(+), 105 deletions(-) diff --git a/go.mod b/go.mod index 330c6b66..dfaf6999 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.23.0 require ( dario.cat/mergo v1.0.1 github.com/AlecAivazis/survey/v2 v2.3.7 - github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.30 + github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.32 github.com/alecthomas/kong v1.6.1 github.com/bmatcuk/doublestar/v3 v3.0.0 github.com/containerd/platforms v0.2.1 diff --git a/go.sum b/go.sum index e4528841..71899041 100644 --- a/go.sum +++ b/go.sum @@ -15,8 +15,8 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s= github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w= -github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.30 h1:kPFkEzqg3+5gu077Zrg+24d0rO0Iwdx/ZUUHFFprfsc= -github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.30/go.mod h1:kL1v4iIjlalwm3gCYGvF4NLa3hs+aKEfRkNJvj4aoDU= +github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.32 h1:+YzI72wzNTcaPUDVcSxeYQdHfvEk8mPGZh/yTk5kkRg= +github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.32/go.mod h1:BSzsfjlE0wakLw2/U1FtO8rdVt+Z+4VyoGo/YcGD9QQ= github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg= github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM= github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ= diff --git a/vendor/github.com/PaulSonOfLars/gotgbot/v2/.golangci.yaml b/vendor/github.com/PaulSonOfLars/gotgbot/v2/.golangci.yaml index 006cbc74..8b175636 100644 --- a/vendor/github.com/PaulSonOfLars/gotgbot/v2/.golangci.yaml +++ b/vendor/github.com/PaulSonOfLars/gotgbot/v2/.golangci.yaml @@ -21,9 +21,6 @@ output: # print linter name in the end of issue text, default is true print-linter-name: true - # make issues output unique by line, default is true - uniq-by-line: true - # sorts results by: filepath, line and column sort-results: true @@ -44,7 +41,7 @@ linters: - durationcheck - errorlint - exhaustive - - exportloopref + - copyloopvar - forbidigo - forcetypeassert - godot @@ -72,6 +69,9 @@ linters: - unparam - wastedassign issues: + # make issues output unique by line, default is true + uniq-by-line: true + # Excluding configuration per-path, per-linter, per-text and per-source exclude-rules: - path: samples/ diff --git a/vendor/github.com/PaulSonOfLars/gotgbot/v2/entities.go b/vendor/github.com/PaulSonOfLars/gotgbot/v2/entities.go index fa9c20d8..9546b929 100644 --- a/vendor/github.com/PaulSonOfLars/gotgbot/v2/entities.go +++ b/vendor/github.com/PaulSonOfLars/gotgbot/v2/entities.go @@ -7,20 +7,20 @@ type ParsedMessageEntity struct { Text string `json:"text"` } -// ParseEntities calls Message.ParseEntity on all message text entities. -func (m Message) ParseEntities() (out []ParsedMessageEntity) { - return m.ParseEntityTypes(nil) +// ParseEntity parses a single MessageEntity into a ParsedMessageEntity. +func ParseEntity(text string, entity MessageEntity) ParsedMessageEntity { + return parseEntity(entity, utf16.Encode([]rune(text))) } -// ParseCaptionEntities calls Message.ParseEntity on all message caption entities. -func (m Message) ParseCaptionEntities() (out []ParsedMessageEntity) { - return m.ParseCaptionEntityTypes(nil) +// ParseEntities parses all MessageEntity items into a list of ParsedMessageEntity. +func ParseEntities(text string, entities []MessageEntity) (out []ParsedMessageEntity) { + return ParseEntityTypes(text, entities, nil) } -// ParseEntityTypes calls Message.ParseEntity on a subset of message text entities. -func (m Message) ParseEntityTypes(accepted map[string]struct{}) (out []ParsedMessageEntity) { - utf16Text := utf16.Encode([]rune(m.Text)) - for _, ent := range m.Entities { +// ParseEntityTypes parses a subset of MessageEntity items into a list of ParsedMessageEntity. +func ParseEntityTypes(text string, entities []MessageEntity, accepted map[string]struct{}) (out []ParsedMessageEntity) { + utf16Text := utf16.Encode([]rune(text)) + for _, ent := range entities { if _, ok := accepted[ent.Type]; ok || accepted == nil { out = append(out, parseEntity(ent, utf16Text)) } @@ -28,25 +28,34 @@ func (m Message) ParseEntityTypes(accepted map[string]struct{}) (out []ParsedMes return out } -// ParseCaptionEntityTypes calls Message.ParseEntity on a subset of message caption entities. +// ParseEntities parses all message text entities into a list of ParsedMessageEntity. +func (m Message) ParseEntities() (out []ParsedMessageEntity) { + return m.ParseEntityTypes(nil) +} + +// ParseCaptionEntities parses all message caption entities into a list of ParsedMessageEntity. +func (m Message) ParseCaptionEntities() (out []ParsedMessageEntity) { + return m.ParseCaptionEntityTypes(nil) +} + +// ParseEntityTypes parses a subset of message text entities into a list of ParsedMessageEntity. +func (m Message) ParseEntityTypes(accepted map[string]struct{}) (out []ParsedMessageEntity) { + return ParseEntityTypes(m.Text, m.Entities, accepted) +} + +// ParseCaptionEntityTypes parses a subset of message caption entities into a list of ParsedMessageEntity. func (m Message) ParseCaptionEntityTypes(accepted map[string]struct{}) (out []ParsedMessageEntity) { - utf16Caption := utf16.Encode([]rune(m.Caption)) - for _, ent := range m.CaptionEntities { - if _, ok := accepted[ent.Type]; ok || accepted == nil { - out = append(out, parseEntity(ent, utf16Caption)) - } - } - return out + return ParseEntityTypes(m.Caption, m.CaptionEntities, accepted) } // ParseEntity parses a single message text entity to populate text contents, URL, and offsets in UTF8. func (m Message) ParseEntity(entity MessageEntity) ParsedMessageEntity { - return parseEntity(entity, utf16.Encode([]rune(m.Text))) + return ParseEntity(m.Text, entity) } // ParseCaptionEntity parses a single message caption entity to populate text contents, URL, and offsets in UTF8. func (m Message) ParseCaptionEntity(entity MessageEntity) ParsedMessageEntity { - return parseEntity(entity, utf16.Encode([]rune(m.Caption))) + return ParseEntity(m.Caption, entity) } func parseEntity(entity MessageEntity, utf16Text []uint16) ParsedMessageEntity { diff --git a/vendor/github.com/PaulSonOfLars/gotgbot/v2/gen_helpers.go b/vendor/github.com/PaulSonOfLars/gotgbot/v2/gen_helpers.go index c3f34a5b..ec70e299 100644 --- a/vendor/github.com/PaulSonOfLars/gotgbot/v2/gen_helpers.go +++ b/vendor/github.com/PaulSonOfLars/gotgbot/v2/gen_helpers.go @@ -121,6 +121,11 @@ func (c Chat) PromoteMember(b *Bot, userId int64, opts *PromoteChatMemberOpts) ( return b.PromoteChatMember(c.Id, userId, opts) } +// RemoveVerification Helper method for Bot.RemoveChatVerification. +func (c Chat) RemoveVerification(b *Bot, opts *RemoveChatVerificationOpts) (bool, error) { + return b.RemoveChatVerification(c.Id, opts) +} + // RestrictMember Helper method for Bot.RestrictChatMember. func (c Chat) RestrictMember(b *Bot, userId int64, permissions ChatPermissions, opts *RestrictChatMemberOpts) (bool, error) { return b.RestrictChatMember(c.Id, userId, permissions, opts) @@ -199,6 +204,16 @@ func (c Chat) UnpinMessage(b *Bot, opts *UnpinChatMessageOpts) (bool, error) { return b.UnpinChatMessage(c.Id, opts) } +// Verify Helper method for Bot.VerifyChat. +func (c Chat) Verify(b *Bot, opts *VerifyChatOpts) (bool, error) { + return b.VerifyChat(c.Id, opts) +} + +// Send Helper method for Bot.SendGift. +func (g Gift) Send(b *Bot, opts *SendGiftOpts) (bool, error) { + return b.SendGift(g.Id, opts) +} + // Copy Helper method for Bot.CopyMessage. func (im InaccessibleMessage) Copy(b *Bot, chatId int64, opts *CopyMessageOpts) (*MessageId, error) { return b.CopyMessage(chatId, im.Chat.Id, im.MessageId, opts) @@ -299,6 +314,11 @@ func (im InaccessibleMessage) Pin(b *Bot, opts *PinChatMessageOpts) (bool, error return b.PinChatMessage(im.Chat.Id, im.MessageId, opts) } +// ReadBusiness Helper method for Bot.ReadBusinessMessage. +func (im InaccessibleMessage) ReadBusiness(b *Bot, businessConnectionId string, opts *ReadBusinessMessageOpts) (bool, error) { + return b.ReadBusinessMessage(businessConnectionId, im.Chat.Id, im.MessageId, opts) +} + // SetReaction Helper method for Bot.SetMessageReaction. func (im InaccessibleMessage) SetReaction(b *Bot, opts *SetMessageReactionOpts) (bool, error) { return b.SetMessageReaction(im.Chat.Id, im.MessageId, opts) @@ -438,6 +458,11 @@ func (m Message) Pin(b *Bot, opts *PinChatMessageOpts) (bool, error) { return b.PinChatMessage(m.Chat.Id, m.MessageId, opts) } +// ReadBusiness Helper method for Bot.ReadBusinessMessage. +func (m Message) ReadBusiness(b *Bot, businessConnectionId string, opts *ReadBusinessMessageOpts) (bool, error) { + return b.ReadBusinessMessage(businessConnectionId, m.Chat.Id, m.MessageId, opts) +} + // SetReaction Helper method for Bot.SetMessageReaction. func (m Message) SetReaction(b *Bot, opts *SetMessageReactionOpts) (bool, error) { return b.SetMessageReaction(m.Chat.Id, m.MessageId, opts) @@ -482,6 +507,21 @@ func (sq ShippingQuery) Answer(b *Bot, ok bool, opts *AnswerShippingQueryOpts) ( return b.AnswerShippingQuery(sq.Id, ok, opts) } +// Delete Helper method for Bot.DeleteStory. +func (s Story) Delete(b *Bot, businessConnectionId string, opts *DeleteStoryOpts) (bool, error) { + return b.DeleteStory(businessConnectionId, s.Id, opts) +} + +// Edit Helper method for Bot.EditStory. +func (s Story) Edit(b *Bot, businessConnectionId string, content InputStoryContent, opts *EditStoryOpts) (*Story, error) { + return b.EditStory(businessConnectionId, s.Id, content, opts) +} + +// EditStarSubscription Helper method for Bot.EditUserStarSubscription. +func (u User) EditStarSubscription(b *Bot, telegramPaymentChargeId string, isCanceled bool, opts *EditUserStarSubscriptionOpts) (bool, error) { + return b.EditUserStarSubscription(u.Id, telegramPaymentChargeId, isCanceled, opts) +} + // GetChatBoosts Helper method for Bot.GetUserChatBoosts. func (u User) GetChatBoosts(b *Bot, chatId int64, opts *GetUserChatBoostsOpts) (*UserChatBoosts, error) { return b.GetUserChatBoosts(chatId, u.Id, opts) @@ -491,3 +531,18 @@ func (u User) GetChatBoosts(b *Bot, chatId int64, opts *GetUserChatBoostsOpts) ( func (u User) GetProfilePhotos(b *Bot, opts *GetUserProfilePhotosOpts) (*UserProfilePhotos, error) { return b.GetUserProfilePhotos(u.Id, opts) } + +// RemoveVerification Helper method for Bot.RemoveUserVerification. +func (u User) RemoveVerification(b *Bot, opts *RemoveUserVerificationOpts) (bool, error) { + return b.RemoveUserVerification(u.Id, opts) +} + +// SetEmojiStatus Helper method for Bot.SetUserEmojiStatus. +func (u User) SetEmojiStatus(b *Bot, opts *SetUserEmojiStatusOpts) (bool, error) { + return b.SetUserEmojiStatus(u.Id, opts) +} + +// Verify Helper method for Bot.VerifyUser. +func (u User) Verify(b *Bot, opts *VerifyUserOpts) (bool, error) { + return b.VerifyUser(u.Id, opts) +} diff --git a/vendor/github.com/PaulSonOfLars/gotgbot/v2/gen_methods.go b/vendor/github.com/PaulSonOfLars/gotgbot/v2/gen_methods.go index f7bebb76..51d23a62 100644 --- a/vendor/github.com/PaulSonOfLars/gotgbot/v2/gen_methods.go +++ b/vendor/github.com/PaulSonOfLars/gotgbot/v2/gen_methods.go @@ -30,21 +30,20 @@ func (bot *Bot) AddStickerToSet(userId int64, name string, sticker InputSticker, // AddStickerToSetWithContext is the same as Bot.AddStickerToSet, but with a context.Context parameter func (bot *Bot) AddStickerToSetWithContext(ctx context.Context, userId int64, name string, sticker InputSticker, opts *AddStickerToSetOpts) (bool, error) { v := map[string]string{} - data := map[string]FileReader{} v["user_id"] = strconv.FormatInt(userId, 10) v["name"] = name - inputBs, err := sticker.InputParams("sticker", data) + bs, err := json.Marshal(sticker) if err != nil { return false, fmt.Errorf("failed to marshal field sticker: %w", err) } - v["sticker"] = string(inputBs) + v["sticker"] = string(bs) var reqOpts *RequestOpts if opts != nil { reqOpts = opts.RequestOpts } - r, err := bot.RequestWithContext(ctx, "addStickerToSet", v, data, reqOpts) + r, err := bot.RequestWithContext(ctx, "addStickerToSet", v, nil, reqOpts) if err != nil { return false, err } @@ -213,7 +212,7 @@ func (bot *Bot) AnswerPreCheckoutQueryWithContext(ctx context.Context, preChecko type AnswerShippingQueryOpts struct { // Required if ok is True. A JSON-serialized array of available shipping options. ShippingOptions []ShippingOption - // Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user. + // Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable"). Telegram will display this message to the user. ErrorMessage string // RequestOpts are an additional optional field to configure timeouts for individual requests RequestOpts *RequestOpts @@ -519,10 +518,48 @@ func (bot *Bot) CloseGeneralForumTopicWithContext(ctx context.Context, chatId in return b, json.Unmarshal(r, &b) } +// ConvertGiftToStarsOpts is the set of optional fields for Bot.ConvertGiftToStars and Bot.ConvertGiftToStarsWithContext. +type ConvertGiftToStarsOpts struct { + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// ConvertGiftToStars (https://core.telegram.org/bots/api#convertgifttostars) +// +// Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns True on success. +// - businessConnectionId (type string): Unique identifier of the business connection +// - ownedGiftId (type string): Unique identifier of the regular gift that should be converted to Telegram Stars +// - opts (type ConvertGiftToStarsOpts): All optional parameters. +func (bot *Bot) ConvertGiftToStars(businessConnectionId string, ownedGiftId string, opts *ConvertGiftToStarsOpts) (bool, error) { + return bot.ConvertGiftToStarsWithContext(context.Background(), businessConnectionId, ownedGiftId, opts) +} + +// ConvertGiftToStarsWithContext is the same as Bot.ConvertGiftToStars, but with a context.Context parameter +func (bot *Bot) ConvertGiftToStarsWithContext(ctx context.Context, businessConnectionId string, ownedGiftId string, opts *ConvertGiftToStarsOpts) (bool, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + v["owned_gift_id"] = ownedGiftId + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "convertGiftToStars", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + // CopyMessageOpts is the set of optional fields for Bot.CopyMessage and Bot.CopyMessageWithContext. type CopyMessageOpts struct { // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only MessageThreadId int64 + // New start timestamp for the copied video in the message + VideoStartTimestamp int64 // New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept Caption *string // Mode for parsing entities in the new caption. See formatting options for more details. @@ -566,6 +603,9 @@ func (bot *Bot) CopyMessageWithContext(ctx context.Context, chatId int64, fromCh if opts.MessageThreadId != 0 { v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) } + if opts.VideoStartTimestamp != 0 { + v["video_start_timestamp"] = strconv.FormatInt(opts.VideoStartTimestamp, 10) + } if opts.Caption != nil { v["caption"] = *opts.Caption } @@ -736,7 +776,7 @@ type CreateChatSubscriptionInviteLinkOpts struct { // Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object. // - chatId (type int64): Unique identifier for the target channel chat // - subscriptionPeriod (type int64): The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days). -// - subscriptionPrice (type int64): The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500 +// - subscriptionPrice (type int64): The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-10000 // - opts (type CreateChatSubscriptionInviteLinkOpts): All optional parameters. func (bot *Bot) CreateChatSubscriptionInviteLink(chatId int64, subscriptionPeriod int64, subscriptionPrice int64, opts *CreateChatSubscriptionInviteLinkOpts) (*ChatInviteLink, error) { return bot.CreateChatSubscriptionInviteLinkWithContext(context.Background(), chatId, subscriptionPeriod, subscriptionPrice, opts) @@ -814,8 +854,12 @@ func (bot *Bot) CreateForumTopicWithContext(ctx context.Context, chatId int64, n // CreateInvoiceLinkOpts is the set of optional fields for Bot.CreateInvoiceLink and Bot.CreateInvoiceLinkWithContext. type CreateInvoiceLinkOpts struct { + // Unique identifier of the business connection on behalf of which the link will be created. For payments in Telegram Stars only. + BusinessConnectionId string // Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars. ProviderToken string + // The number of seconds the subscription will be active for before the next payment. The currency must be set to "XTR" (Telegram Stars) if the parameter is used. Currently, it must always be 2592000 (30 days) if specified. Any number of subscriptions can be active for a given bot at the same time, including multiple concurrent subscriptions from the same user. Subscription price must no exceed 10000 Telegram Stars. + SubscriptionPeriod int64 // The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in Telegram Stars. MaxTipAmount int64 // A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount. @@ -876,7 +920,11 @@ func (bot *Bot) CreateInvoiceLinkWithContext(ctx context.Context, title string, v["prices"] = string(bs) } if opts != nil { + v["business_connection_id"] = opts.BusinessConnectionId v["provider_token"] = opts.ProviderToken + if opts.SubscriptionPeriod != 0 { + v["subscription_period"] = strconv.FormatInt(opts.SubscriptionPeriod, 10) + } if opts.MaxTipAmount != 0 { v["max_tip_amount"] = strconv.FormatInt(opts.MaxTipAmount, 10) } @@ -946,22 +994,13 @@ func (bot *Bot) CreateNewStickerSet(userId int64, name string, title string, sti // CreateNewStickerSetWithContext is the same as Bot.CreateNewStickerSet, but with a context.Context parameter func (bot *Bot) CreateNewStickerSetWithContext(ctx context.Context, userId int64, name string, title string, stickers []InputSticker, opts *CreateNewStickerSetOpts) (bool, error) { v := map[string]string{} - data := map[string]FileReader{} v["user_id"] = strconv.FormatInt(userId, 10) v["name"] = name v["title"] = title if stickers != nil { - var rawList []json.RawMessage - for idx, im := range stickers { - inputBs, err := im.InputParams("stickers"+strconv.Itoa(idx), data) - if err != nil { - return false, fmt.Errorf("failed to marshal list item %d for field stickers: %w", idx, err) - } - rawList = append(rawList, inputBs) - } - bs, err := json.Marshal(rawList) + bs, err := json.Marshal(stickers) if err != nil { - return false, fmt.Errorf("failed to marshal raw json list for field: stickers %w", err) + return false, fmt.Errorf("failed to marshal field stickers: %w", err) } v["stickers"] = string(bs) } @@ -975,7 +1014,7 @@ func (bot *Bot) CreateNewStickerSetWithContext(ctx context.Context, userId int64 reqOpts = opts.RequestOpts } - r, err := bot.RequestWithContext(ctx, "createNewStickerSet", v, data, reqOpts) + r, err := bot.RequestWithContext(ctx, "createNewStickerSet", v, nil, reqOpts) if err != nil { return false, err } @@ -1020,6 +1059,48 @@ func (bot *Bot) DeclineChatJoinRequestWithContext(ctx context.Context, chatId in return b, json.Unmarshal(r, &b) } +// DeleteBusinessMessagesOpts is the set of optional fields for Bot.DeleteBusinessMessages and Bot.DeleteBusinessMessagesWithContext. +type DeleteBusinessMessagesOpts struct { + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// DeleteBusinessMessages (https://core.telegram.org/bots/api#deletebusinessmessages) +// +// Delete messages on behalf of a business account. Requires the can_delete_outgoing_messages business bot right to delete messages sent by the bot itself, or the can_delete_all_messages business bot right to delete any message. Returns True on success. +// - businessConnectionId (type string): Unique identifier of the business connection on behalf of which to delete the messages +// - messageIds (type []int64): A JSON-serialized list of 1-100 identifiers of messages to delete. All messages must be from the same chat. See deleteMessage for limitations on which messages can be deleted +// - opts (type DeleteBusinessMessagesOpts): All optional parameters. +func (bot *Bot) DeleteBusinessMessages(businessConnectionId string, messageIds []int64, opts *DeleteBusinessMessagesOpts) (bool, error) { + return bot.DeleteBusinessMessagesWithContext(context.Background(), businessConnectionId, messageIds, opts) +} + +// DeleteBusinessMessagesWithContext is the same as Bot.DeleteBusinessMessages, but with a context.Context parameter +func (bot *Bot) DeleteBusinessMessagesWithContext(ctx context.Context, businessConnectionId string, messageIds []int64, opts *DeleteBusinessMessagesOpts) (bool, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + if messageIds != nil { + bs, err := json.Marshal(messageIds) + if err != nil { + return false, fmt.Errorf("failed to marshal field message_ids: %w", err) + } + v["message_ids"] = string(bs) + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "deleteBusinessMessages", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + // DeleteChatPhotoOpts is the set of optional fields for Bot.DeleteChatPhoto and Bot.DeleteChatPhotoWithContext. type DeleteChatPhotoOpts struct { // RequestOpts are an additional optional field to configure timeouts for individual requests @@ -1324,6 +1405,42 @@ func (bot *Bot) DeleteStickerSetWithContext(ctx context.Context, name string, op return b, json.Unmarshal(r, &b) } +// DeleteStoryOpts is the set of optional fields for Bot.DeleteStory and Bot.DeleteStoryWithContext. +type DeleteStoryOpts struct { + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// DeleteStory (https://core.telegram.org/bots/api#deletestory) +// +// Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns True on success. +// - businessConnectionId (type string): Unique identifier of the business connection +// - storyId (type int64): Unique identifier of the story to delete +// - opts (type DeleteStoryOpts): All optional parameters. +func (bot *Bot) DeleteStory(businessConnectionId string, storyId int64, opts *DeleteStoryOpts) (bool, error) { + return bot.DeleteStoryWithContext(context.Background(), businessConnectionId, storyId, opts) +} + +// DeleteStoryWithContext is the same as Bot.DeleteStory, but with a context.Context parameter +func (bot *Bot) DeleteStoryWithContext(ctx context.Context, businessConnectionId string, storyId int64, opts *DeleteStoryOpts) (bool, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + v["story_id"] = strconv.FormatInt(storyId, 10) + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "deleteStory", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + // DeleteWebhookOpts is the set of optional fields for Bot.DeleteWebhook and Bot.DeleteWebhookWithContext. type DeleteWebhookOpts struct { // Pass True to drop all pending updates @@ -1935,6 +2052,112 @@ func (bot *Bot) EditMessageTextWithContext(ctx context.Context, text string, opt } +// EditStoryOpts is the set of optional fields for Bot.EditStory and Bot.EditStoryWithContext. +type EditStoryOpts struct { + // Caption of the story, 0-2048 characters after entities parsing + Caption string + // Mode for parsing entities in the story caption. See formatting options for more details. + ParseMode string + // A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode + CaptionEntities []MessageEntity + // A JSON-serialized list of clickable areas to be shown on the story + Areas []StoryArea + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// EditStory (https://core.telegram.org/bots/api#editstory) +// +// Edits a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success. +// - businessConnectionId (type string): Unique identifier of the business connection +// - storyId (type int64): Unique identifier of the story to edit +// - content (type InputStoryContent): Content of the story +// - opts (type EditStoryOpts): All optional parameters. +func (bot *Bot) EditStory(businessConnectionId string, storyId int64, content InputStoryContent, opts *EditStoryOpts) (*Story, error) { + return bot.EditStoryWithContext(context.Background(), businessConnectionId, storyId, content, opts) +} + +// EditStoryWithContext is the same as Bot.EditStory, but with a context.Context parameter +func (bot *Bot) EditStoryWithContext(ctx context.Context, businessConnectionId string, storyId int64, content InputStoryContent, opts *EditStoryOpts) (*Story, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + v["story_id"] = strconv.FormatInt(storyId, 10) + bs, err := json.Marshal(content) + if err != nil { + return nil, fmt.Errorf("failed to marshal field content: %w", err) + } + v["content"] = string(bs) + if opts != nil { + v["caption"] = opts.Caption + v["parse_mode"] = opts.ParseMode + if opts.CaptionEntities != nil { + bs, err := json.Marshal(opts.CaptionEntities) + if err != nil { + return nil, fmt.Errorf("failed to marshal field caption_entities: %w", err) + } + v["caption_entities"] = string(bs) + } + if opts.Areas != nil { + bs, err := json.Marshal(opts.Areas) + if err != nil { + return nil, fmt.Errorf("failed to marshal field areas: %w", err) + } + v["areas"] = string(bs) + } + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "editStory", v, nil, reqOpts) + if err != nil { + return nil, err + } + + var s Story + return &s, json.Unmarshal(r, &s) +} + +// EditUserStarSubscriptionOpts is the set of optional fields for Bot.EditUserStarSubscription and Bot.EditUserStarSubscriptionWithContext. +type EditUserStarSubscriptionOpts struct { + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// EditUserStarSubscription (https://core.telegram.org/bots/api#edituserstarsubscription) +// +// Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success. +// - userId (type int64): Identifier of the user whose subscription will be edited +// - telegramPaymentChargeId (type string): Telegram payment identifier for the subscription +// - isCanceled (type bool): Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot. +// - opts (type EditUserStarSubscriptionOpts): All optional parameters. +func (bot *Bot) EditUserStarSubscription(userId int64, telegramPaymentChargeId string, isCanceled bool, opts *EditUserStarSubscriptionOpts) (bool, error) { + return bot.EditUserStarSubscriptionWithContext(context.Background(), userId, telegramPaymentChargeId, isCanceled, opts) +} + +// EditUserStarSubscriptionWithContext is the same as Bot.EditUserStarSubscription, but with a context.Context parameter +func (bot *Bot) EditUserStarSubscriptionWithContext(ctx context.Context, userId int64, telegramPaymentChargeId string, isCanceled bool, opts *EditUserStarSubscriptionOpts) (bool, error) { + v := map[string]string{} + v["user_id"] = strconv.FormatInt(userId, 10) + v["telegram_payment_charge_id"] = telegramPaymentChargeId + v["is_canceled"] = strconv.FormatBool(isCanceled) + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "editUserStarSubscription", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + // ExportChatInviteLinkOpts is the set of optional fields for Bot.ExportChatInviteLink and Bot.ExportChatInviteLinkWithContext. type ExportChatInviteLinkOpts struct { // RequestOpts are an additional optional field to configure timeouts for individual requests @@ -1973,6 +2196,8 @@ func (bot *Bot) ExportChatInviteLinkWithContext(ctx context.Context, chatId int6 type ForwardMessageOpts struct { // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only MessageThreadId int64 + // New start timestamp for the forwarded video in the message + VideoStartTimestamp int64 // Sends the message silently. Users will receive a notification with no sound. DisableNotification bool // Protects the contents of the forwarded message from forwarding and saving @@ -2002,6 +2227,9 @@ func (bot *Bot) ForwardMessageWithContext(ctx context.Context, chatId int64, fro if opts.MessageThreadId != 0 { v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) } + if opts.VideoStartTimestamp != 0 { + v["video_start_timestamp"] = strconv.FormatInt(opts.VideoStartTimestamp, 10) + } v["disable_notification"] = strconv.FormatBool(opts.DisableNotification) v["protect_content"] = strconv.FormatBool(opts.ProtectContent) } @@ -2077,6 +2305,134 @@ func (bot *Bot) ForwardMessagesWithContext(ctx context.Context, chatId int64, fr return m, json.Unmarshal(r, &m) } +// GetAvailableGiftsOpts is the set of optional fields for Bot.GetAvailableGifts and Bot.GetAvailableGiftsWithContext. +type GetAvailableGiftsOpts struct { + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// GetAvailableGifts (https://core.telegram.org/bots/api#getavailablegifts) +// +// Returns the list of gifts that can be sent by the bot to users and channel chats. Requires no parameters. Returns a Gifts object. +// - opts (type GetAvailableGiftsOpts): All optional parameters. +func (bot *Bot) GetAvailableGifts(opts *GetAvailableGiftsOpts) (*Gifts, error) { + return bot.GetAvailableGiftsWithContext(context.Background(), opts) +} + +// GetAvailableGiftsWithContext is the same as Bot.GetAvailableGifts, but with a context.Context parameter +func (bot *Bot) GetAvailableGiftsWithContext(ctx context.Context, opts *GetAvailableGiftsOpts) (*Gifts, error) { + v := map[string]string{} + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "getAvailableGifts", v, nil, reqOpts) + if err != nil { + return nil, err + } + + var g Gifts + return &g, json.Unmarshal(r, &g) +} + +// GetBusinessAccountGiftsOpts is the set of optional fields for Bot.GetBusinessAccountGifts and Bot.GetBusinessAccountGiftsWithContext. +type GetBusinessAccountGiftsOpts struct { + // Pass True to exclude gifts that aren't saved to the account's profile page + ExcludeUnsaved bool + // Pass True to exclude gifts that are saved to the account's profile page + ExcludeSaved bool + // Pass True to exclude gifts that can be purchased an unlimited number of times + ExcludeUnlimited bool + // Pass True to exclude gifts that can be purchased a limited number of times + ExcludeLimited bool + // Pass True to exclude unique gifts + ExcludeUnique bool + // Pass True to sort results by gift price instead of send date. Sorting is applied before pagination. + SortByPrice bool + // Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results + Offset string + // The maximum number of gifts to be returned; 1-100. Defaults to 100 + Limit int64 + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// GetBusinessAccountGifts (https://core.telegram.org/bots/api#getbusinessaccountgifts) +// +// Returns the gifts received and owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns OwnedGifts on success. +// - businessConnectionId (type string): Unique identifier of the business connection +// - opts (type GetBusinessAccountGiftsOpts): All optional parameters. +func (bot *Bot) GetBusinessAccountGifts(businessConnectionId string, opts *GetBusinessAccountGiftsOpts) (*OwnedGifts, error) { + return bot.GetBusinessAccountGiftsWithContext(context.Background(), businessConnectionId, opts) +} + +// GetBusinessAccountGiftsWithContext is the same as Bot.GetBusinessAccountGifts, but with a context.Context parameter +func (bot *Bot) GetBusinessAccountGiftsWithContext(ctx context.Context, businessConnectionId string, opts *GetBusinessAccountGiftsOpts) (*OwnedGifts, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + if opts != nil { + v["exclude_unsaved"] = strconv.FormatBool(opts.ExcludeUnsaved) + v["exclude_saved"] = strconv.FormatBool(opts.ExcludeSaved) + v["exclude_unlimited"] = strconv.FormatBool(opts.ExcludeUnlimited) + v["exclude_limited"] = strconv.FormatBool(opts.ExcludeLimited) + v["exclude_unique"] = strconv.FormatBool(opts.ExcludeUnique) + v["sort_by_price"] = strconv.FormatBool(opts.SortByPrice) + v["offset"] = opts.Offset + if opts.Limit != 0 { + v["limit"] = strconv.FormatInt(opts.Limit, 10) + } + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "getBusinessAccountGifts", v, nil, reqOpts) + if err != nil { + return nil, err + } + + var o OwnedGifts + return &o, json.Unmarshal(r, &o) +} + +// GetBusinessAccountStarBalanceOpts is the set of optional fields for Bot.GetBusinessAccountStarBalance and Bot.GetBusinessAccountStarBalanceWithContext. +type GetBusinessAccountStarBalanceOpts struct { + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// GetBusinessAccountStarBalance (https://core.telegram.org/bots/api#getbusinessaccountstarbalance) +// +// Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns StarAmount on success. +// - businessConnectionId (type string): Unique identifier of the business connection +// - opts (type GetBusinessAccountStarBalanceOpts): All optional parameters. +func (bot *Bot) GetBusinessAccountStarBalance(businessConnectionId string, opts *GetBusinessAccountStarBalanceOpts) (*StarAmount, error) { + return bot.GetBusinessAccountStarBalanceWithContext(context.Background(), businessConnectionId, opts) +} + +// GetBusinessAccountStarBalanceWithContext is the same as Bot.GetBusinessAccountStarBalance, but with a context.Context parameter +func (bot *Bot) GetBusinessAccountStarBalanceWithContext(ctx context.Context, businessConnectionId string, opts *GetBusinessAccountStarBalanceOpts) (*StarAmount, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "getBusinessAccountStarBalance", v, nil, reqOpts) + if err != nil { + return nil, err + } + + var s StarAmount + return &s, json.Unmarshal(r, &s) +} + // GetBusinessConnectionOpts is the set of optional fields for Bot.GetBusinessConnection and Bot.GetBusinessConnectionWithContext. type GetBusinessConnectionOpts struct { // RequestOpts are an additional optional field to configure timeouts for individual requests @@ -2751,7 +3107,7 @@ type GetUpdatesOpts struct { Limit int64 // Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only. Timeout int64 - // A JSON-serialized list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used. Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted updates may be received for a short period of time. + // A JSON-serialized list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used. Please note that this parameter doesn't affect updates created before the call to getUpdates, so unwanted updates may be received for a short period of time. AllowedUpdates []string // RequestOpts are an additional optional field to configure timeouts for individual requests RequestOpts *RequestOpts @@ -2915,6 +3271,61 @@ func (bot *Bot) GetWebhookInfoWithContext(ctx context.Context, opts *GetWebhookI return &w, json.Unmarshal(r, &w) } +// GiftPremiumSubscriptionOpts is the set of optional fields for Bot.GiftPremiumSubscription and Bot.GiftPremiumSubscriptionWithContext. +type GiftPremiumSubscriptionOpts struct { + // Text that will be shown along with the service message about the subscription; 0-128 characters + Text string + // Mode for parsing entities in the text. See formatting options for more details. Entities other than "bold", "italic", "underline", "strikethrough", "spoiler", and "custom_emoji" are ignored. + TextParseMode string + // A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than "bold", "italic", "underline", "strikethrough", "spoiler", and "custom_emoji" are ignored. + TextEntities []MessageEntity + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// GiftPremiumSubscription (https://core.telegram.org/bots/api#giftpremiumsubscription) +// +// Gifts a Telegram Premium subscription to the given user. Returns True on success. +// - userId (type int64): Unique identifier of the target user who will receive a Telegram Premium subscription +// - monthCount (type int64): Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12 +// - starCount (type int64): Number of Telegram Stars to pay for the Telegram Premium subscription; must be 1000 for 3 months, 1500 for 6 months, and 2500 for 12 months +// - opts (type GiftPremiumSubscriptionOpts): All optional parameters. +func (bot *Bot) GiftPremiumSubscription(userId int64, monthCount int64, starCount int64, opts *GiftPremiumSubscriptionOpts) (bool, error) { + return bot.GiftPremiumSubscriptionWithContext(context.Background(), userId, monthCount, starCount, opts) +} + +// GiftPremiumSubscriptionWithContext is the same as Bot.GiftPremiumSubscription, but with a context.Context parameter +func (bot *Bot) GiftPremiumSubscriptionWithContext(ctx context.Context, userId int64, monthCount int64, starCount int64, opts *GiftPremiumSubscriptionOpts) (bool, error) { + v := map[string]string{} + v["user_id"] = strconv.FormatInt(userId, 10) + v["month_count"] = strconv.FormatInt(monthCount, 10) + v["star_count"] = strconv.FormatInt(starCount, 10) + if opts != nil { + v["text"] = opts.Text + v["text_parse_mode"] = opts.TextParseMode + if opts.TextEntities != nil { + bs, err := json.Marshal(opts.TextEntities) + if err != nil { + return false, fmt.Errorf("failed to marshal field text_entities: %w", err) + } + v["text_entities"] = string(bs) + } + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "giftPremiumSubscription", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + // HideGeneralForumTopicOpts is the set of optional fields for Bot.HideGeneralForumTopic and Bot.HideGeneralForumTopicWithContext. type HideGeneralForumTopicOpts struct { // RequestOpts are an additional optional field to configure timeouts for individual requests @@ -3059,6 +3470,80 @@ func (bot *Bot) PinChatMessageWithContext(ctx context.Context, chatId int64, mes return b, json.Unmarshal(r, &b) } +// PostStoryOpts is the set of optional fields for Bot.PostStory and Bot.PostStoryWithContext. +type PostStoryOpts struct { + // Caption of the story, 0-2048 characters after entities parsing + Caption string + // Mode for parsing entities in the story caption. See formatting options for more details. + ParseMode string + // A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode + CaptionEntities []MessageEntity + // A JSON-serialized list of clickable areas to be shown on the story + Areas []StoryArea + // Pass True to keep the story accessible after it expires + PostToChatPage bool + // Pass True if the content of the story must be protected from forwarding and screenshotting + ProtectContent bool + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// PostStory (https://core.telegram.org/bots/api#poststory) +// +// Posts a story on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success. +// - businessConnectionId (type string): Unique identifier of the business connection +// - content (type InputStoryContent): Content of the story +// - activePeriod (type int64): Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400 +// - opts (type PostStoryOpts): All optional parameters. +func (bot *Bot) PostStory(businessConnectionId string, content InputStoryContent, activePeriod int64, opts *PostStoryOpts) (*Story, error) { + return bot.PostStoryWithContext(context.Background(), businessConnectionId, content, activePeriod, opts) +} + +// PostStoryWithContext is the same as Bot.PostStory, but with a context.Context parameter +func (bot *Bot) PostStoryWithContext(ctx context.Context, businessConnectionId string, content InputStoryContent, activePeriod int64, opts *PostStoryOpts) (*Story, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + bs, err := json.Marshal(content) + if err != nil { + return nil, fmt.Errorf("failed to marshal field content: %w", err) + } + v["content"] = string(bs) + v["active_period"] = strconv.FormatInt(activePeriod, 10) + if opts != nil { + v["caption"] = opts.Caption + v["parse_mode"] = opts.ParseMode + if opts.CaptionEntities != nil { + bs, err := json.Marshal(opts.CaptionEntities) + if err != nil { + return nil, fmt.Errorf("failed to marshal field caption_entities: %w", err) + } + v["caption_entities"] = string(bs) + } + if opts.Areas != nil { + bs, err := json.Marshal(opts.Areas) + if err != nil { + return nil, fmt.Errorf("failed to marshal field areas: %w", err) + } + v["areas"] = string(bs) + } + v["post_to_chat_page"] = strconv.FormatBool(opts.PostToChatPage) + v["protect_content"] = strconv.FormatBool(opts.ProtectContent) + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "postStory", v, nil, reqOpts) + if err != nil { + return nil, err + } + + var s Story + return &s, json.Unmarshal(r, &s) +} + // PromoteChatMemberOpts is the set of optional fields for Bot.PromoteChatMember and Bot.PromoteChatMemberWithContext. type PromoteChatMemberOpts struct { // Pass True if the administrator's presence in the chat is hidden @@ -3142,6 +3627,44 @@ func (bot *Bot) PromoteChatMemberWithContext(ctx context.Context, chatId int64, return b, json.Unmarshal(r, &b) } +// ReadBusinessMessageOpts is the set of optional fields for Bot.ReadBusinessMessage and Bot.ReadBusinessMessageWithContext. +type ReadBusinessMessageOpts struct { + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// ReadBusinessMessage (https://core.telegram.org/bots/api#readbusinessmessage) +// +// Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success. +// - businessConnectionId (type string): Unique identifier of the business connection on behalf of which to read the message +// - chatId (type int64): Unique identifier of the chat in which the message was received. The chat must have been active in the last 24 hours. +// - messageId (type int64): Unique identifier of the message to mark as read +// - opts (type ReadBusinessMessageOpts): All optional parameters. +func (bot *Bot) ReadBusinessMessage(businessConnectionId string, chatId int64, messageId int64, opts *ReadBusinessMessageOpts) (bool, error) { + return bot.ReadBusinessMessageWithContext(context.Background(), businessConnectionId, chatId, messageId, opts) +} + +// ReadBusinessMessageWithContext is the same as Bot.ReadBusinessMessage, but with a context.Context parameter +func (bot *Bot) ReadBusinessMessageWithContext(ctx context.Context, businessConnectionId string, chatId int64, messageId int64, opts *ReadBusinessMessageOpts) (bool, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + v["chat_id"] = strconv.FormatInt(chatId, 10) + v["message_id"] = strconv.FormatInt(messageId, 10) + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "readBusinessMessage", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + // RefundStarPaymentOpts is the set of optional fields for Bot.RefundStarPayment and Bot.RefundStarPaymentWithContext. type RefundStarPaymentOpts struct { // RequestOpts are an additional optional field to configure timeouts for individual requests @@ -3178,6 +3701,113 @@ func (bot *Bot) RefundStarPaymentWithContext(ctx context.Context, userId int64, return b, json.Unmarshal(r, &b) } +// RemoveBusinessAccountProfilePhotoOpts is the set of optional fields for Bot.RemoveBusinessAccountProfilePhoto and Bot.RemoveBusinessAccountProfilePhotoWithContext. +type RemoveBusinessAccountProfilePhotoOpts struct { + // Pass True to remove the public photo, which is visible even if the main photo is hidden by the business account's privacy settings. After the main photo is removed, the previous profile photo (if present) becomes the main photo. + IsPublic bool + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// RemoveBusinessAccountProfilePhoto (https://core.telegram.org/bots/api#removebusinessaccountprofilephoto) +// +// Removes the current profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success. +// - businessConnectionId (type string): Unique identifier of the business connection +// - opts (type RemoveBusinessAccountProfilePhotoOpts): All optional parameters. +func (bot *Bot) RemoveBusinessAccountProfilePhoto(businessConnectionId string, opts *RemoveBusinessAccountProfilePhotoOpts) (bool, error) { + return bot.RemoveBusinessAccountProfilePhotoWithContext(context.Background(), businessConnectionId, opts) +} + +// RemoveBusinessAccountProfilePhotoWithContext is the same as Bot.RemoveBusinessAccountProfilePhoto, but with a context.Context parameter +func (bot *Bot) RemoveBusinessAccountProfilePhotoWithContext(ctx context.Context, businessConnectionId string, opts *RemoveBusinessAccountProfilePhotoOpts) (bool, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + if opts != nil { + v["is_public"] = strconv.FormatBool(opts.IsPublic) + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "removeBusinessAccountProfilePhoto", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + +// RemoveChatVerificationOpts is the set of optional fields for Bot.RemoveChatVerification and Bot.RemoveChatVerificationWithContext. +type RemoveChatVerificationOpts struct { + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// RemoveChatVerification (https://core.telegram.org/bots/api#removechatverification) +// +// Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success. +// - chatId (type int64): Unique identifier for the target chat +// - opts (type RemoveChatVerificationOpts): All optional parameters. +func (bot *Bot) RemoveChatVerification(chatId int64, opts *RemoveChatVerificationOpts) (bool, error) { + return bot.RemoveChatVerificationWithContext(context.Background(), chatId, opts) +} + +// RemoveChatVerificationWithContext is the same as Bot.RemoveChatVerification, but with a context.Context parameter +func (bot *Bot) RemoveChatVerificationWithContext(ctx context.Context, chatId int64, opts *RemoveChatVerificationOpts) (bool, error) { + v := map[string]string{} + v["chat_id"] = strconv.FormatInt(chatId, 10) + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "removeChatVerification", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + +// RemoveUserVerificationOpts is the set of optional fields for Bot.RemoveUserVerification and Bot.RemoveUserVerificationWithContext. +type RemoveUserVerificationOpts struct { + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// RemoveUserVerification (https://core.telegram.org/bots/api#removeuserverification) +// +// Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success. +// - userId (type int64): Unique identifier of the target user +// - opts (type RemoveUserVerificationOpts): All optional parameters. +func (bot *Bot) RemoveUserVerification(userId int64, opts *RemoveUserVerificationOpts) (bool, error) { + return bot.RemoveUserVerificationWithContext(context.Background(), userId, opts) +} + +// RemoveUserVerificationWithContext is the same as Bot.RemoveUserVerification, but with a context.Context parameter +func (bot *Bot) RemoveUserVerificationWithContext(ctx context.Context, userId int64, opts *RemoveUserVerificationOpts) (bool, error) { + v := map[string]string{} + v["user_id"] = strconv.FormatInt(userId, 10) + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "removeUserVerification", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + // ReopenForumTopicOpts is the set of optional fields for Bot.ReopenForumTopic and Bot.ReopenForumTopicWithContext. type ReopenForumTopicOpts struct { // RequestOpts are an additional optional field to configure timeouts for individual requests @@ -3269,22 +3899,21 @@ func (bot *Bot) ReplaceStickerInSet(userId int64, name string, oldSticker string // ReplaceStickerInSetWithContext is the same as Bot.ReplaceStickerInSet, but with a context.Context parameter func (bot *Bot) ReplaceStickerInSetWithContext(ctx context.Context, userId int64, name string, oldSticker string, sticker InputSticker, opts *ReplaceStickerInSetOpts) (bool, error) { v := map[string]string{} - data := map[string]FileReader{} v["user_id"] = strconv.FormatInt(userId, 10) v["name"] = name v["old_sticker"] = oldSticker - inputBs, err := sticker.InputParams("sticker", data) + bs, err := json.Marshal(sticker) if err != nil { return false, fmt.Errorf("failed to marshal field sticker: %w", err) } - v["sticker"] = string(inputBs) + v["sticker"] = string(bs) var reqOpts *RequestOpts if opts != nil { reqOpts = opts.RequestOpts } - r, err := bot.RequestWithContext(ctx, "replaceStickerInSet", v, data, reqOpts) + r, err := bot.RequestWithContext(ctx, "replaceStickerInSet", v, nil, reqOpts) if err != nil { return false, err } @@ -3381,6 +4010,60 @@ func (bot *Bot) RevokeChatInviteLinkWithContext(ctx context.Context, chatId int6 return &c, json.Unmarshal(r, &c) } +// SavePreparedInlineMessageOpts is the set of optional fields for Bot.SavePreparedInlineMessage and Bot.SavePreparedInlineMessageWithContext. +type SavePreparedInlineMessageOpts struct { + // Pass True if the message can be sent to private chats with users + AllowUserChats bool + // Pass True if the message can be sent to private chats with bots + AllowBotChats bool + // Pass True if the message can be sent to group and supergroup chats + AllowGroupChats bool + // Pass True if the message can be sent to channel chats + AllowChannelChats bool + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// SavePreparedInlineMessage (https://core.telegram.org/bots/api#savepreparedinlinemessage) +// +// Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object. +// - userId (type int64): Unique identifier of the target user that can use the prepared message +// - result (type InlineQueryResult): A JSON-serialized object describing the message to be sent +// - opts (type SavePreparedInlineMessageOpts): All optional parameters. +func (bot *Bot) SavePreparedInlineMessage(userId int64, result InlineQueryResult, opts *SavePreparedInlineMessageOpts) (*PreparedInlineMessage, error) { + return bot.SavePreparedInlineMessageWithContext(context.Background(), userId, result, opts) +} + +// SavePreparedInlineMessageWithContext is the same as Bot.SavePreparedInlineMessage, but with a context.Context parameter +func (bot *Bot) SavePreparedInlineMessageWithContext(ctx context.Context, userId int64, result InlineQueryResult, opts *SavePreparedInlineMessageOpts) (*PreparedInlineMessage, error) { + v := map[string]string{} + v["user_id"] = strconv.FormatInt(userId, 10) + bs, err := json.Marshal(result) + if err != nil { + return nil, fmt.Errorf("failed to marshal field result: %w", err) + } + v["result"] = string(bs) + if opts != nil { + v["allow_user_chats"] = strconv.FormatBool(opts.AllowUserChats) + v["allow_bot_chats"] = strconv.FormatBool(opts.AllowBotChats) + v["allow_group_chats"] = strconv.FormatBool(opts.AllowGroupChats) + v["allow_channel_chats"] = strconv.FormatBool(opts.AllowChannelChats) + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "savePreparedInlineMessage", v, nil, reqOpts) + if err != nil { + return nil, err + } + + var p PreparedInlineMessage + return &p, json.Unmarshal(r, &p) +} + // SendAnimationOpts is the set of optional fields for Bot.SendAnimation and Bot.SendAnimationWithContext. type SendAnimationOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent @@ -4020,6 +4703,70 @@ func (bot *Bot) SendGameWithContext(ctx context.Context, chatId int64, gameShort return &m, json.Unmarshal(r, &m) } +// SendGiftOpts is the set of optional fields for Bot.SendGift and Bot.SendGiftWithContext. +type SendGiftOpts struct { + // Required if chat_id is not specified. Unique identifier of the target user who will receive the gift. + UserId int64 + // Required if user_id is not specified. Unique identifier for the chat that will receive the gift. + ChatId int64 + // Pass True to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver + PayForUpgrade bool + // Text that will be shown along with the gift; 0-128 characters + Text string + // Mode for parsing entities in the text. See formatting options for more details. Entities other than "bold", "italic", "underline", "strikethrough", "spoiler", and "custom_emoji" are ignored. + TextParseMode string + // A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than "bold", "italic", "underline", "strikethrough", "spoiler", and "custom_emoji" are ignored. + TextEntities []MessageEntity + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// SendGift (https://core.telegram.org/bots/api#sendgift) +// +// Sends a gift to the given user or channel chat. The gift can't be converted to Telegram Stars by the receiver. Returns True on success. +// - giftId (type string): Identifier of the gift +// - opts (type SendGiftOpts): All optional parameters. +func (bot *Bot) SendGift(giftId string, opts *SendGiftOpts) (bool, error) { + return bot.SendGiftWithContext(context.Background(), giftId, opts) +} + +// SendGiftWithContext is the same as Bot.SendGift, but with a context.Context parameter +func (bot *Bot) SendGiftWithContext(ctx context.Context, giftId string, opts *SendGiftOpts) (bool, error) { + v := map[string]string{} + v["gift_id"] = giftId + if opts != nil { + if opts.UserId != 0 { + v["user_id"] = strconv.FormatInt(opts.UserId, 10) + } + if opts.ChatId != 0 { + v["chat_id"] = strconv.FormatInt(opts.ChatId, 10) + } + v["pay_for_upgrade"] = strconv.FormatBool(opts.PayForUpgrade) + v["text"] = opts.Text + v["text_parse_mode"] = opts.TextParseMode + if opts.TextEntities != nil { + bs, err := json.Marshal(opts.TextEntities) + if err != nil { + return false, fmt.Errorf("failed to marshal field text_entities: %w", err) + } + v["text_entities"] = string(bs) + } + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "sendGift", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + // SendInvoiceOpts is the set of optional fields for Bot.SendInvoice and Bot.SendInvoiceWithContext. type SendInvoiceOpts struct { // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only @@ -4476,7 +5223,7 @@ type SendPaidMediaOpts struct { // // Use this method to send paid media. On success, the sent Message is returned. // - chatId (type int64): Unique identifier for the target chat. If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance. -// - starCount (type int64): The number of Telegram Stars that must be paid to buy access to the media; 1-2500 +// - starCount (type int64): The number of Telegram Stars that must be paid to buy access to the media; 1-10000 // - media (type []InputPaidMedia): A JSON-serialized array describing the media to be sent; up to 10 items // - opts (type SendPaidMediaOpts): All optional parameters. func (bot *Bot) SendPaidMedia(chatId int64, starCount int64, media []InputPaidMedia, opts *SendPaidMediaOpts) (*Message, error) { @@ -4987,6 +5734,10 @@ type SendVideoOpts struct { Height int64 // Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass "attach://" if the thumbnail was uploaded using multipart/form-data under . More information on Sending Files: https://core.telegram.org/bots/api#sending-files Thumbnail InputFile + // Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. More information on Sending Files: https://core.telegram.org/bots/api#sending-files + Cover InputFileOrString + // Start timestamp for the video in the message + StartTimestamp int64 // Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsing Caption string // Mode for parsing entities in the video caption. See formatting options for more details. @@ -5058,6 +5809,16 @@ func (bot *Bot) SendVideoWithContext(ctx context.Context, chatId int64, video In } v["thumbnail"] = opts.Thumbnail.getValue() } + if opts.Cover != nil { + err := opts.Cover.Attach("cover", data) + if err != nil { + return nil, fmt.Errorf("failed to attach 'cover' input file: %w", err) + } + v["cover"] = opts.Cover.getValue() + } + if opts.StartTimestamp != 0 { + v["start_timestamp"] = strconv.FormatInt(opts.StartTimestamp, 10) + } v["caption"] = opts.Caption v["parse_mode"] = opts.ParseMode if opts.CaptionEntities != nil { @@ -5309,6 +6070,212 @@ func (bot *Bot) SendVoiceWithContext(ctx context.Context, chatId int64, voice In return &m, json.Unmarshal(r, &m) } +// SetBusinessAccountBioOpts is the set of optional fields for Bot.SetBusinessAccountBio and Bot.SetBusinessAccountBioWithContext. +type SetBusinessAccountBioOpts struct { + // The new value of the bio for the business account; 0-140 characters + Bio string + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// SetBusinessAccountBio (https://core.telegram.org/bots/api#setbusinessaccountbio) +// +// Changes the bio of a managed business account. Requires the can_change_bio business bot right. Returns True on success. +// - businessConnectionId (type string): Unique identifier of the business connection +// - opts (type SetBusinessAccountBioOpts): All optional parameters. +func (bot *Bot) SetBusinessAccountBio(businessConnectionId string, opts *SetBusinessAccountBioOpts) (bool, error) { + return bot.SetBusinessAccountBioWithContext(context.Background(), businessConnectionId, opts) +} + +// SetBusinessAccountBioWithContext is the same as Bot.SetBusinessAccountBio, but with a context.Context parameter +func (bot *Bot) SetBusinessAccountBioWithContext(ctx context.Context, businessConnectionId string, opts *SetBusinessAccountBioOpts) (bool, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + if opts != nil { + v["bio"] = opts.Bio + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "setBusinessAccountBio", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + +// SetBusinessAccountGiftSettingsOpts is the set of optional fields for Bot.SetBusinessAccountGiftSettings and Bot.SetBusinessAccountGiftSettingsWithContext. +type SetBusinessAccountGiftSettingsOpts struct { + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// SetBusinessAccountGiftSettings (https://core.telegram.org/bots/api#setbusinessaccountgiftsettings) +// +// Changes the privacy settings pertaining to incoming gifts in a managed business account. Requires the can_change_gift_settings business bot right. Returns True on success. +// - businessConnectionId (type string): Unique identifier of the business connection +// - showGiftButton (type bool): Pass True, if a button for sending a gift to the user or by the business account must always be shown in the input field +// - acceptedGiftTypes (type AcceptedGiftTypes): Types of gifts accepted by the business account +// - opts (type SetBusinessAccountGiftSettingsOpts): All optional parameters. +func (bot *Bot) SetBusinessAccountGiftSettings(businessConnectionId string, showGiftButton bool, acceptedGiftTypes AcceptedGiftTypes, opts *SetBusinessAccountGiftSettingsOpts) (bool, error) { + return bot.SetBusinessAccountGiftSettingsWithContext(context.Background(), businessConnectionId, showGiftButton, acceptedGiftTypes, opts) +} + +// SetBusinessAccountGiftSettingsWithContext is the same as Bot.SetBusinessAccountGiftSettings, but with a context.Context parameter +func (bot *Bot) SetBusinessAccountGiftSettingsWithContext(ctx context.Context, businessConnectionId string, showGiftButton bool, acceptedGiftTypes AcceptedGiftTypes, opts *SetBusinessAccountGiftSettingsOpts) (bool, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + v["show_gift_button"] = strconv.FormatBool(showGiftButton) + bs, err := json.Marshal(acceptedGiftTypes) + if err != nil { + return false, fmt.Errorf("failed to marshal field accepted_gift_types: %w", err) + } + v["accepted_gift_types"] = string(bs) + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "setBusinessAccountGiftSettings", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + +// SetBusinessAccountNameOpts is the set of optional fields for Bot.SetBusinessAccountName and Bot.SetBusinessAccountNameWithContext. +type SetBusinessAccountNameOpts struct { + // The new value of the last name for the business account; 0-64 characters + LastName string + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// SetBusinessAccountName (https://core.telegram.org/bots/api#setbusinessaccountname) +// +// Changes the first and last name of a managed business account. Requires the can_change_name business bot right. Returns True on success. +// - businessConnectionId (type string): Unique identifier of the business connection +// - firstName (type string): The new value of the first name for the business account; 1-64 characters +// - opts (type SetBusinessAccountNameOpts): All optional parameters. +func (bot *Bot) SetBusinessAccountName(businessConnectionId string, firstName string, opts *SetBusinessAccountNameOpts) (bool, error) { + return bot.SetBusinessAccountNameWithContext(context.Background(), businessConnectionId, firstName, opts) +} + +// SetBusinessAccountNameWithContext is the same as Bot.SetBusinessAccountName, but with a context.Context parameter +func (bot *Bot) SetBusinessAccountNameWithContext(ctx context.Context, businessConnectionId string, firstName string, opts *SetBusinessAccountNameOpts) (bool, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + v["first_name"] = firstName + if opts != nil { + v["last_name"] = opts.LastName + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "setBusinessAccountName", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + +// SetBusinessAccountProfilePhotoOpts is the set of optional fields for Bot.SetBusinessAccountProfilePhoto and Bot.SetBusinessAccountProfilePhotoWithContext. +type SetBusinessAccountProfilePhotoOpts struct { + // Pass True to set the public photo, which will be visible even if the main photo is hidden by the business account's privacy settings. An account can have only one public photo. + IsPublic bool + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// SetBusinessAccountProfilePhoto (https://core.telegram.org/bots/api#setbusinessaccountprofilephoto) +// +// Changes the profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success. +// - businessConnectionId (type string): Unique identifier of the business connection +// - photo (type InputProfilePhoto): The new profile photo to set +// - opts (type SetBusinessAccountProfilePhotoOpts): All optional parameters. +func (bot *Bot) SetBusinessAccountProfilePhoto(businessConnectionId string, photo InputProfilePhoto, opts *SetBusinessAccountProfilePhotoOpts) (bool, error) { + return bot.SetBusinessAccountProfilePhotoWithContext(context.Background(), businessConnectionId, photo, opts) +} + +// SetBusinessAccountProfilePhotoWithContext is the same as Bot.SetBusinessAccountProfilePhoto, but with a context.Context parameter +func (bot *Bot) SetBusinessAccountProfilePhotoWithContext(ctx context.Context, businessConnectionId string, photo InputProfilePhoto, opts *SetBusinessAccountProfilePhotoOpts) (bool, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + bs, err := json.Marshal(photo) + if err != nil { + return false, fmt.Errorf("failed to marshal field photo: %w", err) + } + v["photo"] = string(bs) + if opts != nil { + v["is_public"] = strconv.FormatBool(opts.IsPublic) + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "setBusinessAccountProfilePhoto", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + +// SetBusinessAccountUsernameOpts is the set of optional fields for Bot.SetBusinessAccountUsername and Bot.SetBusinessAccountUsernameWithContext. +type SetBusinessAccountUsernameOpts struct { + // The new value of the username for the business account; 0-32 characters + Username string + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// SetBusinessAccountUsername (https://core.telegram.org/bots/api#setbusinessaccountusername) +// +// Changes the username of a managed business account. Requires the can_change_username business bot right. Returns True on success. +// - businessConnectionId (type string): Unique identifier of the business connection +// - opts (type SetBusinessAccountUsernameOpts): All optional parameters. +func (bot *Bot) SetBusinessAccountUsername(businessConnectionId string, opts *SetBusinessAccountUsernameOpts) (bool, error) { + return bot.SetBusinessAccountUsernameWithContext(context.Background(), businessConnectionId, opts) +} + +// SetBusinessAccountUsernameWithContext is the same as Bot.SetBusinessAccountUsername, but with a context.Context parameter +func (bot *Bot) SetBusinessAccountUsernameWithContext(ctx context.Context, businessConnectionId string, opts *SetBusinessAccountUsernameOpts) (bool, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + if opts != nil { + v["username"] = opts.Username + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "setBusinessAccountUsername", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + // SetChatAdministratorCustomTitleOpts is the set of optional fields for Bot.SetChatAdministratorCustomTitle and Bot.SetChatAdministratorCustomTitleWithContext. type SetChatAdministratorCustomTitleOpts struct { // RequestOpts are an additional optional field to configure timeouts for individual requests @@ -5708,7 +6675,7 @@ type SetMessageReactionOpts struct { // SetMessageReaction (https://core.telegram.org/bots/api#setmessagereaction) // -// Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success. +// Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success. // - chatId (type int64): Unique identifier for the target chat // - messageId (type int64): Identifier of the target message. If the message belongs to a media group, the reaction is set to the first non-deleted message in the group instead. // - opts (type SetMessageReactionOpts): All optional parameters. @@ -6177,7 +7144,7 @@ func (bot *Bot) SetStickerPositionInSetWithContext(ctx context.Context, sticker // SetStickerSetThumbnailOpts is the set of optional fields for Bot.SetStickerSetThumbnail and Bot.SetStickerSetThumbnailWithContext. type SetStickerSetThumbnailOpts struct { - // A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files: https://core.telegram.org/bots/api#sending-files. Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. + // A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a .WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files: https://core.telegram.org/bots/api#sending-files. Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. Thumbnail InputFile // RequestOpts are an additional optional field to configure timeouts for individual requests RequestOpts *RequestOpts @@ -6188,7 +7155,7 @@ type SetStickerSetThumbnailOpts struct { // Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set. Returns True on success. // - name (type string): Sticker set name // - userId (type int64): User identifier of the sticker set owner -// - format (type string): Format of the thumbnail, must be one of "static" for a .WEBP or .PNG image, "animated" for a .TGS animation, or "video" for a WEBM video +// - format (type string): Format of the thumbnail, must be one of "static" for a .WEBP or .PNG image, "animated" for a .TGS animation, or "video" for a .WEBM video // - opts (type SetStickerSetThumbnailOpts): All optional parameters. func (bot *Bot) SetStickerSetThumbnail(name string, userId int64, format string, opts *SetStickerSetThumbnailOpts) (bool, error) { return bot.SetStickerSetThumbnailWithContext(context.Background(), name, userId, format, opts) @@ -6261,6 +7228,50 @@ func (bot *Bot) SetStickerSetTitleWithContext(ctx context.Context, name string, return b, json.Unmarshal(r, &b) } +// SetUserEmojiStatusOpts is the set of optional fields for Bot.SetUserEmojiStatus and Bot.SetUserEmojiStatusWithContext. +type SetUserEmojiStatusOpts struct { + // Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status. + EmojiStatusCustomEmojiId string + // Expiration date of the emoji status, if any + EmojiStatusExpirationDate int64 + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// SetUserEmojiStatus (https://core.telegram.org/bots/api#setuseremojistatus) +// +// Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success. +// - userId (type int64): Unique identifier of the target user +// - opts (type SetUserEmojiStatusOpts): All optional parameters. +func (bot *Bot) SetUserEmojiStatus(userId int64, opts *SetUserEmojiStatusOpts) (bool, error) { + return bot.SetUserEmojiStatusWithContext(context.Background(), userId, opts) +} + +// SetUserEmojiStatusWithContext is the same as Bot.SetUserEmojiStatus, but with a context.Context parameter +func (bot *Bot) SetUserEmojiStatusWithContext(ctx context.Context, userId int64, opts *SetUserEmojiStatusOpts) (bool, error) { + v := map[string]string{} + v["user_id"] = strconv.FormatInt(userId, 10) + if opts != nil { + v["emoji_status_custom_emoji_id"] = opts.EmojiStatusCustomEmojiId + if opts.EmojiStatusExpirationDate != 0 { + v["emoji_status_expiration_date"] = strconv.FormatInt(opts.EmojiStatusExpirationDate, 10) + } + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "setUserEmojiStatus", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + // SetWebhookOpts is the set of optional fields for Bot.SetWebhook and Bot.SetWebhookWithContext. type SetWebhookOpts struct { // Upload your public key certificate so that the root certificate in use can be checked. See our self-signed guide for details. @@ -6281,7 +7292,7 @@ type SetWebhookOpts struct { // SetWebhook (https://core.telegram.org/bots/api#setwebhook) // -// Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success. +// Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request (a request with response HTTP status code different from 2XY), we will repeat the request and give up after a reasonable amount of attempts. Returns True on success. // If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header "X-Telegram-Bot-Api-Secret-Token" with the secret token as content. // - url (type string): HTTPS URL to send updates to. Use an empty string to remove webhook integration // - opts (type SetWebhookOpts): All optional parameters. @@ -6444,6 +7455,87 @@ func (bot *Bot) StopPollWithContext(ctx context.Context, chatId int64, messageId return &p, json.Unmarshal(r, &p) } +// TransferBusinessAccountStarsOpts is the set of optional fields for Bot.TransferBusinessAccountStars and Bot.TransferBusinessAccountStarsWithContext. +type TransferBusinessAccountStarsOpts struct { + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// TransferBusinessAccountStars (https://core.telegram.org/bots/api#transferbusinessaccountstars) +// +// Transfers Telegram Stars from the business account balance to the bot's balance. Requires the can_transfer_stars business bot right. Returns True on success. +// - businessConnectionId (type string): Unique identifier of the business connection +// - starCount (type int64): Number of Telegram Stars to transfer; 1-10000 +// - opts (type TransferBusinessAccountStarsOpts): All optional parameters. +func (bot *Bot) TransferBusinessAccountStars(businessConnectionId string, starCount int64, opts *TransferBusinessAccountStarsOpts) (bool, error) { + return bot.TransferBusinessAccountStarsWithContext(context.Background(), businessConnectionId, starCount, opts) +} + +// TransferBusinessAccountStarsWithContext is the same as Bot.TransferBusinessAccountStars, but with a context.Context parameter +func (bot *Bot) TransferBusinessAccountStarsWithContext(ctx context.Context, businessConnectionId string, starCount int64, opts *TransferBusinessAccountStarsOpts) (bool, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + v["star_count"] = strconv.FormatInt(starCount, 10) + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "transferBusinessAccountStars", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + +// TransferGiftOpts is the set of optional fields for Bot.TransferGift and Bot.TransferGiftWithContext. +type TransferGiftOpts struct { + // The amount of Telegram Stars that will be paid for the transfer from the business account balance. If positive, then the can_transfer_stars business bot right is required. + StarCount int64 + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// TransferGift (https://core.telegram.org/bots/api#transfergift) +// +// Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right. Requires can_transfer_stars business bot right if the transfer is paid. Returns True on success. +// - businessConnectionId (type string): Unique identifier of the business connection +// - ownedGiftId (type string): Unique identifier of the regular gift that should be transferred +// - newOwnerChatId (type int64): Unique identifier of the chat which will own the gift. The chat must be active in the last 24 hours. +// - opts (type TransferGiftOpts): All optional parameters. +func (bot *Bot) TransferGift(businessConnectionId string, ownedGiftId string, newOwnerChatId int64, opts *TransferGiftOpts) (bool, error) { + return bot.TransferGiftWithContext(context.Background(), businessConnectionId, ownedGiftId, newOwnerChatId, opts) +} + +// TransferGiftWithContext is the same as Bot.TransferGift, but with a context.Context parameter +func (bot *Bot) TransferGiftWithContext(ctx context.Context, businessConnectionId string, ownedGiftId string, newOwnerChatId int64, opts *TransferGiftOpts) (bool, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + v["owned_gift_id"] = ownedGiftId + v["new_owner_chat_id"] = strconv.FormatInt(newOwnerChatId, 10) + if opts != nil { + if opts.StarCount != 0 { + v["star_count"] = strconv.FormatInt(opts.StarCount, 10) + } + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "transferGift", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + // UnbanChatMemberOpts is the set of optional fields for Bot.UnbanChatMember and Bot.UnbanChatMemberWithContext. type UnbanChatMemberOpts struct { // Do nothing if the user is not banned @@ -6703,6 +7795,52 @@ func (bot *Bot) UnpinChatMessageWithContext(ctx context.Context, chatId int64, o return b, json.Unmarshal(r, &b) } +// UpgradeGiftOpts is the set of optional fields for Bot.UpgradeGift and Bot.UpgradeGiftWithContext. +type UpgradeGiftOpts struct { + // Pass True to keep the original gift text, sender and receiver in the upgraded gift + KeepOriginalDetails bool + // The amount of Telegram Stars that will be paid for the upgrade from the business account balance. If gift.prepaid_upgrade_star_count > 0, then pass 0, otherwise, the can_transfer_stars business bot right is required and gift.upgrade_star_count must be passed. + StarCount int64 + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// UpgradeGift (https://core.telegram.org/bots/api#upgradegift) +// +// Upgrades a given regular gift to a unique gift. Requires the can_transfer_and_upgrade_gifts business bot right. Additionally requires the can_transfer_stars business bot right if the upgrade is paid. Returns True on success. +// - businessConnectionId (type string): Unique identifier of the business connection +// - ownedGiftId (type string): Unique identifier of the regular gift that should be upgraded to a unique one +// - opts (type UpgradeGiftOpts): All optional parameters. +func (bot *Bot) UpgradeGift(businessConnectionId string, ownedGiftId string, opts *UpgradeGiftOpts) (bool, error) { + return bot.UpgradeGiftWithContext(context.Background(), businessConnectionId, ownedGiftId, opts) +} + +// UpgradeGiftWithContext is the same as Bot.UpgradeGift, but with a context.Context parameter +func (bot *Bot) UpgradeGiftWithContext(ctx context.Context, businessConnectionId string, ownedGiftId string, opts *UpgradeGiftOpts) (bool, error) { + v := map[string]string{} + v["business_connection_id"] = businessConnectionId + v["owned_gift_id"] = ownedGiftId + if opts != nil { + v["keep_original_details"] = strconv.FormatBool(opts.KeepOriginalDetails) + if opts.StarCount != 0 { + v["star_count"] = strconv.FormatInt(opts.StarCount, 10) + } + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "upgradeGift", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + // UploadStickerFileOpts is the set of optional fields for Bot.UploadStickerFile and Bot.UploadStickerFileWithContext. type UploadStickerFileOpts struct { // RequestOpts are an additional optional field to configure timeouts for individual requests @@ -6747,3 +7885,81 @@ func (bot *Bot) UploadStickerFileWithContext(ctx context.Context, userId int64, var f File return &f, json.Unmarshal(r, &f) } + +// VerifyChatOpts is the set of optional fields for Bot.VerifyChat and Bot.VerifyChatWithContext. +type VerifyChatOpts struct { + // Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description. + CustomDescription string + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// VerifyChat (https://core.telegram.org/bots/api#verifychat) +// +// Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success. +// - chatId (type int64): Unique identifier for the target chat +// - opts (type VerifyChatOpts): All optional parameters. +func (bot *Bot) VerifyChat(chatId int64, opts *VerifyChatOpts) (bool, error) { + return bot.VerifyChatWithContext(context.Background(), chatId, opts) +} + +// VerifyChatWithContext is the same as Bot.VerifyChat, but with a context.Context parameter +func (bot *Bot) VerifyChatWithContext(ctx context.Context, chatId int64, opts *VerifyChatOpts) (bool, error) { + v := map[string]string{} + v["chat_id"] = strconv.FormatInt(chatId, 10) + if opts != nil { + v["custom_description"] = opts.CustomDescription + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "verifyChat", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + +// VerifyUserOpts is the set of optional fields for Bot.VerifyUser and Bot.VerifyUserWithContext. +type VerifyUserOpts struct { + // Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description. + CustomDescription string + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// VerifyUser (https://core.telegram.org/bots/api#verifyuser) +// +// Verifies a user on behalf of the organization which is represented by the bot. Returns True on success. +// - userId (type int64): Unique identifier of the target user +// - opts (type VerifyUserOpts): All optional parameters. +func (bot *Bot) VerifyUser(userId int64, opts *VerifyUserOpts) (bool, error) { + return bot.VerifyUserWithContext(context.Background(), userId, opts) +} + +// VerifyUserWithContext is the same as Bot.VerifyUser, but with a context.Context parameter +func (bot *Bot) VerifyUserWithContext(ctx context.Context, userId int64, opts *VerifyUserOpts) (bool, error) { + v := map[string]string{} + v["user_id"] = strconv.FormatInt(userId, 10) + if opts != nil { + v["custom_description"] = opts.CustomDescription + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "verifyUser", v, nil, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} diff --git a/vendor/github.com/PaulSonOfLars/gotgbot/v2/gen_types.go b/vendor/github.com/PaulSonOfLars/gotgbot/v2/gen_types.go index 70ea6c70..e339c40d 100644 --- a/vendor/github.com/PaulSonOfLars/gotgbot/v2/gen_types.go +++ b/vendor/github.com/PaulSonOfLars/gotgbot/v2/gen_types.go @@ -21,6 +21,36 @@ var ( _ ReplyMarkup = ReplyKeyboardRemove{} ) +// AcceptedGiftTypes (https://core.telegram.org/bots/api#acceptedgifttypes) +// +// This object describes the types of gifts that can be gifted to a user or a chat. +type AcceptedGiftTypes struct { + // True, if unlimited regular gifts are accepted + UnlimitedGifts bool `json:"unlimited_gifts"` + // True, if limited regular gifts are accepted + LimitedGifts bool `json:"limited_gifts"` + // True, if unique gifts or gifts that can be upgraded to unique for free are accepted + UniqueGifts bool `json:"unique_gifts"` + // True, if a Telegram Premium subscription is accepted + PremiumSubscription bool `json:"premium_subscription"` +} + +// AffiliateInfo (https://core.telegram.org/bots/api#affiliateinfo) +// +// Contains information about the affiliate that received a commission via this transaction. +type AffiliateInfo struct { + // Optional. The bot or the user that received an affiliate commission if it was received by a bot or a user + AffiliateUser *User `json:"affiliate_user,omitempty"` + // Optional. The chat that received an affiliate commission if it was received by a chat + AffiliateChat *Chat `json:"affiliate_chat,omitempty"` + // The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the bot from referred users + CommissionPerMille int64 `json:"commission_per_mille"` + // Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for refunds + Amount int64 `json:"amount"` + // Optional. The number of 1/1000000000 shares of Telegram Stars received by the affiliate; from -999999999 to 999999999; can be negative for refunds + NanostarAmount int64 `json:"nanostar_amount,omitempty"` +} + // Animation (https://core.telegram.org/bots/api#animation) // // This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound). @@ -541,7 +571,7 @@ func (v BackgroundTypeFill) backgroundType() {} // BackgroundTypePattern (https://core.telegram.org/bots/api#backgroundtypepattern) // -// The background is a PNG or TGV (gzipped subset of SVG with MIME type "application/x-tgwallpattern") pattern to be combined with the background fill chosen by the user. +// The background is a .PNG or .TGV (gzipped subset of SVG with MIME type "application/x-tgwallpattern") pattern to be combined with the background fill chosen by the user. type BackgroundTypePattern struct { // Document with the pattern Document Document `json:"document"` @@ -1006,6 +1036,40 @@ type BotShortDescription struct { ShortDescription string `json:"short_description"` } +// BusinessBotRights (https://core.telegram.org/bots/api#businessbotrights) +// +// Represents the rights of a business bot. +type BusinessBotRights struct { + // Optional. True, if the bot can send and edit messages in the private chats that had incoming messages in the last 24 hours + CanReply bool `json:"can_reply,omitempty"` + // Optional. True, if the bot can mark incoming private messages as read + CanReadMessages bool `json:"can_read_messages,omitempty"` + // Optional. True, if the bot can delete messages sent by the bot + CanDeleteOutgoingMessages bool `json:"can_delete_outgoing_messages,omitempty"` + // Optional. True, if the bot can delete all private messages in managed chats + CanDeleteAllMessages bool `json:"can_delete_all_messages,omitempty"` + // Optional. True, if the bot can edit the first and last name of the business account + CanEditName bool `json:"can_edit_name,omitempty"` + // Optional. True, if the bot can edit the bio of the business account + CanEditBio bool `json:"can_edit_bio,omitempty"` + // Optional. True, if the bot can edit the profile photo of the business account + CanEditProfilePhoto bool `json:"can_edit_profile_photo,omitempty"` + // Optional. True, if the bot can edit the username of the business account + CanEditUsername bool `json:"can_edit_username,omitempty"` + // Optional. True, if the bot can change the privacy settings pertaining to gifts for the business account + CanChangeGiftSettings bool `json:"can_change_gift_settings,omitempty"` + // Optional. True, if the bot can view gifts and the amount of Telegram Stars owned by the business account + CanViewGiftsAndStars bool `json:"can_view_gifts_and_stars,omitempty"` + // Optional. True, if the bot can convert regular gifts owned by the business account to Telegram Stars + CanConvertGiftsToStars bool `json:"can_convert_gifts_to_stars,omitempty"` + // Optional. True, if the bot can transfer and upgrade gifts owned by the business account + CanTransferAndUpgradeGifts bool `json:"can_transfer_and_upgrade_gifts,omitempty"` + // Optional. True, if the bot can transfer Telegram Stars received by the business account to its own account, or use them to upgrade and transfer gifts + CanTransferStars bool `json:"can_transfer_stars,omitempty"` + // Optional. True, if the bot can post, edit and delete stories on behalf of the business account + CanManageStories bool `json:"can_manage_stories,omitempty"` +} + // BusinessConnection (https://core.telegram.org/bots/api#businessconnection) // // Describes the connection of the bot with a business account. @@ -1018,8 +1082,8 @@ type BusinessConnection struct { UserChatId int64 `json:"user_chat_id"` // Date the connection was established in Unix time Date int64 `json:"date"` - // True, if the bot can act on behalf of the business account in chats that were active in the last 24 hours - CanReply bool `json:"can_reply"` + // Optional. Rights of the business bot + Rights *BusinessBotRights `json:"rights,omitempty"` // True, if the connection is active IsEnabled bool `json:"is_enabled"` } @@ -1620,6 +1684,8 @@ type ChatFullInfo struct { PinnedMessage *Message `json:"pinned_message,omitempty"` // Optional. Default chat member permissions, for groups and supergroups Permissions *ChatPermissions `json:"permissions,omitempty"` + // Information about types of gifts that are accepted by the chat or by the corresponding user for private chats + AcceptedGiftTypes AcceptedGiftTypes `json:"accepted_gift_types"` // Optional. True, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats. CanSendPaidMedia bool `json:"can_send_paid_media,omitempty"` // Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds @@ -1683,6 +1749,7 @@ func (v *ChatFullInfo) UnmarshalJSON(b []byte) error { InviteLink string `json:"invite_link"` PinnedMessage *Message `json:"pinned_message"` Permissions *ChatPermissions `json:"permissions"` + AcceptedGiftTypes AcceptedGiftTypes `json:"accepted_gift_types"` CanSendPaidMedia bool `json:"can_send_paid_media"` SlowModeDelay int64 `json:"slow_mode_delay"` UnrestrictBoostCount int64 `json:"unrestrict_boost_count"` @@ -1737,6 +1804,7 @@ func (v *ChatFullInfo) UnmarshalJSON(b []byte) error { v.InviteLink = t.InviteLink v.PinnedMessage = t.PinnedMessage v.Permissions = t.Permissions + v.AcceptedGiftTypes = t.AcceptedGiftTypes v.CanSendPaidMedia = t.CanSendPaidMedia v.SlowModeDelay = t.SlowModeDelay v.UnrestrictBoostCount = t.UnrestrictBoostCount @@ -2843,6 +2911,54 @@ type GeneralForumTopicHidden struct{} // This object represents a service message about General forum topic unhidden in the chat. Currently holds no information. type GeneralForumTopicUnhidden struct{} +// Gift (https://core.telegram.org/bots/api#gift) +// +// This object represents a gift that can be sent by the bot. +type Gift struct { + // Unique identifier of the gift + Id string `json:"id"` + // The sticker that represents the gift + Sticker Sticker `json:"sticker"` + // The number of Telegram Stars that must be paid to send the sticker + StarCount int64 `json:"star_count"` + // Optional. The number of Telegram Stars that must be paid to upgrade the gift to a unique one + UpgradeStarCount int64 `json:"upgrade_star_count,omitempty"` + // Optional. The total number of the gifts of this type that can be sent; for limited gifts only + TotalCount int64 `json:"total_count,omitempty"` + // Optional. The number of remaining gifts of this type that can be sent; for limited gifts only + RemainingCount int64 `json:"remaining_count,omitempty"` +} + +// GiftInfo (https://core.telegram.org/bots/api#giftinfo) +// +// Describes a service message about a regular gift that was sent or received. +type GiftInfo struct { + // Information about the gift + Gift Gift `json:"gift"` + // Optional. Unique identifier of the received gift for the bot; only present for gifts received on behalf of business accounts + OwnedGiftId string `json:"owned_gift_id,omitempty"` + // Optional. Number of Telegram Stars that can be claimed by the receiver by converting the gift; omitted if conversion to Telegram Stars is impossible + ConvertStarCount int64 `json:"convert_star_count,omitempty"` + // Optional. Number of Telegram Stars that were prepaid by the sender for the ability to upgrade the gift + PrepaidUpgradeStarCount int64 `json:"prepaid_upgrade_star_count,omitempty"` + // Optional. True, if the gift can be upgraded to a unique gift + CanBeUpgraded bool `json:"can_be_upgraded,omitempty"` + // Optional. Text of the message that was added to the gift + Text string `json:"text,omitempty"` + // Optional. Special entities that appear in the text + Entities []MessageEntity `json:"entities,omitempty"` + // Optional. True, if the sender and gift text are shown only to the gift receiver; otherwise, everyone will be able to see them + IsPrivate bool `json:"is_private,omitempty"` +} + +// Gifts (https://core.telegram.org/bots/api#gifts) +// +// This object represent a list of gifts. +type Gifts struct { + // The list of gifts + Gifts []Gift `json:"gifts,omitempty"` +} + // Giveaway (https://core.telegram.org/bots/api#giveaway) // // This object represents a message about a scheduled giveaway. @@ -3104,8 +3220,6 @@ type MergedInlineQueryResult struct { VoiceFileId string `json:"voice_file_id,omitempty"` // Optional. URL of the result (Only for article) Url string `json:"url,omitempty"` - // Optional. Pass True if you don't want the URL to be shown in the message (Only for article) - HideUrl bool `json:"hide_url,omitempty"` // Optional. Url of the thumbnail for the result (Only for article, contact, document, gif, location, mpeg4_gif, photo, venue, video) ThumbnailUrl string `json:"thumbnail_url,omitempty"` // Optional. Thumbnail width (Only for article, contact, document, location, venue) @@ -3132,7 +3246,7 @@ type MergedInlineQueryResult struct { DocumentUrl string `json:"document_url,omitempty"` // Optional. MIME type of the content of the file, either "application/pdf" or "application/zip" (Only for document, video) MimeType string `json:"mime_type,omitempty"` - // Optional. A valid URL for the GIF file. File size must not exceed 1MB (Only for gif) + // Optional. A valid URL for the GIF file (Only for gif) GifUrl string `json:"gif_url,omitempty"` // Optional. Width of the GIF (Only for gif) GifWidth int64 `json:"gif_width,omitempty"` @@ -3154,7 +3268,7 @@ type MergedInlineQueryResult struct { Heading int64 `json:"heading,omitempty"` // Optional. For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified. (Only for location) ProximityAlertRadius int64 `json:"proximity_alert_radius,omitempty"` - // Optional. A valid URL for the MPEG4 file. File size must not exceed 1MB (Only for mpeg4_gif) + // Optional. A valid URL for the MPEG4 file (Only for mpeg4_gif) Mpeg4Url string `json:"mpeg4_url,omitempty"` // Optional. Video width (Only for mpeg4_gif) Mpeg4Width int64 `json:"mpeg4_width,omitempty"` @@ -3224,8 +3338,6 @@ type InlineQueryResultArticle struct { ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // Optional. URL of the result Url string `json:"url,omitempty"` - // Optional. Pass True if you don't want the URL to be shown in the message - HideUrl bool `json:"hide_url,omitempty"` // Optional. Short description of the result Description string `json:"description,omitempty"` // Optional. Url of the thumbnail for the result @@ -3255,7 +3367,6 @@ func (v InlineQueryResultArticle) MergeInlineQueryResult() MergedInlineQueryResu InputMessageContent: v.InputMessageContent, ReplyMarkup: v.ReplyMarkup, Url: v.Url, - HideUrl: v.HideUrl, Description: v.Description, ThumbnailUrl: v.ThumbnailUrl, ThumbnailWidth: v.ThumbnailWidth, @@ -4059,7 +4170,7 @@ func (v InlineQueryResultGame) inlineQueryResult() {} type InlineQueryResultGif struct { // Unique identifier for this result, 1-64 bytes Id string `json:"id"` - // A valid URL for the GIF file. File size must not exceed 1MB + // A valid URL for the GIF file GifUrl string `json:"gif_url"` // Optional. Width of the GIF GifWidth int64 `json:"gif_width,omitempty"` @@ -4218,7 +4329,7 @@ func (v InlineQueryResultLocation) inlineQueryResult() {} type InlineQueryResultMpeg4Gif struct { // Unique identifier for this result, 1-64 bytes Id string `json:"id"` - // A valid URL for the MPEG4 file. File size must not exceed 1MB + // A valid URL for the MPEG4 file Mpeg4Url string `json:"mpeg4_url"` // Optional. Video width Mpeg4Width int64 `json:"mpeg4_width,omitempty"` @@ -4762,6 +4873,10 @@ type MergedInputMedia struct { Performer string `json:"performer,omitempty"` // Optional. Title of the audio (Only for audio) Title string `json:"title,omitempty"` + // Optional. Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. More information on Sending Files: https://core.telegram.org/bots/api#sending-files (Only for video) + Cover string `json:"cover,omitempty"` + // Optional. Start timestamp for the video in the message (Only for video) + StartTimestamp int64 `json:"start_timestamp,omitempty"` // Optional. Pass True if the uploaded video is suitable for streaming (Only for video) SupportsStreaming bool `json:"supports_streaming,omitempty"` } @@ -5103,6 +5218,10 @@ type InputMediaVideo struct { Media InputFileOrString `json:"media"` // Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass "attach://" if the thumbnail was uploaded using multipart/form-data under . More information on Sending Files: https://core.telegram.org/bots/api#sending-files Thumbnail InputFile `json:"thumbnail,omitempty"` + // Optional. Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. More information on Sending Files: https://core.telegram.org/bots/api#sending-files + Cover string `json:"cover,omitempty"` + // Optional. Start timestamp for the video in the message + StartTimestamp int64 `json:"start_timestamp,omitempty"` // Optional. Caption of the video to be sent, 0-1024 characters after entities parsing Caption string `json:"caption,omitempty"` // Optional. Mode for parsing entities in the video caption. See formatting options for more details. @@ -5139,6 +5258,8 @@ func (v InputMediaVideo) MergeInputMedia() MergedInputMedia { Type: "video", Media: v.Media, Thumbnail: v.Thumbnail, + Cover: v.Cover, + StartTimestamp: v.StartTimestamp, Caption: v.Caption, ParseMode: v.ParseMode, CaptionEntities: v.CaptionEntities, @@ -5237,6 +5358,10 @@ type MergedInputPaidMedia struct { Media InputFileOrString `json:"media"` // Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass "attach://" if the thumbnail was uploaded using multipart/form-data under . More information on Sending Files: https://core.telegram.org/bots/api#sending-files (Only for video) Thumbnail InputFile `json:"thumbnail,omitempty"` + // Optional. Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. More information on Sending Files: https://core.telegram.org/bots/api#sending-files (Only for video) + Cover string `json:"cover,omitempty"` + // Optional. Start timestamp for the video in the message (Only for video) + StartTimestamp int64 `json:"start_timestamp,omitempty"` // Optional. Video width (Only for video) Width int64 `json:"width,omitempty"` // Optional. Video height (Only for video) @@ -5326,6 +5451,10 @@ type InputPaidMediaVideo struct { Media InputFileOrString `json:"media"` // Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass "attach://" if the thumbnail was uploaded using multipart/form-data under . More information on Sending Files: https://core.telegram.org/bots/api#sending-files Thumbnail InputFile `json:"thumbnail,omitempty"` + // Optional. Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. More information on Sending Files: https://core.telegram.org/bots/api#sending-files + Cover string `json:"cover,omitempty"` + // Optional. Start timestamp for the video in the message + StartTimestamp int64 `json:"start_timestamp,omitempty"` // Optional. Video width Width int64 `json:"width,omitempty"` // Optional. Video height @@ -5352,6 +5481,8 @@ func (v InputPaidMediaVideo) MergeInputPaidMedia() MergedInputPaidMedia { Type: "video", Media: v.Media, Thumbnail: v.Thumbnail, + Cover: v.Cover, + StartTimestamp: v.StartTimestamp, Width: v.Width, Height: v.Height, Duration: v.Duration, @@ -5405,13 +5536,134 @@ type InputPollOption struct { TextEntities []MessageEntity `json:"text_entities,omitempty"` } +// InputProfilePhoto (https://core.telegram.org/bots/api#inputprofilephoto) +// +// This object describes a profile photo to set. Currently, it can be one of +// - InputProfilePhotoStatic +// - InputProfilePhotoAnimated +type InputProfilePhoto interface { + GetType() string + // MergeInputProfilePhoto returns a MergedInputProfilePhoto struct to simplify working with complex telegram types in a non-generic world. + MergeInputProfilePhoto() MergedInputProfilePhoto + // inputProfilePhoto exists to avoid external types implementing this interface. + inputProfilePhoto() +} + +// Ensure that all subtypes correctly implement the parent interface. +var ( + _ InputProfilePhoto = InputProfilePhotoStatic{} + _ InputProfilePhoto = InputProfilePhotoAnimated{} +) + +// MergedInputProfilePhoto is a helper type to simplify interactions with the various InputProfilePhoto subtypes. +type MergedInputProfilePhoto struct { + // Type of the profile photo, must be "static" + Type string `json:"type"` + // Optional. The static profile photo. Profile photos can't be reused and can only be uploaded as a new file, so you can pass "attach://" if the photo was uploaded using multipart/form-data under . More information on Sending Files: https://core.telegram.org/bots/api#sending-files (Only for static) + Photo string `json:"photo,omitempty"` + // Optional. The animated profile photo. Profile photos can't be reused and can only be uploaded as a new file, so you can pass "attach://" if the photo was uploaded using multipart/form-data under . More information on Sending Files: https://core.telegram.org/bots/api#sending-files (Only for animated) + Animation string `json:"animation,omitempty"` + // Optional. Timestamp in seconds of the frame that will be used as the static profile photo. Defaults to 0.0. (Only for animated) + MainFrameTimestamp float64 `json:"main_frame_timestamp,omitempty"` +} + +// GetType is a helper method to easily access the common fields of an interface. +func (v MergedInputProfilePhoto) GetType() string { + return v.Type +} + +// MergedInputProfilePhoto.inputProfilePhoto is a dummy method to avoid interface implementation. +func (v MergedInputProfilePhoto) inputProfilePhoto() {} + +// MergeInputProfilePhoto returns a MergedInputProfilePhoto struct to simplify working with types in a non-generic world. +func (v MergedInputProfilePhoto) MergeInputProfilePhoto() MergedInputProfilePhoto { + return v +} + +// InputProfilePhotoAnimated (https://core.telegram.org/bots/api#inputprofilephotoanimated) +// +// An animated profile photo in the MPEG4 format. +type InputProfilePhotoAnimated struct { + // The animated profile photo. Profile photos can't be reused and can only be uploaded as a new file, so you can pass "attach://" if the photo was uploaded using multipart/form-data under . More information on Sending Files: https://core.telegram.org/bots/api#sending-files + Animation string `json:"animation"` + // Optional. Timestamp in seconds of the frame that will be used as the static profile photo. Defaults to 0.0. + MainFrameTimestamp float64 `json:"main_frame_timestamp,omitempty"` +} + +// GetType is a helper method to easily access the common fields of an interface. +func (v InputProfilePhotoAnimated) GetType() string { + return "animated" +} + +// MergeInputProfilePhoto returns a MergedInputProfilePhoto struct to simplify working with types in a non-generic world. +func (v InputProfilePhotoAnimated) MergeInputProfilePhoto() MergedInputProfilePhoto { + return MergedInputProfilePhoto{ + Type: "animated", + Animation: v.Animation, + MainFrameTimestamp: v.MainFrameTimestamp, + } +} + +// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value. +func (v InputProfilePhotoAnimated) MarshalJSON() ([]byte, error) { + type alias InputProfilePhotoAnimated + a := struct { + Type string `json:"type"` + alias + }{ + Type: "animated", + alias: (alias)(v), + } + return json.Marshal(a) +} + +// InputProfilePhotoAnimated.inputProfilePhoto is a dummy method to avoid interface implementation. +func (v InputProfilePhotoAnimated) inputProfilePhoto() {} + +// InputProfilePhotoStatic (https://core.telegram.org/bots/api#inputprofilephotostatic) +// +// A static profile photo in the .JPG format. +type InputProfilePhotoStatic struct { + // The static profile photo. Profile photos can't be reused and can only be uploaded as a new file, so you can pass "attach://" if the photo was uploaded using multipart/form-data under . More information on Sending Files: https://core.telegram.org/bots/api#sending-files + Photo string `json:"photo"` +} + +// GetType is a helper method to easily access the common fields of an interface. +func (v InputProfilePhotoStatic) GetType() string { + return "static" +} + +// MergeInputProfilePhoto returns a MergedInputProfilePhoto struct to simplify working with types in a non-generic world. +func (v InputProfilePhotoStatic) MergeInputProfilePhoto() MergedInputProfilePhoto { + return MergedInputProfilePhoto{ + Type: "static", + Photo: v.Photo, + } +} + +// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value. +func (v InputProfilePhotoStatic) MarshalJSON() ([]byte, error) { + type alias InputProfilePhotoStatic + a := struct { + Type string `json:"type"` + alias + }{ + Type: "static", + alias: (alias)(v), + } + return json.Marshal(a) +} + +// InputProfilePhotoStatic.inputProfilePhoto is a dummy method to avoid interface implementation. +func (v InputProfilePhotoStatic) inputProfilePhoto() {} + // InputSticker (https://core.telegram.org/bots/api#inputsticker) // // This object describes a sticker to be added to a sticker set. type InputSticker struct { - // The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, upload a new one using multipart/form-data, or pass "attach://" to upload a new one using multipart/form-data under name. Animated and video stickers can't be uploaded via HTTP URL. More information on Sending Files: https://core.telegram.org/bots/api#sending-files - Sticker InputFileOrString `json:"sticker"` - // Format of the added sticker, must be one of "static" for a .WEBP or .PNG image, "animated" for a .TGS animation, "video" for a WEBM video + // The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or pass "attach://" to upload a new file using multipart/form-data under name. Animated and video stickers can't be uploaded via HTTP URL. More information on Sending Files: https://core.telegram.org/bots/api#sending-files + Sticker string `json:"sticker"` + // Format of the added sticker, must be one of "static" for a .WEBP or .PNG image, "animated" for a .TGS animation, "video" for a .WEBM video Format string `json:"format"` // List of 1-20 emoji associated with the sticker EmojiList []string `json:"emoji_list,omitempty"` @@ -5421,17 +5673,137 @@ type InputSticker struct { Keywords []string `json:"keywords,omitempty"` } -func (v InputSticker) InputParams(mediaName string, data map[string]FileReader) ([]byte, error) { - if v.Sticker != nil { - err := v.Sticker.Attach(mediaName, data) - if err != nil { - return nil, fmt.Errorf("failed to attach input file for %s: %w", mediaName, err) - } - } - - return json.Marshal(v) +// InputStoryContent (https://core.telegram.org/bots/api#inputstorycontent) +// +// This object describes the content of a story to post. Currently, it can be one of +// - InputStoryContentPhoto +// - InputStoryContentVideo +type InputStoryContent interface { + GetType() string + // MergeInputStoryContent returns a MergedInputStoryContent struct to simplify working with complex telegram types in a non-generic world. + MergeInputStoryContent() MergedInputStoryContent + // inputStoryContent exists to avoid external types implementing this interface. + inputStoryContent() } +// Ensure that all subtypes correctly implement the parent interface. +var ( + _ InputStoryContent = InputStoryContentPhoto{} + _ InputStoryContent = InputStoryContentVideo{} +) + +// MergedInputStoryContent is a helper type to simplify interactions with the various InputStoryContent subtypes. +type MergedInputStoryContent struct { + // Type of the content, must be "photo" + Type string `json:"type"` + // Optional. The photo to post as a story. The photo must be of the size 1080x1920 and must not exceed 10 MB. The photo can't be reused and can only be uploaded as a new file, so you can pass "attach://" if the photo was uploaded using multipart/form-data under . More information on Sending Files: https://core.telegram.org/bots/api#sending-files (Only for photo) + Photo string `json:"photo,omitempty"` + // Optional. The video to post as a story. The video must be of the size 720x1280, streamable, encoded with H.265 codec, with key frames added each second in the MPEG4 format, and must not exceed 30 MB. The video can't be reused and can only be uploaded as a new file, so you can pass "attach://" if the video was uploaded using multipart/form-data under . More information on Sending Files: https://core.telegram.org/bots/api#sending-files (Only for video) + Video string `json:"video,omitempty"` + // Optional. Precise duration of the video in seconds; 0-60 (Only for video) + Duration float64 `json:"duration,omitempty"` + // Optional. Timestamp in seconds of the frame that will be used as the static cover for the story. Defaults to 0.0. (Only for video) + CoverFrameTimestamp float64 `json:"cover_frame_timestamp,omitempty"` + // Optional. Pass True if the video has no sound (Only for video) + IsAnimation bool `json:"is_animation,omitempty"` +} + +// GetType is a helper method to easily access the common fields of an interface. +func (v MergedInputStoryContent) GetType() string { + return v.Type +} + +// MergedInputStoryContent.inputStoryContent is a dummy method to avoid interface implementation. +func (v MergedInputStoryContent) inputStoryContent() {} + +// MergeInputStoryContent returns a MergedInputStoryContent struct to simplify working with types in a non-generic world. +func (v MergedInputStoryContent) MergeInputStoryContent() MergedInputStoryContent { + return v +} + +// InputStoryContentPhoto (https://core.telegram.org/bots/api#inputstorycontentphoto) +// +// Describes a photo to post as a story. +type InputStoryContentPhoto struct { + // The photo to post as a story. The photo must be of the size 1080x1920 and must not exceed 10 MB. The photo can't be reused and can only be uploaded as a new file, so you can pass "attach://" if the photo was uploaded using multipart/form-data under . More information on Sending Files: https://core.telegram.org/bots/api#sending-files + Photo string `json:"photo"` +} + +// GetType is a helper method to easily access the common fields of an interface. +func (v InputStoryContentPhoto) GetType() string { + return "photo" +} + +// MergeInputStoryContent returns a MergedInputStoryContent struct to simplify working with types in a non-generic world. +func (v InputStoryContentPhoto) MergeInputStoryContent() MergedInputStoryContent { + return MergedInputStoryContent{ + Type: "photo", + Photo: v.Photo, + } +} + +// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value. +func (v InputStoryContentPhoto) MarshalJSON() ([]byte, error) { + type alias InputStoryContentPhoto + a := struct { + Type string `json:"type"` + alias + }{ + Type: "photo", + alias: (alias)(v), + } + return json.Marshal(a) +} + +// InputStoryContentPhoto.inputStoryContent is a dummy method to avoid interface implementation. +func (v InputStoryContentPhoto) inputStoryContent() {} + +// InputStoryContentVideo (https://core.telegram.org/bots/api#inputstorycontentvideo) +// +// Describes a video to post as a story. +type InputStoryContentVideo struct { + // The video to post as a story. The video must be of the size 720x1280, streamable, encoded with H.265 codec, with key frames added each second in the MPEG4 format, and must not exceed 30 MB. The video can't be reused and can only be uploaded as a new file, so you can pass "attach://" if the video was uploaded using multipart/form-data under . More information on Sending Files: https://core.telegram.org/bots/api#sending-files + Video string `json:"video"` + // Optional. Precise duration of the video in seconds; 0-60 + Duration float64 `json:"duration,omitempty"` + // Optional. Timestamp in seconds of the frame that will be used as the static cover for the story. Defaults to 0.0. + CoverFrameTimestamp float64 `json:"cover_frame_timestamp,omitempty"` + // Optional. Pass True if the video has no sound + IsAnimation bool `json:"is_animation,omitempty"` +} + +// GetType is a helper method to easily access the common fields of an interface. +func (v InputStoryContentVideo) GetType() string { + return "video" +} + +// MergeInputStoryContent returns a MergedInputStoryContent struct to simplify working with types in a non-generic world. +func (v InputStoryContentVideo) MergeInputStoryContent() MergedInputStoryContent { + return MergedInputStoryContent{ + Type: "video", + Video: v.Video, + Duration: v.Duration, + CoverFrameTimestamp: v.CoverFrameTimestamp, + IsAnimation: v.IsAnimation, + } +} + +// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value. +func (v InputStoryContentVideo) MarshalJSON() ([]byte, error) { + type alias InputStoryContentVideo + a := struct { + Type string `json:"type"` + alias + }{ + Type: "video", + alias: (alias)(v), + } + return json.Marshal(a) +} + +// InputStoryContentVideo.inputStoryContent is a dummy method to avoid interface implementation. +func (v InputStoryContentVideo) inputStoryContent() {} + // InputTextMessageContent (https://core.telegram.org/bots/api#inputtextmessagecontent) // // Represents the content of a text message to be sent as the result of an inline query. @@ -5611,6 +5983,20 @@ type Location struct { ProximityAlertRadius int64 `json:"proximity_alert_radius,omitempty"` } +// LocationAddress (https://core.telegram.org/bots/api#locationaddress) +// +// Describes the physical address of a location. +type LocationAddress struct { + // The two-letter ISO 3166-1 alpha-2 country code of the country where the location is located + CountryCode string `json:"country_code"` + // Optional. State of the location + State string `json:"state,omitempty"` + // Optional. City of the location + City string `json:"city,omitempty"` + // Optional. Street address of the location + Street string `json:"street,omitempty"` +} + // LoginUrl (https://core.telegram.org/bots/api#loginurl) // // This object represents a parameter of the inline keyboard button used to automatically authorize a user. Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram. All the user needs to do is tap/click a button and confirm that they want to log in: @@ -5671,6 +6057,8 @@ type MaybeInaccessibleMessage interface { Forward(b *Bot, chatId int64, opts *ForwardMessageOpts) (*Message, error) // Pin Helper method for Bot.PinChatMessage. Pin(b *Bot, opts *PinChatMessageOpts) (bool, error) + // ReadBusiness Helper method for Bot.ReadBusinessMessage. + ReadBusiness(b *Bot, businessConnectionId string, opts *ReadBusinessMessageOpts) (bool, error) // SetReaction Helper method for Bot.SetMessageReaction. SetReaction(b *Bot, opts *SetMessageReactionOpts) (bool, error) // StopLiveLocation Helper method for Bot.StopMessageLiveLocation. @@ -5954,6 +6342,8 @@ type Message struct { MediaGroupId string `json:"media_group_id,omitempty"` // Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group administrator AuthorSignature string `json:"author_signature,omitempty"` + // Optional. The number of Telegram Stars that were paid by the sender of the message to send it + PaidStarCount int64 `json:"paid_star_count,omitempty"` // Optional. For text messages, the actual UTF-8 text of the message Text string `json:"text,omitempty"` // Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text @@ -6036,6 +6426,10 @@ type Message struct { UsersShared *UsersShared `json:"users_shared,omitempty"` // Optional. Service message: a chat was shared with the bot ChatShared *ChatShared `json:"chat_shared,omitempty"` + // Optional. Service message: a regular gift was sent or received + Gift *GiftInfo `json:"gift,omitempty"` + // Optional. Service message: a unique gift was sent or received + UniqueGift *UniqueGiftInfo `json:"unique_gift,omitempty"` // Optional. The domain name of the website on which the user has logged in. More about Telegram Login: https://core.telegram.org/widgets/login ConnectedWebsite string `json:"connected_website,omitempty"` // Optional. Service message: the user allowed the bot to write messages after adding it to the attachment or side menu, launching a Web App from a link, or accepting an explicit request from a Web App sent by the method requestWriteAccess @@ -6068,6 +6462,8 @@ type Message struct { GiveawayWinners *GiveawayWinners `json:"giveaway_winners,omitempty"` // Optional. Service message: a giveaway without public winners was completed GiveawayCompleted *GiveawayCompleted `json:"giveaway_completed,omitempty"` + // Optional. Service message: the price for paid messages has changed in the chat + PaidMessagePriceChanged *PaidMessagePriceChanged `json:"paid_message_price_changed,omitempty"` // Optional. Service message: video chat scheduled VideoChatScheduled *VideoChatScheduled `json:"video_chat_scheduled,omitempty"` // Optional. Service message: video chat started @@ -6108,6 +6504,7 @@ func (v *Message) UnmarshalJSON(b []byte) error { IsFromOffline bool `json:"is_from_offline"` MediaGroupId string `json:"media_group_id"` AuthorSignature string `json:"author_signature"` + PaidStarCount int64 `json:"paid_star_count"` Text string `json:"text"` Entities []MessageEntity `json:"entities"` LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options"` @@ -6149,6 +6546,8 @@ func (v *Message) UnmarshalJSON(b []byte) error { RefundedPayment *RefundedPayment `json:"refunded_payment"` UsersShared *UsersShared `json:"users_shared"` ChatShared *ChatShared `json:"chat_shared"` + Gift *GiftInfo `json:"gift"` + UniqueGift *UniqueGiftInfo `json:"unique_gift"` ConnectedWebsite string `json:"connected_website"` WriteAccessAllowed *WriteAccessAllowed `json:"write_access_allowed"` PassportData *PassportData `json:"passport_data"` @@ -6165,6 +6564,7 @@ func (v *Message) UnmarshalJSON(b []byte) error { Giveaway *Giveaway `json:"giveaway"` GiveawayWinners *GiveawayWinners `json:"giveaway_winners"` GiveawayCompleted *GiveawayCompleted `json:"giveaway_completed"` + PaidMessagePriceChanged *PaidMessagePriceChanged `json:"paid_message_price_changed"` VideoChatScheduled *VideoChatScheduled `json:"video_chat_scheduled"` VideoChatStarted *VideoChatStarted `json:"video_chat_started"` VideoChatEnded *VideoChatEnded `json:"video_chat_ended"` @@ -6203,6 +6603,7 @@ func (v *Message) UnmarshalJSON(b []byte) error { v.IsFromOffline = t.IsFromOffline v.MediaGroupId = t.MediaGroupId v.AuthorSignature = t.AuthorSignature + v.PaidStarCount = t.PaidStarCount v.Text = t.Text v.Entities = t.Entities v.LinkPreviewOptions = t.LinkPreviewOptions @@ -6247,6 +6648,8 @@ func (v *Message) UnmarshalJSON(b []byte) error { v.RefundedPayment = t.RefundedPayment v.UsersShared = t.UsersShared v.ChatShared = t.ChatShared + v.Gift = t.Gift + v.UniqueGift = t.UniqueGift v.ConnectedWebsite = t.ConnectedWebsite v.WriteAccessAllowed = t.WriteAccessAllowed v.PassportData = t.PassportData @@ -6263,6 +6666,7 @@ func (v *Message) UnmarshalJSON(b []byte) error { v.Giveaway = t.Giveaway v.GiveawayWinners = t.GiveawayWinners v.GiveawayCompleted = t.GiveawayCompleted + v.PaidMessagePriceChanged = t.PaidMessagePriceChanged v.VideoChatScheduled = t.VideoChatScheduled v.VideoChatStarted = t.VideoChatStarted v.VideoChatEnded = t.VideoChatEnded @@ -6738,6 +7142,223 @@ type OrderInfo struct { ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"` } +// OwnedGift (https://core.telegram.org/bots/api#ownedgift) +// +// This object describes a gift received and owned by a user or a chat. Currently, it can be one of +// - OwnedGiftRegular +// - OwnedGiftUnique +type OwnedGift interface { + GetType() string + GetSendDate() int64 + // ownedGift exists to avoid external types implementing this interface. + ownedGift() +} + +// Ensure that all subtypes correctly implement the parent interface. +var ( + _ OwnedGift = OwnedGiftRegular{} + _ OwnedGift = OwnedGiftUnique{} +) + +// unmarshalOwnedGiftArray is a JSON unmarshalling helper which allows unmarshalling an array of interfaces +// using unmarshalOwnedGift. +func unmarshalOwnedGiftArray(d json.RawMessage) ([]OwnedGift, error) { + if len(d) == 0 { + return nil, nil + } + + var ds []json.RawMessage + err := json.Unmarshal(d, &ds) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal initial OwnedGift JSON into an array: %w", err) + } + + var vs []OwnedGift + for idx, d := range ds { + v, err := unmarshalOwnedGift(d) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal OwnedGift on array item %d: %w", idx, err) + } + vs = append(vs, v) + } + + return vs, nil +} + +// unmarshalOwnedGift is a JSON unmarshal helper to marshal the right structs into a OwnedGift interface +// based on the Type field. +func unmarshalOwnedGift(d json.RawMessage) (OwnedGift, error) { + if len(d) == 0 { + return nil, nil + } + + t := struct { + Type string + }{} + err := json.Unmarshal(d, &t) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal OwnedGift for constant field 'Type': %w", err) + } + + switch t.Type { + case "regular": + s := OwnedGiftRegular{} + err := json.Unmarshal(d, &s) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal OwnedGift for value 'regular': %w", err) + } + return s, nil + + case "unique": + s := OwnedGiftUnique{} + err := json.Unmarshal(d, &s) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal OwnedGift for value 'unique': %w", err) + } + return s, nil + + } + return nil, fmt.Errorf("unknown interface for OwnedGift with Type %v", t.Type) +} + +// OwnedGiftRegular (https://core.telegram.org/bots/api#ownedgiftregular) +// +// Describes a regular gift owned by a user or a chat. +type OwnedGiftRegular struct { + // Information about the regular gift + Gift Gift `json:"gift"` + // Optional. Unique identifier of the gift for the bot; for gifts received on behalf of business accounts only + OwnedGiftId string `json:"owned_gift_id,omitempty"` + // Optional. Sender of the gift if it is a known user + SenderUser *User `json:"sender_user,omitempty"` + // Date the gift was sent in Unix time + SendDate int64 `json:"send_date"` + // Optional. Text of the message that was added to the gift + Text string `json:"text,omitempty"` + // Optional. Special entities that appear in the text + Entities []MessageEntity `json:"entities,omitempty"` + // Optional. True, if the sender and gift text are shown only to the gift receiver; otherwise, everyone will be able to see them + IsPrivate bool `json:"is_private,omitempty"` + // Optional. True, if the gift is displayed on the account's profile page; for gifts received on behalf of business accounts only + IsSaved bool `json:"is_saved,omitempty"` + // Optional. True, if the gift can be upgraded to a unique gift; for gifts received on behalf of business accounts only + CanBeUpgraded bool `json:"can_be_upgraded,omitempty"` + // Optional. True, if the gift was refunded and isn't available anymore + WasRefunded bool `json:"was_refunded,omitempty"` + // Optional. Number of Telegram Stars that can be claimed by the receiver instead of the gift; omitted if the gift cannot be converted to Telegram Stars + ConvertStarCount int64 `json:"convert_star_count,omitempty"` + // Optional. Number of Telegram Stars that were paid by the sender for the ability to upgrade the gift + PrepaidUpgradeStarCount int64 `json:"prepaid_upgrade_star_count,omitempty"` +} + +// GetType is a helper method to easily access the common fields of an interface. +func (v OwnedGiftRegular) GetType() string { + return "regular" +} + +// GetSendDate is a helper method to easily access the common fields of an interface. +func (v OwnedGiftRegular) GetSendDate() int64 { + return v.SendDate +} + +// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value. +func (v OwnedGiftRegular) MarshalJSON() ([]byte, error) { + type alias OwnedGiftRegular + a := struct { + Type string `json:"type"` + alias + }{ + Type: "regular", + alias: (alias)(v), + } + return json.Marshal(a) +} + +// OwnedGiftRegular.ownedGift is a dummy method to avoid interface implementation. +func (v OwnedGiftRegular) ownedGift() {} + +// OwnedGiftUnique (https://core.telegram.org/bots/api#ownedgiftunique) +// +// Describes a unique gift received and owned by a user or a chat. +type OwnedGiftUnique struct { + // Information about the unique gift + Gift UniqueGift `json:"gift"` + // Optional. Unique identifier of the received gift for the bot; for gifts received on behalf of business accounts only + OwnedGiftId string `json:"owned_gift_id,omitempty"` + // Optional. Sender of the gift if it is a known user + SenderUser *User `json:"sender_user,omitempty"` + // Date the gift was sent in Unix time + SendDate int64 `json:"send_date"` + // Optional. True, if the gift is displayed on the account's profile page; for gifts received on behalf of business accounts only + IsSaved bool `json:"is_saved,omitempty"` + // Optional. True, if the gift can be transferred to another owner; for gifts received on behalf of business accounts only + CanBeTransferred bool `json:"can_be_transferred,omitempty"` + // Optional. Number of Telegram Stars that must be paid to transfer the gift; omitted if the bot cannot transfer the gift + TransferStarCount int64 `json:"transfer_star_count,omitempty"` +} + +// GetType is a helper method to easily access the common fields of an interface. +func (v OwnedGiftUnique) GetType() string { + return "unique" +} + +// GetSendDate is a helper method to easily access the common fields of an interface. +func (v OwnedGiftUnique) GetSendDate() int64 { + return v.SendDate +} + +// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value. +func (v OwnedGiftUnique) MarshalJSON() ([]byte, error) { + type alias OwnedGiftUnique + a := struct { + Type string `json:"type"` + alias + }{ + Type: "unique", + alias: (alias)(v), + } + return json.Marshal(a) +} + +// OwnedGiftUnique.ownedGift is a dummy method to avoid interface implementation. +func (v OwnedGiftUnique) ownedGift() {} + +// OwnedGifts (https://core.telegram.org/bots/api#ownedgifts) +// +// Contains the list of gifts received and owned by a user or a chat. +type OwnedGifts struct { + // The total number of gifts owned by the user or the chat + TotalCount int64 `json:"total_count"` + // The list of gifts + Gifts []OwnedGift `json:"gifts,omitempty"` + // Optional. Offset for the next request. If empty, then there are no more results + NextOffset string `json:"next_offset,omitempty"` +} + +// UnmarshalJSON is a custom JSON unmarshaller to use the helpers which allow for unmarshalling structs into interfaces. +func (v *OwnedGifts) UnmarshalJSON(b []byte) error { + // All fields in OwnedGifts, with interface fields as json.RawMessage + type tmp struct { + TotalCount int64 `json:"total_count"` + Gifts json.RawMessage `json:"gifts"` + NextOffset string `json:"next_offset"` + } + t := tmp{} + err := json.Unmarshal(b, &t) + if err != nil { + return fmt.Errorf("failed to unmarshal OwnedGifts JSON into tmp struct: %w", err) + } + + v.TotalCount = t.TotalCount + v.Gifts, err = unmarshalOwnedGiftArray(t.Gifts) + if err != nil { + return fmt.Errorf("failed to unmarshal custom JSON field Gifts: %w", err) + } + v.NextOffset = t.NextOffset + + return nil +} + // PaidMedia (https://core.telegram.org/bots/api#paidmedia) // // This object describes paid media. Currently, it can be one of @@ -7016,6 +7637,14 @@ func (v PaidMediaVideo) MarshalJSON() ([]byte, error) { // PaidMediaVideo.paidMedia is a dummy method to avoid interface implementation. func (v PaidMediaVideo) paidMedia() {} +// PaidMessagePriceChanged (https://core.telegram.org/bots/api#paidmessagepricechanged) +// +// Describes a service message about a change in the price of paid messages within a chat. +type PaidMessagePriceChanged struct { + // The new number of Telegram Stars that must be paid by non-administrator users of the supergroup chat for each sent message + PaidMessageStarCount int64 `json:"paid_message_star_count"` +} + // PassportData (https://core.telegram.org/bots/api#passportdata) // // Describes Telegram Passport data shared with the bot by the user. @@ -7694,6 +8323,16 @@ type PreCheckoutQuery struct { OrderInfo *OrderInfo `json:"order_info,omitempty"` } +// PreparedInlineMessage (https://core.telegram.org/bots/api#preparedinlinemessage) +// +// Describes an inline message to be sent by a user of a Mini App. +type PreparedInlineMessage struct { + // Unique identifier of the prepared message + Id string `json:"id"` + // Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used + ExpirationDate int64 `json:"expiration_date"` +} + // ProximityAlertTriggered (https://core.telegram.org/bots/api#proximityalerttriggered) // // This object represents the content of a service message, sent whenever a user in the chat triggers a proximity alert set by another user. @@ -8325,14 +8964,26 @@ type ShippingQuery struct { ShippingAddress ShippingAddress `json:"shipping_address"` } +// StarAmount (https://core.telegram.org/bots/api#staramount) +// +// Describes an amount of Telegram Stars. +type StarAmount struct { + // Integer amount of Telegram Stars, rounded to 0; can be negative + Amount int64 `json:"amount"` + // Optional. The number of 1/1000000000 shares of Telegram Stars; from -999999999 to 999999999; can be negative if and only if amount is non-positive + NanostarAmount int64 `json:"nanostar_amount,omitempty"` +} + // StarTransaction (https://core.telegram.org/bots/api#startransaction) // -// Describes a Telegram Star transaction. +// Describes a Telegram Star transaction. Note that if the buyer initiates a chargeback with the payment provider from whom they acquired Stars (e.g., Apple, Google) following this transaction, the refunded Stars will be deducted from the bot's balance. This is outside of Telegram's control. type StarTransaction struct { // Unique identifier of the transaction. Coincides with the identifier of the original transaction for refund transactions. Coincides with SuccessfulPayment.telegram_payment_charge_id for successful incoming payments from users. Id string `json:"id"` - // Number of Telegram Stars transferred by the transaction + // Integer amount of Telegram Stars transferred by the transaction Amount int64 `json:"amount"` + // Optional. The number of 1/1000000000 shares of Telegram Stars transferred by the transaction; from 0 to 999999999 + NanostarAmount int64 `json:"nanostar_amount,omitempty"` // Date the transaction was created in Unix time Date int64 `json:"date"` // Optional. Source of an incoming transaction (e.g., a user purchasing goods or services, Fragment refunding a failed withdrawal). Only for incoming transactions @@ -8345,11 +8996,12 @@ type StarTransaction struct { func (v *StarTransaction) UnmarshalJSON(b []byte) error { // All fields in StarTransaction, with interface fields as json.RawMessage type tmp struct { - Id string `json:"id"` - Amount int64 `json:"amount"` - Date int64 `json:"date"` - Source json.RawMessage `json:"source"` - Receiver json.RawMessage `json:"receiver"` + Id string `json:"id"` + Amount int64 `json:"amount"` + NanostarAmount int64 `json:"nanostar_amount"` + Date int64 `json:"date"` + Source json.RawMessage `json:"source"` + Receiver json.RawMessage `json:"receiver"` } t := tmp{} err := json.Unmarshal(b, &t) @@ -8359,6 +9011,7 @@ func (v *StarTransaction) UnmarshalJSON(b []byte) error { v.Id = t.Id v.Amount = t.Amount + v.NanostarAmount = t.NanostarAmount v.Date = t.Date v.Source, err = unmarshalTransactionPartner(t.Source) if err != nil { @@ -8442,9 +9095,306 @@ type Story struct { Id int64 `json:"id"` } +// StoryArea (https://core.telegram.org/bots/api#storyarea) +// +// Describes a clickable area on a story media. +type StoryArea struct { + // Position of the area + Position StoryAreaPosition `json:"position"` + // Type of the area + Type StoryAreaType `json:"type"` +} + +// StoryAreaPosition (https://core.telegram.org/bots/api#storyareaposition) +// +// Describes the position of a clickable area within a story. +type StoryAreaPosition struct { + // The abscissa of the area's center, as a percentage of the media width + XPercentage float64 `json:"x_percentage"` + // The ordinate of the area's center, as a percentage of the media height + YPercentage float64 `json:"y_percentage"` + // The width of the area's rectangle, as a percentage of the media width + WidthPercentage float64 `json:"width_percentage"` + // The height of the area's rectangle, as a percentage of the media height + HeightPercentage float64 `json:"height_percentage"` + // The clockwise rotation angle of the rectangle, in degrees; 0-360 + RotationAngle float64 `json:"rotation_angle"` + // The radius of the rectangle corner rounding, as a percentage of the media width + CornerRadiusPercentage float64 `json:"corner_radius_percentage"` +} + +// StoryAreaType (https://core.telegram.org/bots/api#storyareatype) +// +// Describes the type of a clickable area on a story. Currently, it can be one of +// - StoryAreaTypeLocation +// - StoryAreaTypeSuggestedReaction +// - StoryAreaTypeLink +// - StoryAreaTypeWeather +// - StoryAreaTypeUniqueGift +type StoryAreaType interface { + GetType() string + // MergeStoryAreaType returns a MergedStoryAreaType struct to simplify working with complex telegram types in a non-generic world. + MergeStoryAreaType() MergedStoryAreaType + // storyAreaType exists to avoid external types implementing this interface. + storyAreaType() +} + +// Ensure that all subtypes correctly implement the parent interface. +var ( + _ StoryAreaType = StoryAreaTypeLocation{} + _ StoryAreaType = StoryAreaTypeSuggestedReaction{} + _ StoryAreaType = StoryAreaTypeLink{} + _ StoryAreaType = StoryAreaTypeWeather{} + _ StoryAreaType = StoryAreaTypeUniqueGift{} +) + +// MergedStoryAreaType is a helper type to simplify interactions with the various StoryAreaType subtypes. +type MergedStoryAreaType struct { + // Type of the area + Type string `json:"type"` + // Optional. Location latitude in degrees (Only for location) + Latitude float64 `json:"latitude,omitempty"` + // Optional. Location longitude in degrees (Only for location) + Longitude float64 `json:"longitude,omitempty"` + // Optional. Address of the location (Only for location) + Address *LocationAddress `json:"address,omitempty"` + // Optional. Type of the reaction (Only for suggested_reaction) + ReactionType ReactionType `json:"reaction_type,omitempty"` + // Optional. Pass True if the reaction area has a dark background (Only for suggested_reaction) + IsDark bool `json:"is_dark,omitempty"` + // Optional. Pass True if reaction area corner is flipped (Only for suggested_reaction) + IsFlipped bool `json:"is_flipped,omitempty"` + // Optional. HTTP or tg:// URL to be opened when the area is clicked (Only for link) + Url string `json:"url,omitempty"` + // Optional. Temperature, in degree Celsius (Only for weather) + Temperature float64 `json:"temperature,omitempty"` + // Optional. Emoji representing the weather (Only for weather) + Emoji string `json:"emoji,omitempty"` + // Optional. A color of the area background in the ARGB format (Only for weather) + BackgroundColor int64 `json:"background_color,omitempty"` + // Optional. Unique name of the gift (Only for unique_gift) + Name string `json:"name,omitempty"` +} + +// GetType is a helper method to easily access the common fields of an interface. +func (v MergedStoryAreaType) GetType() string { + return v.Type +} + +// MergedStoryAreaType.storyAreaType is a dummy method to avoid interface implementation. +func (v MergedStoryAreaType) storyAreaType() {} + +// MergeStoryAreaType returns a MergedStoryAreaType struct to simplify working with types in a non-generic world. +func (v MergedStoryAreaType) MergeStoryAreaType() MergedStoryAreaType { + return v +} + +// StoryAreaTypeLink (https://core.telegram.org/bots/api#storyareatypelink) +// +// Describes a story area pointing to an HTTP or tg:// link. Currently, a story can have up to 3 link areas. +type StoryAreaTypeLink struct { + // HTTP or tg:// URL to be opened when the area is clicked + Url string `json:"url"` +} + +// GetType is a helper method to easily access the common fields of an interface. +func (v StoryAreaTypeLink) GetType() string { + return "link" +} + +// MergeStoryAreaType returns a MergedStoryAreaType struct to simplify working with types in a non-generic world. +func (v StoryAreaTypeLink) MergeStoryAreaType() MergedStoryAreaType { + return MergedStoryAreaType{ + Type: "link", + Url: v.Url, + } +} + +// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value. +func (v StoryAreaTypeLink) MarshalJSON() ([]byte, error) { + type alias StoryAreaTypeLink + a := struct { + Type string `json:"type"` + alias + }{ + Type: "link", + alias: (alias)(v), + } + return json.Marshal(a) +} + +// StoryAreaTypeLink.storyAreaType is a dummy method to avoid interface implementation. +func (v StoryAreaTypeLink) storyAreaType() {} + +// StoryAreaTypeLocation (https://core.telegram.org/bots/api#storyareatypelocation) +// +// Describes a story area pointing to a location. Currently, a story can have up to 10 location areas. +type StoryAreaTypeLocation struct { + // Location latitude in degrees + Latitude float64 `json:"latitude"` + // Location longitude in degrees + Longitude float64 `json:"longitude"` + // Optional. Address of the location + Address *LocationAddress `json:"address,omitempty"` +} + +// GetType is a helper method to easily access the common fields of an interface. +func (v StoryAreaTypeLocation) GetType() string { + return "location" +} + +// MergeStoryAreaType returns a MergedStoryAreaType struct to simplify working with types in a non-generic world. +func (v StoryAreaTypeLocation) MergeStoryAreaType() MergedStoryAreaType { + return MergedStoryAreaType{ + Type: "location", + Latitude: v.Latitude, + Longitude: v.Longitude, + Address: v.Address, + } +} + +// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value. +func (v StoryAreaTypeLocation) MarshalJSON() ([]byte, error) { + type alias StoryAreaTypeLocation + a := struct { + Type string `json:"type"` + alias + }{ + Type: "location", + alias: (alias)(v), + } + return json.Marshal(a) +} + +// StoryAreaTypeLocation.storyAreaType is a dummy method to avoid interface implementation. +func (v StoryAreaTypeLocation) storyAreaType() {} + +// StoryAreaTypeSuggestedReaction (https://core.telegram.org/bots/api#storyareatypesuggestedreaction) +// +// Describes a story area pointing to a suggested reaction. Currently, a story can have up to 5 suggested reaction areas. +type StoryAreaTypeSuggestedReaction struct { + // Type of the reaction + ReactionType ReactionType `json:"reaction_type"` + // Optional. Pass True if the reaction area has a dark background + IsDark bool `json:"is_dark,omitempty"` + // Optional. Pass True if reaction area corner is flipped + IsFlipped bool `json:"is_flipped,omitempty"` +} + +// GetType is a helper method to easily access the common fields of an interface. +func (v StoryAreaTypeSuggestedReaction) GetType() string { + return "suggested_reaction" +} + +// MergeStoryAreaType returns a MergedStoryAreaType struct to simplify working with types in a non-generic world. +func (v StoryAreaTypeSuggestedReaction) MergeStoryAreaType() MergedStoryAreaType { + return MergedStoryAreaType{ + Type: "suggested_reaction", + ReactionType: v.ReactionType, + IsDark: v.IsDark, + IsFlipped: v.IsFlipped, + } +} + +// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value. +func (v StoryAreaTypeSuggestedReaction) MarshalJSON() ([]byte, error) { + type alias StoryAreaTypeSuggestedReaction + a := struct { + Type string `json:"type"` + alias + }{ + Type: "suggested_reaction", + alias: (alias)(v), + } + return json.Marshal(a) +} + +// StoryAreaTypeSuggestedReaction.storyAreaType is a dummy method to avoid interface implementation. +func (v StoryAreaTypeSuggestedReaction) storyAreaType() {} + +// StoryAreaTypeUniqueGift (https://core.telegram.org/bots/api#storyareatypeuniquegift) +// +// Describes a story area pointing to a unique gift. Currently, a story can have at most 1 unique gift area. +type StoryAreaTypeUniqueGift struct { + // Unique name of the gift + Name string `json:"name"` +} + +// GetType is a helper method to easily access the common fields of an interface. +func (v StoryAreaTypeUniqueGift) GetType() string { + return "unique_gift" +} + +// MergeStoryAreaType returns a MergedStoryAreaType struct to simplify working with types in a non-generic world. +func (v StoryAreaTypeUniqueGift) MergeStoryAreaType() MergedStoryAreaType { + return MergedStoryAreaType{ + Type: "unique_gift", + Name: v.Name, + } +} + +// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value. +func (v StoryAreaTypeUniqueGift) MarshalJSON() ([]byte, error) { + type alias StoryAreaTypeUniqueGift + a := struct { + Type string `json:"type"` + alias + }{ + Type: "unique_gift", + alias: (alias)(v), + } + return json.Marshal(a) +} + +// StoryAreaTypeUniqueGift.storyAreaType is a dummy method to avoid interface implementation. +func (v StoryAreaTypeUniqueGift) storyAreaType() {} + +// StoryAreaTypeWeather (https://core.telegram.org/bots/api#storyareatypeweather) +// +// Describes a story area containing weather information. Currently, a story can have up to 3 weather areas. +type StoryAreaTypeWeather struct { + // Temperature, in degree Celsius + Temperature float64 `json:"temperature"` + // Emoji representing the weather + Emoji string `json:"emoji"` + // A color of the area background in the ARGB format + BackgroundColor int64 `json:"background_color"` +} + +// GetType is a helper method to easily access the common fields of an interface. +func (v StoryAreaTypeWeather) GetType() string { + return "weather" +} + +// MergeStoryAreaType returns a MergedStoryAreaType struct to simplify working with types in a non-generic world. +func (v StoryAreaTypeWeather) MergeStoryAreaType() MergedStoryAreaType { + return MergedStoryAreaType{ + Type: "weather", + Temperature: v.Temperature, + Emoji: v.Emoji, + BackgroundColor: v.BackgroundColor, + } +} + +// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value. +func (v StoryAreaTypeWeather) MarshalJSON() ([]byte, error) { + type alias StoryAreaTypeWeather + a := struct { + Type string `json:"type"` + alias + }{ + Type: "weather", + alias: (alias)(v), + } + return json.Marshal(a) +} + +// StoryAreaTypeWeather.storyAreaType is a dummy method to avoid interface implementation. +func (v StoryAreaTypeWeather) storyAreaType() {} + // SuccessfulPayment (https://core.telegram.org/bots/api#successfulpayment) // -// This object contains basic information about a successful payment. +// This object contains basic information about a successful payment. Note that if the buyer initiates a chargeback with the relevant payment provider following this transaction, the funds may be debited from your balance. This is outside of Telegram's control. type SuccessfulPayment struct { // Three-letter ISO 4217 currency code, or "XTR" for payments in Telegram Stars Currency string `json:"currency"` @@ -8452,6 +9402,12 @@ type SuccessfulPayment struct { TotalAmount int64 `json:"total_amount"` // Bot-specified invoice payload InvoicePayload string `json:"invoice_payload"` + // Optional. Expiration date of the subscription, in Unix time; for recurring payments only + SubscriptionExpirationDate int64 `json:"subscription_expiration_date,omitempty"` + // Optional. True, if the payment is a recurring payment for a subscription + IsRecurring bool `json:"is_recurring,omitempty"` + // Optional. True, if the payment is the first payment for a subscription + IsFirstRecurring bool `json:"is_first_recurring,omitempty"` // Optional. Identifier of the shipping option chosen by the user ShippingOptionId string `json:"shipping_option_id,omitempty"` // Optional. Order information provided by the user @@ -8496,6 +9452,8 @@ type TextQuote struct { // // This object describes the source of a transaction, or its recipient for outgoing transactions. Currently, it can be one of // - TransactionPartnerUser +// - TransactionPartnerChat +// - TransactionPartnerAffiliateProgram // - TransactionPartnerFragment // - TransactionPartnerTelegramAds // - TransactionPartnerTelegramApi @@ -8511,6 +9469,8 @@ type TransactionPartner interface { // Ensure that all subtypes correctly implement the parent interface. var ( _ TransactionPartner = TransactionPartnerUser{} + _ TransactionPartner = TransactionPartnerChat{} + _ TransactionPartner = TransactionPartnerAffiliateProgram{} _ TransactionPartner = TransactionPartnerFragment{} _ TransactionPartner = TransactionPartnerTelegramAds{} _ TransactionPartner = TransactionPartnerTelegramApi{} @@ -8521,14 +9481,30 @@ var ( type MergedTransactionPartner struct { // Type of the transaction partner Type string `json:"type"` + // Optional. Type of the transaction, currently one of "invoice_payment" for payments via invoices, "paid_media_payment" for payments for paid media, "gift_purchase" for gifts sent by the bot, "premium_purchase" for Telegram Premium subscriptions gifted by the bot, "business_account_transfer" for direct transfers from managed business accounts (Only for user) + TransactionType string `json:"transaction_type,omitempty"` // Optional. Information about the user (Only for user) User *User `json:"user,omitempty"` - // Optional. Bot-specified invoice payload (Only for user) + // Optional. Information about the affiliate that received a commission via this transaction. Can be available only for "invoice_payment" and "paid_media_payment" transactions. (Only for user) + Affiliate *AffiliateInfo `json:"affiliate,omitempty"` + // Optional. Bot-specified invoice payload. Can be available only for "invoice_payment" transactions. (Only for user) InvoicePayload string `json:"invoice_payload,omitempty"` - // Optional. Information about the paid media bought by the user (Only for user) + // Optional. The duration of the paid subscription. Can be available only for "invoice_payment" transactions. (Only for user) + SubscriptionPeriod int64 `json:"subscription_period,omitempty"` + // Optional. Information about the paid media bought by the user; for "paid_media_payment" transactions only (Only for user) PaidMedia []PaidMedia `json:"paid_media,omitempty"` - // Optional. Bot-specified paid media payload (Only for user) + // Optional. Bot-specified paid media payload. Can be available only for "paid_media_payment" transactions. (Only for user) PaidMediaPayload string `json:"paid_media_payload,omitempty"` + // Optional. The gift sent to the user by the bot; for "gift_purchase" transactions only (Only for user, chat) + Gift *Gift `json:"gift,omitempty"` + // Optional. Number of months the gifted Telegram Premium subscription will be active for; for "premium_purchase" transactions only (Only for user) + PremiumSubscriptionDuration int64 `json:"premium_subscription_duration,omitempty"` + // Optional. Information about the chat (Only for chat) + Chat *Chat `json:"chat,omitempty"` + // Optional. Information about the bot that sponsored the affiliate program (Only for affiliate_program) + SponsorUser *User `json:"sponsor_user,omitempty"` + // Optional. The number of Telegram Stars received by the bot for each 1000 Telegram Stars received by the affiliate program sponsor from referred users (Only for affiliate_program) + CommissionPerMille int64 `json:"commission_per_mille,omitempty"` // Optional. State of the transaction if the transaction is outgoing (Only for fragment) WithdrawalState RevenueWithdrawalState `json:"withdrawal_state,omitempty"` // Optional. The number of successful requests that exceeded regular limits and were therefore billed (Only for telegram_api) @@ -8597,6 +9573,22 @@ func unmarshalTransactionPartner(d json.RawMessage) (TransactionPartner, error) } return s, nil + case "chat": + s := TransactionPartnerChat{} + err := json.Unmarshal(d, &s) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal TransactionPartner for value 'chat': %w", err) + } + return s, nil + + case "affiliate_program": + s := TransactionPartnerAffiliateProgram{} + err := json.Unmarshal(d, &s) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal TransactionPartner for value 'affiliate_program': %w", err) + } + return s, nil + case "fragment": s := TransactionPartnerFragment{} err := json.Unmarshal(d, &s) @@ -8633,6 +9625,86 @@ func unmarshalTransactionPartner(d json.RawMessage) (TransactionPartner, error) return nil, fmt.Errorf("unknown interface for TransactionPartner with Type %v", t.Type) } +// TransactionPartnerAffiliateProgram (https://core.telegram.org/bots/api#transactionpartneraffiliateprogram) +// +// Describes the affiliate program that issued the affiliate commission received via this transaction. +type TransactionPartnerAffiliateProgram struct { + // Optional. Information about the bot that sponsored the affiliate program + SponsorUser *User `json:"sponsor_user,omitempty"` + // The number of Telegram Stars received by the bot for each 1000 Telegram Stars received by the affiliate program sponsor from referred users + CommissionPerMille int64 `json:"commission_per_mille"` +} + +// GetType is a helper method to easily access the common fields of an interface. +func (v TransactionPartnerAffiliateProgram) GetType() string { + return "affiliate_program" +} + +// MergeTransactionPartner returns a MergedTransactionPartner struct to simplify working with types in a non-generic world. +func (v TransactionPartnerAffiliateProgram) MergeTransactionPartner() MergedTransactionPartner { + return MergedTransactionPartner{ + Type: "affiliate_program", + SponsorUser: v.SponsorUser, + CommissionPerMille: v.CommissionPerMille, + } +} + +// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value. +func (v TransactionPartnerAffiliateProgram) MarshalJSON() ([]byte, error) { + type alias TransactionPartnerAffiliateProgram + a := struct { + Type string `json:"type"` + alias + }{ + Type: "affiliate_program", + alias: (alias)(v), + } + return json.Marshal(a) +} + +// TransactionPartnerAffiliateProgram.transactionPartner is a dummy method to avoid interface implementation. +func (v TransactionPartnerAffiliateProgram) transactionPartner() {} + +// TransactionPartnerChat (https://core.telegram.org/bots/api#transactionpartnerchat) +// +// Describes a transaction with a chat. +type TransactionPartnerChat struct { + // Information about the chat + Chat Chat `json:"chat"` + // Optional. The gift sent to the chat by the bot + Gift *Gift `json:"gift,omitempty"` +} + +// GetType is a helper method to easily access the common fields of an interface. +func (v TransactionPartnerChat) GetType() string { + return "chat" +} + +// MergeTransactionPartner returns a MergedTransactionPartner struct to simplify working with types in a non-generic world. +func (v TransactionPartnerChat) MergeTransactionPartner() MergedTransactionPartner { + return MergedTransactionPartner{ + Type: "chat", + Chat: &v.Chat, + Gift: v.Gift, + } +} + +// MarshalJSON is a custom JSON marshaller to allow for enforcing the Type value. +func (v TransactionPartnerChat) MarshalJSON() ([]byte, error) { + type alias TransactionPartnerChat + a := struct { + Type string `json:"type"` + alias + }{ + Type: "chat", + alias: (alias)(v), + } + return json.Marshal(a) +} + +// TransactionPartnerChat.transactionPartner is a dummy method to avoid interface implementation. +func (v TransactionPartnerChat) transactionPartner() {} + // TransactionPartnerFragment (https://core.telegram.org/bots/api#transactionpartnerfragment) // // Describes a withdrawal transaction with Fragment. @@ -8797,24 +9869,39 @@ func (v TransactionPartnerTelegramApi) transactionPartner() {} // // Describes a transaction with a user. type TransactionPartnerUser struct { + // Type of the transaction, currently one of "invoice_payment" for payments via invoices, "paid_media_payment" for payments for paid media, "gift_purchase" for gifts sent by the bot, "premium_purchase" for Telegram Premium subscriptions gifted by the bot, "business_account_transfer" for direct transfers from managed business accounts + TransactionType string `json:"transaction_type"` // Information about the user User User `json:"user"` - // Optional. Bot-specified invoice payload + // Optional. Information about the affiliate that received a commission via this transaction. Can be available only for "invoice_payment" and "paid_media_payment" transactions. + Affiliate *AffiliateInfo `json:"affiliate,omitempty"` + // Optional. Bot-specified invoice payload. Can be available only for "invoice_payment" transactions. InvoicePayload string `json:"invoice_payload,omitempty"` - // Optional. Information about the paid media bought by the user + // Optional. The duration of the paid subscription. Can be available only for "invoice_payment" transactions. + SubscriptionPeriod int64 `json:"subscription_period,omitempty"` + // Optional. Information about the paid media bought by the user; for "paid_media_payment" transactions only PaidMedia []PaidMedia `json:"paid_media,omitempty"` - // Optional. Bot-specified paid media payload + // Optional. Bot-specified paid media payload. Can be available only for "paid_media_payment" transactions. PaidMediaPayload string `json:"paid_media_payload,omitempty"` + // Optional. The gift sent to the user by the bot; for "gift_purchase" transactions only + Gift *Gift `json:"gift,omitempty"` + // Optional. Number of months the gifted Telegram Premium subscription will be active for; for "premium_purchase" transactions only + PremiumSubscriptionDuration int64 `json:"premium_subscription_duration,omitempty"` } // UnmarshalJSON is a custom JSON unmarshaller to use the helpers which allow for unmarshalling structs into interfaces. func (v *TransactionPartnerUser) UnmarshalJSON(b []byte) error { // All fields in TransactionPartnerUser, with interface fields as json.RawMessage type tmp struct { - User User `json:"user"` - InvoicePayload string `json:"invoice_payload"` - PaidMedia json.RawMessage `json:"paid_media"` - PaidMediaPayload string `json:"paid_media_payload"` + TransactionType string `json:"transaction_type"` + User User `json:"user"` + Affiliate *AffiliateInfo `json:"affiliate"` + InvoicePayload string `json:"invoice_payload"` + SubscriptionPeriod int64 `json:"subscription_period"` + PaidMedia json.RawMessage `json:"paid_media"` + PaidMediaPayload string `json:"paid_media_payload"` + Gift *Gift `json:"gift"` + PremiumSubscriptionDuration int64 `json:"premium_subscription_duration"` } t := tmp{} err := json.Unmarshal(b, &t) @@ -8822,13 +9909,18 @@ func (v *TransactionPartnerUser) UnmarshalJSON(b []byte) error { return fmt.Errorf("failed to unmarshal TransactionPartnerUser JSON into tmp struct: %w", err) } + v.TransactionType = t.TransactionType v.User = t.User + v.Affiliate = t.Affiliate v.InvoicePayload = t.InvoicePayload + v.SubscriptionPeriod = t.SubscriptionPeriod v.PaidMedia, err = unmarshalPaidMediaArray(t.PaidMedia) if err != nil { return fmt.Errorf("failed to unmarshal custom JSON field PaidMedia: %w", err) } v.PaidMediaPayload = t.PaidMediaPayload + v.Gift = t.Gift + v.PremiumSubscriptionDuration = t.PremiumSubscriptionDuration return nil } @@ -8841,11 +9933,16 @@ func (v TransactionPartnerUser) GetType() string { // MergeTransactionPartner returns a MergedTransactionPartner struct to simplify working with types in a non-generic world. func (v TransactionPartnerUser) MergeTransactionPartner() MergedTransactionPartner { return MergedTransactionPartner{ - Type: "user", - User: &v.User, - InvoicePayload: v.InvoicePayload, - PaidMedia: v.PaidMedia, - PaidMediaPayload: v.PaidMediaPayload, + Type: "user", + TransactionType: v.TransactionType, + User: &v.User, + Affiliate: v.Affiliate, + InvoicePayload: v.InvoicePayload, + SubscriptionPeriod: v.SubscriptionPeriod, + PaidMedia: v.PaidMedia, + PaidMediaPayload: v.PaidMediaPayload, + Gift: v.Gift, + PremiumSubscriptionDuration: v.PremiumSubscriptionDuration, } } @@ -8865,6 +9962,88 @@ func (v TransactionPartnerUser) MarshalJSON() ([]byte, error) { // TransactionPartnerUser.transactionPartner is a dummy method to avoid interface implementation. func (v TransactionPartnerUser) transactionPartner() {} +// UniqueGift (https://core.telegram.org/bots/api#uniquegift) +// +// This object describes a unique gift that was upgraded from a regular gift. +type UniqueGift struct { + // Human-readable name of the regular gift from which this unique gift was upgraded + BaseName string `json:"base_name"` + // Unique name of the gift. This name can be used in https://t.me/nft/... links and story areas + Name string `json:"name"` + // Unique number of the upgraded gift among gifts upgraded from the same regular gift + Number int64 `json:"number"` + // Model of the gift + Model UniqueGiftModel `json:"model"` + // Symbol of the gift + Symbol UniqueGiftSymbol `json:"symbol"` + // Backdrop of the gift + Backdrop UniqueGiftBackdrop `json:"backdrop"` +} + +// UniqueGiftBackdrop (https://core.telegram.org/bots/api#uniquegiftbackdrop) +// +// This object describes the backdrop of a unique gift. +type UniqueGiftBackdrop struct { + // Name of the backdrop + Name string `json:"name"` + // Colors of the backdrop + Colors UniqueGiftBackdropColors `json:"colors"` + // The number of unique gifts that receive this backdrop for every 1000 gifts upgraded + RarityPerMille int64 `json:"rarity_per_mille"` +} + +// UniqueGiftBackdropColors (https://core.telegram.org/bots/api#uniquegiftbackdropcolors) +// +// This object describes the colors of the backdrop of a unique gift. +type UniqueGiftBackdropColors struct { + // The color in the center of the backdrop in RGB format + CenterColor int64 `json:"center_color"` + // The color on the edges of the backdrop in RGB format + EdgeColor int64 `json:"edge_color"` + // The color to be applied to the symbol in RGB format + SymbolColor int64 `json:"symbol_color"` + // The color for the text on the backdrop in RGB format + TextColor int64 `json:"text_color"` +} + +// UniqueGiftInfo (https://core.telegram.org/bots/api#uniquegiftinfo) +// +// Describes a service message about a unique gift that was sent or received. +type UniqueGiftInfo struct { + // Information about the gift + Gift UniqueGift `json:"gift"` + // Origin of the gift. Currently, either "upgrade" or "transfer" + Origin string `json:"origin"` + // Optional. Unique identifier of the received gift for the bot; only present for gifts received on behalf of business accounts + OwnedGiftId string `json:"owned_gift_id,omitempty"` + // Optional. Number of Telegram Stars that must be paid to transfer the gift; omitted if the bot cannot transfer the gift + TransferStarCount int64 `json:"transfer_star_count,omitempty"` +} + +// UniqueGiftModel (https://core.telegram.org/bots/api#uniquegiftmodel) +// +// This object describes the model of a unique gift. +type UniqueGiftModel struct { + // Name of the model + Name string `json:"name"` + // The sticker that represents the unique gift + Sticker Sticker `json:"sticker"` + // The number of unique gifts that receive this model for every 1000 gifts upgraded + RarityPerMille int64 `json:"rarity_per_mille"` +} + +// UniqueGiftSymbol (https://core.telegram.org/bots/api#uniquegiftsymbol) +// +// This object describes the symbol shown on the pattern of a unique gift. +type UniqueGiftSymbol struct { + // Name of the symbol + Name string `json:"name"` + // The sticker that represents the unique gift + Sticker Sticker `json:"sticker"` + // The number of unique gifts that receive this model for every 1000 gifts upgraded + RarityPerMille int64 `json:"rarity_per_mille"` +} + // Update (https://core.telegram.org/bots/api#update) // // This object represents an incoming update. @@ -9016,6 +10195,10 @@ type Video struct { Duration int64 `json:"duration"` // Optional. Video thumbnail Thumbnail *PhotoSize `json:"thumbnail,omitempty"` + // Optional. Available sizes of the cover of the video in the message + Cover []PhotoSize `json:"cover,omitempty"` + // Optional. Timestamp in seconds from which the video will play in the message + StartTimestamp int64 `json:"start_timestamp,omitempty"` // Optional. Original filename as defined by the sender FileName string `json:"file_name,omitempty"` // Optional. MIME type of the file as defined by the sender diff --git a/vendor/github.com/PaulSonOfLars/gotgbot/v2/spec_commit b/vendor/github.com/PaulSonOfLars/gotgbot/v2/spec_commit index b6ac4261..eacd0dac 100644 --- a/vendor/github.com/PaulSonOfLars/gotgbot/v2/spec_commit +++ b/vendor/github.com/PaulSonOfLars/gotgbot/v2/spec_commit @@ -1 +1 @@ -15b6cd15658668b7017f3c069e27405ca4f4428e \ No newline at end of file +2b29b473568cc837e56d95160b3f8409e1318537 \ No newline at end of file diff --git a/vendor/modules.txt b/vendor/modules.txt index 3c38ecb2..2c89da92 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -25,8 +25,8 @@ github.com/Microsoft/go-winio/internal/fs github.com/Microsoft/go-winio/internal/socket github.com/Microsoft/go-winio/internal/stringbuffer github.com/Microsoft/go-winio/pkg/guid -# github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.30 -## explicit; go 1.19 +# github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.32 +## explicit; go 1.22 github.com/PaulSonOfLars/gotgbot/v2 # github.com/PuerkitoBio/goquery v1.8.1 ## explicit; go 1.13