diff --git a/gen_helpers.go b/gen_helpers.go index 1d32b94..fa98493 100755 --- a/gen_helpers.go +++ b/gen_helpers.go @@ -78,6 +78,11 @@ func (c Chat) GetAdministrators(b *Bot, opts *GetChatAdministratorsOpts) ([]Chat return b.GetChatAdministrators(c.Id, opts) } +// GetGifts is a helper method for Bot.GetChatGifts. +func (c Chat) GetGifts(b *Bot, opts *GetChatGiftsOpts) (*OwnedGifts, error) { + return b.GetChatGifts(c.Id, opts) +} + // GetMember is a helper method for Bot.GetChatMember. func (c Chat) GetMember(b *Bot, userId int64, opts *GetChatMemberOpts) (ChatMember, error) { return b.GetChatMember(c.Id, userId, opts) @@ -757,6 +762,11 @@ func (u User) GetChatBoosts(b *Bot, chatId int64, opts *GetUserChatBoostsOpts) ( return b.GetUserChatBoosts(chatId, u.Id, opts) } +// GetGifts is a helper method for Bot.GetUserGifts. +func (u User) GetGifts(b *Bot, opts *GetUserGiftsOpts) (*OwnedGifts, error) { + return b.GetUserGifts(u.Id, opts) +} + // GetProfilePhotos is a helper method for Bot.GetUserProfilePhotos. func (u User) GetProfilePhotos(b *Bot, opts *GetUserProfilePhotosOpts) (*UserProfilePhotos, error) { return b.GetUserProfilePhotos(u.Id, opts) diff --git a/gen_methods.go b/gen_methods.go index a462381..6975796 100755 --- a/gen_methods.go +++ b/gen_methods.go @@ -563,7 +563,7 @@ func (bot *Bot) ConvertGiftToStarsWithContext(ctx context.Context, businessConne // 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 + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat DirectMessagesTopicId int64 @@ -583,6 +583,8 @@ type CopyMessageOpts struct { ProtectContent bool // Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance AllowPaidBroadcast bool + // Unique identifier of the message effect to be added to the message; only available when copying to private chats + MessageEffectId string // A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. SuggestedPostParameters *SuggestedPostParameters // Description of the message to reply to @@ -621,6 +623,7 @@ func (bot *Bot) CopyMessageWithContext(ctx context.Context, chatId int64, fromCh addIfValueNotZero(v, "disable_notification", opts.DisableNotification, opts.DisableNotification == false) addIfValueNotZero(v, "protect_content", opts.ProtectContent, opts.ProtectContent == false) addIfValueNotZero(v, "allow_paid_broadcast", opts.AllowPaidBroadcast, opts.AllowPaidBroadcast == false) + addIfValueNotZero(v, "message_effect_id", opts.MessageEffectId, opts.MessageEffectId == "") addIfValueNotZero(v, "suggested_post_parameters", opts.SuggestedPostParameters, opts.SuggestedPostParameters == nil) addIfValueNotZero(v, "reply_parameters", opts.ReplyParameters, opts.ReplyParameters == nil) addIfValueNotZero(v, "reply_markup", opts.ReplyMarkup, opts.ReplyMarkup == nil) @@ -642,7 +645,7 @@ func (bot *Bot) CopyMessageWithContext(ctx context.Context, chatId int64, fromCh // CopyMessagesOpts is the set of optional fields for Bot.CopyMessages and Bot.CopyMessagesWithContext. type CopyMessagesOpts struct { - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the messages will be sent; required if the messages are sent to a direct messages chat DirectMessagesTopicId int64 @@ -1162,7 +1165,7 @@ type DeleteForumTopicOpts struct { // DeleteForumTopic (https://core.telegram.org/bots/api#deleteforumtopic) // -// Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns True on success. +// Use this method to delete a forum topic along with all its messages in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns True on success. // - chatId (type int64): Unique identifier for the target chat // - messageThreadId (type int64): Unique identifier for the target message thread of the forum topic // - opts (type DeleteForumTopicOpts): All optional parameters. @@ -1557,7 +1560,7 @@ type EditForumTopicOpts struct { // EditForumTopic (https://core.telegram.org/bots/api#editforumtopic) // -// Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. +// Use this method to edit name and icon of a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. // - chatId (type int64): Unique identifier for the target chat // - messageThreadId (type int64): Unique identifier for the target message thread of the forum topic // - opts (type EditForumTopicOpts): All optional parameters. @@ -2122,7 +2125,7 @@ func (bot *Bot) ExportChatInviteLinkWithContext(ctx context.Context, chatId int6 // ForwardMessageOpts is the set of optional fields for Bot.ForwardMessage and Bot.ForwardMessageWithContext. type ForwardMessageOpts struct { - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be forwarded; required if the message is forwarded to a direct messages chat DirectMessagesTopicId int64 @@ -2132,6 +2135,8 @@ type ForwardMessageOpts struct { DisableNotification bool // Protects the contents of the forwarded message from forwarding and saving ProtectContent bool + // Unique identifier of the message effect to be added to the message; only available when forwarding to private chats + MessageEffectId string // A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only SuggestedPostParameters *SuggestedPostParameters // RequestOpts are an additional optional field to configure timeouts for individual requests @@ -2161,6 +2166,7 @@ func (bot *Bot) ForwardMessageWithContext(ctx context.Context, chatId int64, fro addIfValueNotZero(v, "video_start_timestamp", opts.VideoStartTimestamp, opts.VideoStartTimestamp == 0) addIfValueNotZero(v, "disable_notification", opts.DisableNotification, opts.DisableNotification == false) addIfValueNotZero(v, "protect_content", opts.ProtectContent, opts.ProtectContent == false) + addIfValueNotZero(v, "message_effect_id", opts.MessageEffectId, opts.MessageEffectId == "") addIfValueNotZero(v, "suggested_post_parameters", opts.SuggestedPostParameters, opts.SuggestedPostParameters == nil) } @@ -2180,7 +2186,7 @@ func (bot *Bot) ForwardMessageWithContext(ctx context.Context, chatId int64, fro // ForwardMessagesOpts is the set of optional fields for Bot.ForwardMessages and Bot.ForwardMessagesWithContext. type ForwardMessagesOpts struct { - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the messages will be forwarded; required if the messages are forwarded to a direct messages chat DirectMessagesTopicId int64 @@ -2270,10 +2276,14 @@ type GetBusinessAccountGiftsOpts struct { 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 gifts that can be purchased a limited number of times and can be upgraded to unique + ExcludeLimitedUpgradable bool + // Pass True to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique + ExcludeLimitedNonUpgradable bool // Pass True to exclude unique gifts ExcludeUnique bool + // Pass True to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram + ExcludeFromBlockchain 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 @@ -2301,8 +2311,10 @@ func (bot *Bot) GetBusinessAccountGiftsWithContext(ctx context.Context, business addIfValueNotZero(v, "exclude_unsaved", opts.ExcludeUnsaved, opts.ExcludeUnsaved == false) addIfValueNotZero(v, "exclude_saved", opts.ExcludeSaved, opts.ExcludeSaved == false) addIfValueNotZero(v, "exclude_unlimited", opts.ExcludeUnlimited, opts.ExcludeUnlimited == false) - addIfValueNotZero(v, "exclude_limited", opts.ExcludeLimited, opts.ExcludeLimited == false) + addIfValueNotZero(v, "exclude_limited_upgradable", opts.ExcludeLimitedUpgradable, opts.ExcludeLimitedUpgradable == false) + addIfValueNotZero(v, "exclude_limited_non_upgradable", opts.ExcludeLimitedNonUpgradable, opts.ExcludeLimitedNonUpgradable == false) addIfValueNotZero(v, "exclude_unique", opts.ExcludeUnique, opts.ExcludeUnique == false) + addIfValueNotZero(v, "exclude_from_blockchain", opts.ExcludeFromBlockchain, opts.ExcludeFromBlockchain == false) addIfValueNotZero(v, "sort_by_price", opts.SortByPrice, opts.SortByPrice == false) addIfValueNotZero(v, "offset", opts.Offset, opts.Offset == "") addIfValueNotZero(v, "limit", opts.Limit, opts.Limit == 0) @@ -2457,6 +2469,72 @@ func (bot *Bot) GetChatAdministratorsWithContext(ctx context.Context, chatId int return unmarshalChatMemberArray(r) } +// GetChatGiftsOpts is the set of optional fields for Bot.GetChatGifts and Bot.GetChatGiftsWithContext. +type GetChatGiftsOpts struct { + // Pass True to exclude gifts that aren't saved to the chat's profile page. Always True, unless the bot has the can_post_messages administrator right in the channel. + ExcludeUnsaved bool + // Pass True to exclude gifts that are saved to the chat's profile page. Always False, unless the bot has the can_post_messages administrator right in the channel. + 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 and can be upgraded to unique + ExcludeLimitedUpgradable bool + // Pass True to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique + ExcludeLimitedNonUpgradable bool + // Pass True to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram + ExcludeFromBlockchain 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 an 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 +} + +// GetChatGifts (https://core.telegram.org/bots/api#getchatgifts) +// +// Returns the gifts owned by a chat. Returns OwnedGifts on success. +// - chatId (type int64): Unique identifier for the target chat +// - opts (type GetChatGiftsOpts): All optional parameters. +func (bot *Bot) GetChatGifts(chatId int64, opts *GetChatGiftsOpts) (*OwnedGifts, error) { + return bot.GetChatGiftsWithContext(context.Background(), chatId, opts) +} + +// GetChatGiftsWithContext is the same as Bot.GetChatGifts, but with a context.Context parameter +func (bot *Bot) GetChatGiftsWithContext(ctx context.Context, chatId int64, opts *GetChatGiftsOpts) (*OwnedGifts, error) { + v := map[string]any{} + v["chat_id"] = chatId + if opts != nil { + addIfValueNotZero(v, "exclude_unsaved", opts.ExcludeUnsaved, opts.ExcludeUnsaved == false) + addIfValueNotZero(v, "exclude_saved", opts.ExcludeSaved, opts.ExcludeSaved == false) + addIfValueNotZero(v, "exclude_unlimited", opts.ExcludeUnlimited, opts.ExcludeUnlimited == false) + addIfValueNotZero(v, "exclude_limited_upgradable", opts.ExcludeLimitedUpgradable, opts.ExcludeLimitedUpgradable == false) + addIfValueNotZero(v, "exclude_limited_non_upgradable", opts.ExcludeLimitedNonUpgradable, opts.ExcludeLimitedNonUpgradable == false) + addIfValueNotZero(v, "exclude_from_blockchain", opts.ExcludeFromBlockchain, opts.ExcludeFromBlockchain == false) + addIfValueNotZero(v, "exclude_unique", opts.ExcludeUnique, opts.ExcludeUnique == false) + addIfValueNotZero(v, "sort_by_price", opts.SortByPrice, opts.SortByPrice == false) + addIfValueNotZero(v, "offset", opts.Offset, opts.Offset == "") + addIfValueNotZero(v, "limit", opts.Limit, opts.Limit == 0) + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "getChatGifts", v, reqOpts) + if err != nil { + return nil, err + } + + var o OwnedGifts + return &o, json.Unmarshal(r, &o) +} + // GetChatMemberOpts is the set of optional fields for Bot.GetChatMember and Bot.GetChatMemberWithContext. type GetChatMemberOpts struct { // RequestOpts are an additional optional field to configure timeouts for individual requests @@ -3116,6 +3194,66 @@ func (bot *Bot) GetUserChatBoostsWithContext(ctx context.Context, chatId int64, return &u, json.Unmarshal(r, &u) } +// GetUserGiftsOpts is the set of optional fields for Bot.GetUserGifts and Bot.GetUserGiftsWithContext. +type GetUserGiftsOpts struct { + // 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 and can be upgraded to unique + ExcludeLimitedUpgradable bool + // Pass True to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique + ExcludeLimitedNonUpgradable bool + // Pass True to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram + ExcludeFromBlockchain 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 an 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 +} + +// GetUserGifts (https://core.telegram.org/bots/api#getusergifts) +// +// Returns the gifts owned and hosted by a user. Returns OwnedGifts on success. +// - userId (type int64): Unique identifier of the user +// - opts (type GetUserGiftsOpts): All optional parameters. +func (bot *Bot) GetUserGifts(userId int64, opts *GetUserGiftsOpts) (*OwnedGifts, error) { + return bot.GetUserGiftsWithContext(context.Background(), userId, opts) +} + +// GetUserGiftsWithContext is the same as Bot.GetUserGifts, but with a context.Context parameter +func (bot *Bot) GetUserGiftsWithContext(ctx context.Context, userId int64, opts *GetUserGiftsOpts) (*OwnedGifts, error) { + v := map[string]any{} + v["user_id"] = userId + if opts != nil { + addIfValueNotZero(v, "exclude_unlimited", opts.ExcludeUnlimited, opts.ExcludeUnlimited == false) + addIfValueNotZero(v, "exclude_limited_upgradable", opts.ExcludeLimitedUpgradable, opts.ExcludeLimitedUpgradable == false) + addIfValueNotZero(v, "exclude_limited_non_upgradable", opts.ExcludeLimitedNonUpgradable, opts.ExcludeLimitedNonUpgradable == false) + addIfValueNotZero(v, "exclude_from_blockchain", opts.ExcludeFromBlockchain, opts.ExcludeFromBlockchain == false) + addIfValueNotZero(v, "exclude_unique", opts.ExcludeUnique, opts.ExcludeUnique == false) + addIfValueNotZero(v, "sort_by_price", opts.SortByPrice, opts.SortByPrice == false) + addIfValueNotZero(v, "offset", opts.Offset, opts.Offset == "") + addIfValueNotZero(v, "limit", opts.Limit, opts.Limit == 0) + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "getUserGifts", v, reqOpts) + if err != nil { + return nil, err + } + + var o OwnedGifts + return &o, json.Unmarshal(r, &o) +} + // GetUserProfilePhotosOpts is the set of optional fields for Bot.GetUserProfilePhotos and Bot.GetUserProfilePhotosWithContext. type GetUserProfilePhotosOpts struct { // Sequential number of the first photo to be returned. By default, all photos are returned. @@ -3451,7 +3589,7 @@ type PromoteChatMemberOpts struct { CanDeleteMessages bool // Pass True if the administrator can manage video chats CanManageVideoChats bool - // Pass True if the administrator can restrict, ban or unban chat members, or access supergroup statistics + // Pass True if the administrator can restrict, ban or unban chat members, or access supergroup statistics. For backward compatibility, defaults to True for promotions of channel administrators CanRestrictMembers bool // Pass True if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by him) CanPromoteMembers bool @@ -3818,6 +3956,54 @@ func (bot *Bot) ReplaceStickerInSetWithContext(ctx context.Context, userId int64 return b, json.Unmarshal(r, &b) } +// RepostStoryOpts is the set of optional fields for Bot.RepostStory and Bot.RepostStoryWithContext. +type RepostStoryOpts struct { + // 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 +} + +// RepostStory (https://core.telegram.org/bots/api#repoststory) +// +// Reposts a story on behalf of a business account from another business account. Both business accounts must be managed by the same bot, and the story on the source account must have been posted (or reposted) by the bot. Requires the can_manage_stories business bot right for both business accounts. Returns Story on success. +// - businessConnectionId (type string): Unique identifier of the business connection +// - fromChatId (type int64): Unique identifier of the chat which posted the story that should be reposted +// - fromStoryId (type int64): Unique identifier of the story that should be reposted +// - 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 RepostStoryOpts): All optional parameters. +func (bot *Bot) RepostStory(businessConnectionId string, fromChatId int64, fromStoryId int64, activePeriod int64, opts *RepostStoryOpts) (*Story, error) { + return bot.RepostStoryWithContext(context.Background(), businessConnectionId, fromChatId, fromStoryId, activePeriod, opts) +} + +// RepostStoryWithContext is the same as Bot.RepostStory, but with a context.Context parameter +func (bot *Bot) RepostStoryWithContext(ctx context.Context, businessConnectionId string, fromChatId int64, fromStoryId int64, activePeriod int64, opts *RepostStoryOpts) (*Story, error) { + v := map[string]any{} + v["business_connection_id"] = businessConnectionId + v["from_chat_id"] = fromChatId + v["from_story_id"] = fromStoryId + v["active_period"] = activePeriod + if opts != nil { + addIfValueNotZero(v, "post_to_chat_page", opts.PostToChatPage, opts.PostToChatPage == false) + addIfValueNotZero(v, "protect_content", opts.ProtectContent, opts.ProtectContent == false) + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "repostStory", v, reqOpts) + if err != nil { + return nil, err + } + + var s Story + return &s, json.Unmarshal(r, &s) +} + // RestrictChatMemberOpts is the set of optional fields for Bot.RestrictChatMember and Bot.RestrictChatMemberWithContext. type RestrictChatMemberOpts struct { // Pass True if chat permissions are set independently. Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission. @@ -3954,7 +4140,7 @@ func (bot *Bot) SavePreparedInlineMessageWithContext(ctx context.Context, userId type SendAnimationOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat DirectMessagesTopicId int64 @@ -4049,7 +4235,7 @@ func (bot *Bot) SendAnimationWithContext(ctx context.Context, chatId int64, anim type SendAudioOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat DirectMessagesTopicId int64 @@ -4139,7 +4325,7 @@ func (bot *Bot) SendAudioWithContext(ctx context.Context, chatId int64, audio In type SendChatActionOpts struct { // Unique identifier of the business connection on behalf of which the action will be sent BusinessConnectionId string - // Unique identifier for the target message thread; for supergroups only + // Unique identifier for the target message thread or topic of a forum; for supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // RequestOpts are an additional optional field to configure timeouts for individual requests RequestOpts *RequestOpts @@ -4239,7 +4425,7 @@ func (bot *Bot) SendChecklistWithContext(ctx context.Context, businessConnection type SendContactOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat DirectMessagesTopicId int64 @@ -4315,7 +4501,7 @@ func (bot *Bot) SendContactWithContext(ctx context.Context, chatId int64, phoneN type SendDiceOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat DirectMessagesTopicId int64 @@ -4384,7 +4570,7 @@ func (bot *Bot) SendDiceWithContext(ctx context.Context, chatId int64, opts *Sen type SendDocumentOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat DirectMessagesTopicId int64 @@ -4467,7 +4653,7 @@ func (bot *Bot) SendDocumentWithContext(ctx context.Context, chatId int64, docum type SendGameOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Sends the message silently. Users will receive a notification with no sound. DisableNotification bool @@ -4546,7 +4732,7 @@ type SendGiftOpts struct { // 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 +// - giftId (type string): Identifier of the gift; limited gifts can't be sent to channel chats // - opts (type SendGiftOpts): All optional parameters. func (bot *Bot) SendGift(giftId string, opts *SendGiftOpts) (bool, error) { return bot.SendGiftWithContext(context.Background(), giftId, opts) @@ -4581,7 +4767,7 @@ func (bot *Bot) SendGiftWithContext(ctx context.Context, giftId string, opts *Se // 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 + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat DirectMessagesTopicId int64 @@ -4704,7 +4890,7 @@ func (bot *Bot) SendInvoiceWithContext(ctx context.Context, chatId int64, title type SendLocationOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat DirectMessagesTopicId int64 @@ -4786,7 +4972,7 @@ func (bot *Bot) SendLocationWithContext(ctx context.Context, chatId int64, latit type SendMediaGroupOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the messages will be sent; required if the messages are sent to a direct messages chat DirectMessagesTopicId int64 @@ -4848,7 +5034,7 @@ func (bot *Bot) SendMediaGroupWithContext(ctx context.Context, chatId int64, med type SendMessageOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat DirectMessagesTopicId int64 @@ -4921,11 +5107,60 @@ func (bot *Bot) SendMessageWithContext(ctx context.Context, chatId int64, text s return &m, json.Unmarshal(r, &m) } +// SendMessageDraftOpts is the set of optional fields for Bot.SendMessageDraft and Bot.SendMessageDraftWithContext. +type SendMessageDraftOpts struct { + // Unique identifier for the target message thread + MessageThreadId int64 + // Mode for parsing entities in the message text. See formatting options for more details. + ParseMode string + // A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode + Entities []MessageEntity + // RequestOpts are an additional optional field to configure timeouts for individual requests + RequestOpts *RequestOpts +} + +// SendMessageDraft (https://core.telegram.org/bots/api#sendmessagedraft) +// +// Use this method to stream a partial message to a user while the message is being generated; supported only for bots with forum topic mode enabled. Returns True on success. +// - chatId (type int64): Unique identifier for the target private chat +// - draftId (type int64): Unique identifier of the message draft; must be non-zero. Changes of drafts with the same identifier are animated +// - text (type string): Text of the message to be sent, 1-4096 characters after entities parsing +// - opts (type SendMessageDraftOpts): All optional parameters. +func (bot *Bot) SendMessageDraft(chatId int64, draftId int64, text string, opts *SendMessageDraftOpts) (bool, error) { + return bot.SendMessageDraftWithContext(context.Background(), chatId, draftId, text, opts) +} + +// SendMessageDraftWithContext is the same as Bot.SendMessageDraft, but with a context.Context parameter +func (bot *Bot) SendMessageDraftWithContext(ctx context.Context, chatId int64, draftId int64, text string, opts *SendMessageDraftOpts) (bool, error) { + v := map[string]any{} + v["chat_id"] = chatId + v["draft_id"] = draftId + v["text"] = text + if opts != nil { + addIfValueNotZero(v, "message_thread_id", opts.MessageThreadId, opts.MessageThreadId == 0) + addIfValueNotZero(v, "parse_mode", opts.ParseMode, opts.ParseMode == "") + addIfValueNotZero(v, "entities", opts.Entities, opts.Entities == nil) + } + + var reqOpts *RequestOpts + if opts != nil { + reqOpts = opts.RequestOpts + } + + r, err := bot.RequestWithContext(ctx, "sendMessageDraft", v, reqOpts) + if err != nil { + return false, err + } + + var b bool + return b, json.Unmarshal(r, &b) +} + // SendPaidMediaOpts is the set of optional fields for Bot.SendPaidMedia and Bot.SendPaidMediaWithContext. type SendPaidMediaOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat DirectMessagesTopicId int64 @@ -4959,7 +5194,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-10000 +// - starCount (type int64): The number of Telegram Stars that must be paid to buy access to the media; 1-25000 // - 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) { @@ -5007,7 +5242,7 @@ func (bot *Bot) SendPaidMediaWithContext(ctx context.Context, chatId int64, star type SendPhotoOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat DirectMessagesTopicId int64 @@ -5090,7 +5325,7 @@ func (bot *Bot) SendPhotoWithContext(ctx context.Context, chatId int64, photo In type SendPollOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Mode for parsing entities in the question. See formatting options for more details. Currently, only custom emoji entities are allowed QuestionParseMode string @@ -5193,7 +5428,7 @@ func (bot *Bot) SendPollWithContext(ctx context.Context, chatId int64, question type SendStickerOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat DirectMessagesTopicId int64 @@ -5264,7 +5499,7 @@ func (bot *Bot) SendStickerWithContext(ctx context.Context, chatId int64, sticke type SendVenueOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat DirectMessagesTopicId int64 @@ -5350,7 +5585,7 @@ func (bot *Bot) SendVenueWithContext(ctx context.Context, chatId int64, latitude type SendVideoOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat DirectMessagesTopicId int64 @@ -5454,7 +5689,7 @@ func (bot *Bot) SendVideoWithContext(ctx context.Context, chatId int64, video In type SendVideoNoteOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat DirectMessagesTopicId int64 @@ -5531,7 +5766,7 @@ func (bot *Bot) SendVideoNoteWithContext(ctx context.Context, chatId int64, vide type SendVoiceOpts struct { // Unique identifier of the business connection on behalf of which the message will be sent BusinessConnectionId string - // Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + // Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only MessageThreadId int64 // Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat DirectMessagesTopicId int64 @@ -7113,7 +7348,7 @@ type UnpinAllForumTopicMessagesOpts struct { // UnpinAllForumTopicMessages (https://core.telegram.org/bots/api#unpinallforumtopicmessages) // -// Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. +// Use this method to clear the list of pinned messages in a forum topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. // - chatId (type int64): Unique identifier for the target chat // - messageThreadId (type int64): Unique identifier for the target message thread of the forum topic // - opts (type UnpinAllForumTopicMessagesOpts): All optional parameters. diff --git a/gen_types.go b/gen_types.go index 4fa635f..8b00fd1 100755 --- a/gen_types.go +++ b/gen_types.go @@ -34,6 +34,8 @@ type AcceptedGiftTypes struct { UniqueGifts bool `json:"unique_gifts"` // True, if a Telegram Premium subscription is accepted PremiumSubscription bool `json:"premium_subscription"` + // True, if transfers of unique gifts from channels are accepted + GiftsFromChannels bool `json:"gifts_from_channels"` } // AffiliateInfo (https://core.telegram.org/bots/api#affiliateinfo) @@ -1721,6 +1723,12 @@ type ChatFullInfo struct { LinkedChatId int64 `json:"linked_chat_id,omitempty"` // Optional. For supergroups, the location to which the supergroup is connected Location *ChatLocation `json:"location,omitempty"` + // Optional. For private chats, the rating of the user if any + Rating *UserRating `json:"rating,omitempty"` + // Optional. The color scheme based on a unique gift that must be used for the chat's name, message replies and link previews + UniqueGiftColors *UniqueGiftColors `json:"unique_gift_colors,omitempty"` + // Optional. The number of Telegram Stars a general user have to pay to send a message to the chat + PaidMessageStarCount int64 `json:"paid_message_star_count,omitempty"` } // UnmarshalJSON is a custom JSON unmarshaller to use the helpers which allow for unmarshalling structs into interfaces. @@ -1774,6 +1782,9 @@ func (v *ChatFullInfo) UnmarshalJSON(b []byte) error { CustomEmojiStickerSetName string `json:"custom_emoji_sticker_set_name"` LinkedChatId int64 `json:"linked_chat_id"` Location *ChatLocation `json:"location"` + Rating *UserRating `json:"rating"` + UniqueGiftColors *UniqueGiftColors `json:"unique_gift_colors"` + PaidMessageStarCount int64 `json:"paid_message_star_count"` } t := tmp{} err := json.Unmarshal(b, &t) @@ -1831,6 +1842,9 @@ func (v *ChatFullInfo) UnmarshalJSON(b []byte) error { v.CustomEmojiStickerSetName = t.CustomEmojiStickerSetName v.LinkedChatId = t.LinkedChatId v.Location = t.Location + v.Rating = t.Rating + v.UniqueGiftColors = t.UniqueGiftColors + v.PaidMessageStarCount = t.PaidMessageStarCount return nil } @@ -2613,8 +2627,10 @@ type ChecklistTask struct { Text string `json:"text"` // Optional. Special entities that appear in the task text TextEntities []MessageEntity `json:"text_entities,omitempty"` - // Optional. User that completed the task; omitted if the task wasn't completed + // Optional. User that completed the task; omitted if the task wasn't completed by a user CompletedByUser *User `json:"completed_by_user,omitempty"` + // Optional. Chat that completed the task; omitted if the task wasn't completed by a chat + CompletedByChat *Chat `json:"completed_by_chat,omitempty"` // Optional. Point in time (Unix timestamp) when the task was completed; 0 if the task wasn't completed CompletionDate int64 `json:"completion_date,omitempty"` } @@ -2706,7 +2722,7 @@ type DirectMessagePriceChanged struct { // // Describes a topic of a direct messages chat. type DirectMessagesTopic struct { - // Unique identifier of the topic + // Unique identifier of the topic. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. TopicId int64 `json:"topic_id"` // Optional. Information about the user that created the topic. Currently, it is always present User *User `json:"user,omitempty"` @@ -2933,6 +2949,8 @@ type ForumTopic struct { IconColor int64 `json:"icon_color"` // Optional. Unique identifier of the custom emoji shown as the topic icon IconCustomEmojiId string `json:"icon_custom_emoji_id,omitempty"` + // Optional. True, if the name of the topic wasn't specified explicitly by its creator and likely needs to be changed by the bot + IsNameImplicit bool `json:"is_name_implicit,omitempty"` } // ForumTopicClosed (https://core.telegram.org/bots/api#forumtopicclosed) @@ -2950,6 +2968,8 @@ type ForumTopicCreated struct { IconColor int64 `json:"icon_color"` // Optional. Unique identifier of the custom emoji shown as the topic icon IconCustomEmojiId string `json:"icon_custom_emoji_id,omitempty"` + // Optional. True, if the name of the topic wasn't specified explicitly by its creator and likely needs to be changed by the bot + IsNameImplicit bool `json:"is_name_implicit,omitempty"` } // ForumTopicEdited (https://core.telegram.org/bots/api#forumtopicedited) @@ -3019,14 +3039,38 @@ type Gift struct { 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 + // Optional. True, if the gift can only be purchased by Telegram Premium subscribers + IsPremium bool `json:"is_premium,omitempty"` + // Optional. True, if the gift can be used (after being upgraded) to customize a user's appearance + HasColors bool `json:"has_colors,omitempty"` + // Optional. The total number of gifts of this type that can be sent by all users; 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 + // Optional. The number of remaining gifts of this type that can be sent by all users; for limited gifts only RemainingCount int64 `json:"remaining_count,omitempty"` + // Optional. The total number of gifts of this type that can be sent by the bot; for limited gifts only + PersonalTotalCount int64 `json:"personal_total_count,omitempty"` + // Optional. The number of remaining gifts of this type that can be sent by the bot; for limited gifts only + PersonalRemainingCount int64 `json:"personal_remaining_count,omitempty"` + // Optional. Background of the gift + Background *GiftBackground `json:"background,omitempty"` + // Optional. The total number of different unique gifts that can be obtained by upgrading the gift + UniqueGiftVariantCount int64 `json:"unique_gift_variant_count,omitempty"` // Optional. Information about the chat that published the gift PublisherChat *Chat `json:"publisher_chat,omitempty"` } +// GiftBackground (https://core.telegram.org/bots/api#giftbackground) +// +// This object describes the background of a gift. +type GiftBackground struct { + // Center color of the background in RGB format + CenterColor int64 `json:"center_color"` + // Edge color of the background in RGB format + EdgeColor int64 `json:"edge_color"` + // Text color of the background in RGB format + TextColor int64 `json:"text_color"` +} + // GiftInfo (https://core.telegram.org/bots/api#giftinfo) // // Describes a service message about a regular gift that was sent or received. @@ -3037,8 +3081,10 @@ type GiftInfo struct { 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 + // Optional. Number of Telegram Stars that were prepaid for the ability to upgrade the gift PrepaidUpgradeStarCount int64 `json:"prepaid_upgrade_star_count,omitempty"` + // Optional. True, if the gift's upgrade was purchased after the gift was sent + IsUpgradeSeparate bool `json:"is_upgrade_separate,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 @@ -3047,6 +3093,8 @@ type GiftInfo struct { 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. Unique number reserved for this gift when upgraded. See the number field in UniqueGift + UniqueGiftNumber int64 `json:"unique_gift_number,omitempty"` } // Gifts (https://core.telegram.org/bots/api#gifts) @@ -6443,7 +6491,7 @@ func (v MenuButtonWebApp) menuButton() {} type Message struct { // Unique message identifier inside this chat. In specific instances (e.g., message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent MessageId int64 `json:"message_id"` - // Optional. Unique identifier of a message thread to which the message belongs; for supergroups only + // Optional. Unique identifier of a message thread or forum topic to which the message belongs; for supergroups and private chats only MessageThreadId int64 `json:"message_thread_id,omitempty"` // Optional. Information about the direct messages chat topic that contains the message DirectMessagesTopic *DirectMessagesTopic `json:"direct_messages_topic,omitempty"` @@ -6463,7 +6511,7 @@ type Message struct { Chat Chat `json:"chat"` // Optional. Information about the original message for forwarded messages ForwardOrigin MessageOrigin `json:"forward_origin,omitempty"` - // Optional. True, if the message is sent to a forum topic + // Optional. True, if the message is sent to a topic in a forum supergroup or a private chat with the bot IsTopicMessage bool `json:"is_topic_message,omitempty"` // Optional. True, if the message is a channel post that was automatically forwarded to the connected discussion group IsAutomaticForward bool `json:"is_automatic_forward,omitempty"` @@ -6583,6 +6631,8 @@ type Message struct { Gift *GiftInfo `json:"gift,omitempty"` // Optional. Service message: a unique gift was sent or received UniqueGift *UniqueGiftInfo `json:"unique_gift,omitempty"` + // Optional. Service message: upgrade of a gift was purchased after the gift was sent + GiftUpgradeSent *GiftInfo `json:"gift_upgrade_sent,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 @@ -6722,6 +6772,7 @@ func (v *Message) UnmarshalJSON(b []byte) error { ChatShared *ChatShared `json:"chat_shared"` Gift *GiftInfo `json:"gift"` UniqueGift *UniqueGiftInfo `json:"unique_gift"` + GiftUpgradeSent *GiftInfo `json:"gift_upgrade_sent"` ConnectedWebsite string `json:"connected_website"` WriteAccessAllowed *WriteAccessAllowed `json:"write_access_allowed"` PassportData *PassportData `json:"passport_data"` @@ -6837,6 +6888,7 @@ func (v *Message) UnmarshalJSON(b []byte) error { v.ChatShared = t.ChatShared v.Gift = t.Gift v.UniqueGift = t.UniqueGift + v.GiftUpgradeSent = t.GiftUpgradeSent v.ConnectedWebsite = t.ConnectedWebsite v.WriteAccessAllowed = t.WriteAccessAllowed v.PassportData = t.PassportData @@ -7440,10 +7492,14 @@ type OwnedGiftRegular struct { 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 + // 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; for gifts received on behalf of business accounts only 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 + // Optional. Number of Telegram Stars that were paid for the ability to upgrade the gift PrepaidUpgradeStarCount int64 `json:"prepaid_upgrade_star_count,omitempty"` + // Optional. True, if the gift's upgrade was purchased after the gift was sent; for gifts received on behalf of business accounts only + IsUpgradeSeparate bool `json:"is_upgrade_separate,omitempty"` + // Optional. Unique number reserved for this gift when upgraded. See the number field in UniqueGift + UniqueGiftNumber int64 `json:"unique_gift_number,omitempty"` } // GetType is a helper method to easily access the common fields of an interface. @@ -9687,7 +9743,7 @@ type SuggestedPostParameters struct { // SuggestedPostPrice (https://core.telegram.org/bots/api#suggestedpostprice) // -// Desribes price of a suggested post. +// Describes the price of a suggested post. type SuggestedPostPrice struct { // Currency in which the post will be paid. Currently, must be one of "XTR" for Telegram Stars or "TON" for toncoins Currency string `json:"currency"` @@ -10253,6 +10309,8 @@ func (v TransactionPartnerUser) transactionPartner() {} // // This object describes a unique gift that was upgraded from a regular gift. type UniqueGift struct { + // Identifier of the regular gift from which the gift was upgraded + GiftId string `json:"gift_id"` // 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 @@ -10265,6 +10323,12 @@ type UniqueGift struct { Symbol UniqueGiftSymbol `json:"symbol"` // Backdrop of the gift Backdrop UniqueGiftBackdrop `json:"backdrop"` + // Optional. True, if the original regular gift was exclusively purchaseable by Telegram Premium subscribers + IsPremium bool `json:"is_premium,omitempty"` + // Optional. True, if the gift is assigned from the TON blockchain and can't be resold or transferred in Telegram + IsFromBlockchain bool `json:"is_from_blockchain,omitempty"` + // Optional. The color scheme that can be used by the gift's owner for the chat's name, replies to messages and link previews; for business account gifts and gifts that are currently on sale only + Colors *UniqueGiftColors `json:"colors,omitempty"` // Optional. Information about the chat that published the gift PublisherChat *Chat `json:"publisher_chat,omitempty"` } @@ -10295,16 +10359,36 @@ type UniqueGiftBackdropColors struct { TextColor int64 `json:"text_color"` } +// UniqueGiftColors (https://core.telegram.org/bots/api#uniquegiftcolors) +// +// This object contains information about the color scheme for a user's name, message replies and link previews based on a unique gift. +type UniqueGiftColors struct { + // Custom emoji identifier of the unique gift's model + ModelCustomEmojiId string `json:"model_custom_emoji_id"` + // Custom emoji identifier of the unique gift's symbol + SymbolCustomEmojiId string `json:"symbol_custom_emoji_id"` + // Main color used in light themes; RGB format + LightThemeMainColor int64 `json:"light_theme_main_color"` + // List of 1-3 additional colors used in light themes; RGB format + LightThemeOtherColors []int64 `json:"light_theme_other_colors,omitempty"` + // Main color used in dark themes; RGB format + DarkThemeMainColor int64 `json:"dark_theme_main_color"` + // List of 1-3 additional colors used in dark themes; RGB format + DarkThemeOtherColors []int64 `json:"dark_theme_other_colors,omitempty"` +} + // 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" for gifts upgraded from regular gifts, "transfer" for gifts transferred from other users or channels, or "resale" for gifts bought from other users + // Origin of the gift. Currently, either "upgrade" for gifts upgraded from regular gifts, "transfer" for gifts transferred from other users or channels, "resale" for gifts bought from other users, "gifted_upgrade" for upgrades purchased after the gift was sent, or "offer" for gifts bought or sold through gift purchase offers Origin string `json:"origin"` - // Optional. For gifts bought from other users, the price paid for the gift - LastResaleStarCount int64 `json:"last_resale_star_count,omitempty"` + // Optional. For gifts bought from other users, the currency in which the payment for the gift was done. Currently, one of "XTR" for Telegram Stars or "TON" for toncoins. + LastResaleCurrency string `json:"last_resale_currency,omitempty"` + // Optional. For gifts bought from other users, the price paid for the gift in either Telegram Stars or nanotoncoins + LastResaleAmount int64 `json:"last_resale_amount,omitempty"` // 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 @@ -10422,6 +10506,8 @@ type User struct { CanConnectToBusiness bool `json:"can_connect_to_business,omitempty"` // Optional. True, if the bot has a main Web App. Returned only in getMe. HasMainWebApp bool `json:"has_main_web_app,omitempty"` + // Optional. True, if the bot has forum topic mode enabled in private chats. Returned only in getMe. + HasTopicsEnabled bool `json:"has_topics_enabled,omitempty"` } // UserChatBoosts (https://core.telegram.org/bots/api#userchatboosts) @@ -10442,6 +10528,20 @@ type UserProfilePhotos struct { Photos [][]PhotoSize `json:"photos,omitempty"` } +// UserRating (https://core.telegram.org/bots/api#userrating) +// +// This object describes the rating of a user based on their Telegram Star spendings. +type UserRating struct { + // Current level of the user, indicating their reliability when purchasing digital goods and services. A higher level suggests a more trustworthy customer; a negative level is likely reason for concern. + Level int64 `json:"level"` + // Numerical value of the user's rating; the higher the rating, the better + Rating int64 `json:"rating"` + // The rating value required to get the current level + CurrentLevelRating int64 `json:"current_level_rating"` + // Optional. The rating value required to get to the next level; omitted if the maximum level was reached + NextLevelRating int64 `json:"next_level_rating,omitempty"` +} + // UsersShared (https://core.telegram.org/bots/api#usersshared) // // This object contains information about the users whose identifiers were shared with the bot using a KeyboardButtonRequestUsers button. diff --git a/scripts/generate/gen.go b/scripts/generate/gen.go index 4775b9a..73caf71 100644 --- a/scripts/generate/gen.go +++ b/scripts/generate/gen.go @@ -206,6 +206,12 @@ func (f Field) hasDefault() (string, bool) { return "", false } + if strings.Contains(strings.ToLower(f.Description), "backward compatibility") || + strings.Contains(strings.ToLower(f.Description), "backwards compatibility") { + // Backwards compatibility for "defaults" is a bad myth + return "", false + } + ms := defaultsMatcher.FindStringSubmatch(f.Description) if len(ms) == 0 { return "", true diff --git a/spec_commit b/spec_commit index 7444be2..c78d7c0 100644 --- a/spec_commit +++ b/spec_commit @@ -1 +1 @@ -9144676f4173de9bf806d52bc1b5433cb26a0dd4 \ No newline at end of file +2b2cc5e2fa33722c4874d16ef1a7381d648086f8 \ No newline at end of file