diff --git a/methods.go b/methods.go index a62eac6..c5fe1a0 100644 --- a/methods.go +++ b/methods.go @@ -59,7 +59,7 @@ type SetWebhookOpts struct { SecretToken string `json:"secret_token,omitempty"` } -// 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. func (b *Bot) SetWebhook(url string, opts *SetWebhookOpts) (bool, error) { params := map[string]string{} @@ -199,12 +199,15 @@ func (b *Bot) Close() (bool, error) { type SendMessageOpts struct { BusinessConnectionId string `json:"business_connection_id,omitempty"` MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` ParseMode string `json:"parse_mode,omitempty"` Entities []types.MessageEntity `json:"entities,omitempty"` LinkPreviewOptions *types.LinkPreviewOptions `json:"link_preview_options,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup types.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -219,6 +222,7 @@ func (b *Bot) SendMessage(chatId int64, text string, opts *SendMessageOpts) (*ty if opts != nil { params["business_connection_id"] = opts.BusinessConnectionId params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) params["parse_mode"] = opts.ParseMode if opts.Entities != nil { @@ -240,8 +244,18 @@ func (b *Bot) SendMessage(chatId int64, text string, opts *SendMessageOpts) (*ty params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + + if opts.ReplyParameters != nil { bs, err := json.Marshal(opts.ReplyParameters) if err != nil { @@ -276,8 +290,12 @@ func (b *Bot) SendMessage(chatId int64, text string, opts *SendMessageOpts) (*ty // ForwardMessage methods's optional params type ForwardMessageOpts struct { MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` + VideoStartTimestamp int64 `json:"video_start_timestamp,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + MessageEffectId string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` } // Use this method to forward messages of any kind. Service messages and messages with protected content can't be forwarded. On success, the sent Message is returned. @@ -290,8 +308,20 @@ func (b *Bot) ForwardMessage(chatId int64, fromChatId int64, messageId int64, op params["message_id"] = strconv.FormatInt(messageId, 10) if opts != nil { params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) + params["video_start_timestamp"] = strconv.FormatInt(opts.VideoStartTimestamp, 10) params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["message_effect_id"] = opts.MessageEffectId + + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + } @@ -309,6 +339,7 @@ func (b *Bot) ForwardMessage(chatId int64, fromChatId int64, messageId int64, op // ForwardMessages methods's optional params type ForwardMessagesOpts struct { MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` } @@ -331,6 +362,7 @@ func (b *Bot) ForwardMessages(chatId int64, fromChatId int64, messageIds []int64 if opts != nil { params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) } @@ -350,12 +382,17 @@ func (b *Bot) ForwardMessages(chatId int64, fromChatId int64, messageIds []int64 // CopyMessage methods's optional params type CopyMessageOpts struct { MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` + VideoStartTimestamp int64 `json:"video_start_timestamp,omitempty"` Caption string `json:"caption,omitempty"` ParseMode string `json:"parse_mode,omitempty"` CaptionEntities []types.MessageEntity `json:"caption_entities,omitempty"` ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` + MessageEffectId string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup types.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -370,6 +407,8 @@ func (b *Bot) CopyMessage(chatId int64, fromChatId int64, messageId int64, opts params["message_id"] = strconv.FormatInt(messageId, 10) if opts != nil { params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) + params["video_start_timestamp"] = strconv.FormatInt(opts.VideoStartTimestamp, 10) params["caption"] = opts.Caption params["parse_mode"] = opts.ParseMode @@ -384,6 +423,17 @@ func (b *Bot) CopyMessage(chatId int64, fromChatId int64, messageId int64, opts params["show_caption_above_media"] = strconv.FormatBool(opts.ShowCaptionAboveMedia) params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) + params["message_effect_id"] = opts.MessageEffectId + + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + if opts.ReplyParameters != nil { bs, err := json.Marshal(opts.ReplyParameters) @@ -419,6 +469,7 @@ func (b *Bot) CopyMessage(chatId int64, fromChatId int64, messageId int64, opts // CopyMessages methods's optional params type CopyMessagesOpts struct { MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` RemoveCaption bool `json:"remove_caption,omitempty"` @@ -442,6 +493,7 @@ func (b *Bot) CopyMessages(chatId int64, fromChatId int64, messageIds []int64, o if opts != nil { params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) params["remove_caption"] = strconv.FormatBool(opts.RemoveCaption) @@ -463,6 +515,7 @@ func (b *Bot) CopyMessages(chatId int64, fromChatId int64, messageIds []int64, o type SendPhotoOpts struct { BusinessConnectionId string `json:"business_connection_id,omitempty"` MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` Caption string `json:"caption,omitempty"` ParseMode string `json:"parse_mode,omitempty"` CaptionEntities []types.MessageEntity `json:"caption_entities,omitempty"` @@ -470,7 +523,9 @@ type SendPhotoOpts struct { HasSpoiler bool `json:"has_spoiler,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup types.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -499,6 +554,7 @@ func (b *Bot) SendPhoto(chatId int64, photo types.InputFile, opts *SendPhotoOpts if opts != nil { params["business_connection_id"] = opts.BusinessConnectionId params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) params["caption"] = opts.Caption params["parse_mode"] = opts.ParseMode @@ -514,8 +570,18 @@ func (b *Bot) SendPhoto(chatId int64, photo types.InputFile, opts *SendPhotoOpts params["has_spoiler"] = strconv.FormatBool(opts.HasSpoiler) params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + + if opts.ReplyParameters != nil { bs, err := json.Marshal(opts.ReplyParameters) if err != nil { @@ -551,6 +617,7 @@ func (b *Bot) SendPhoto(chatId int64, photo types.InputFile, opts *SendPhotoOpts type SendAudioOpts struct { BusinessConnectionId string `json:"business_connection_id,omitempty"` MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` Caption string `json:"caption,omitempty"` ParseMode string `json:"parse_mode,omitempty"` CaptionEntities []types.MessageEntity `json:"caption_entities,omitempty"` @@ -560,7 +627,9 @@ type SendAudioOpts struct { Thumbnail types.InputFile `json:"thumbnail,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup types.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -590,6 +659,7 @@ func (b *Bot) SendAudio(chatId int64, audio types.InputFile, opts *SendAudioOpts if opts != nil { params["business_connection_id"] = opts.BusinessConnectionId params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) params["caption"] = opts.Caption params["parse_mode"] = opts.ParseMode @@ -621,8 +691,18 @@ func (b *Bot) SendAudio(chatId int64, audio types.InputFile, opts *SendAudioOpts } params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + + if opts.ReplyParameters != nil { bs, err := json.Marshal(opts.ReplyParameters) if err != nil { @@ -658,6 +738,7 @@ func (b *Bot) SendAudio(chatId int64, audio types.InputFile, opts *SendAudioOpts type SendDocumentOpts struct { BusinessConnectionId string `json:"business_connection_id,omitempty"` MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` Thumbnail types.InputFile `json:"thumbnail,omitempty"` Caption string `json:"caption,omitempty"` ParseMode string `json:"parse_mode,omitempty"` @@ -665,7 +746,9 @@ type SendDocumentOpts struct { DisableContentTypeDetection bool `json:"disable_content_type_detection,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup types.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -694,6 +777,7 @@ func (b *Bot) SendDocument(chatId int64, document types.InputFile, opts *SendDoc if opts != nil { params["business_connection_id"] = opts.BusinessConnectionId params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) if opts.Thumbnail != nil { switch f := opts.Thumbnail.(type) { @@ -723,8 +807,18 @@ func (b *Bot) SendDocument(chatId int64, document types.InputFile, opts *SendDoc params["disable_content_type_detection"] = strconv.FormatBool(opts.DisableContentTypeDetection) params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + + if opts.ReplyParameters != nil { bs, err := json.Marshal(opts.ReplyParameters) if err != nil { @@ -760,10 +854,13 @@ func (b *Bot) SendDocument(chatId int64, document types.InputFile, opts *SendDoc type SendVideoOpts struct { BusinessConnectionId string `json:"business_connection_id,omitempty"` MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` Duration int64 `json:"duration,omitempty"` Width int64 `json:"width,omitempty"` Height int64 `json:"height,omitempty"` Thumbnail types.InputFile `json:"thumbnail,omitempty"` + Cover types.InputFile `json:"cover,omitempty"` + StartTimestamp int64 `json:"start_timestamp,omitempty"` Caption string `json:"caption,omitempty"` ParseMode string `json:"parse_mode,omitempty"` CaptionEntities []types.MessageEntity `json:"caption_entities,omitempty"` @@ -772,7 +869,9 @@ type SendVideoOpts struct { SupportsStreaming bool `json:"supports_streaming,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup types.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -801,6 +900,7 @@ func (b *Bot) SendVideo(chatId int64, video types.InputFile, opts *SendVideoOpts if opts != nil { params["business_connection_id"] = opts.BusinessConnectionId params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) params["duration"] = strconv.FormatInt(opts.Duration, 10) params["width"] = strconv.FormatInt(opts.Width, 10) params["height"] = strconv.FormatInt(opts.Height, 10) @@ -819,6 +919,22 @@ func (b *Bot) SendVideo(chatId int64, video types.InputFile, opts *SendVideoOpts return nil, fmt.Errorf("unknown type for InputFile: %T", opts.Thumbnail) } } + + if opts.Cover != nil { + switch f := opts.Cover.(type) { + case string: + _, err := os.Stat(f) + if err != nil { + params["cover"] = f + } else { + params["cover"] = "attach://cover" + data_params["cover"] = f + } + default: + return nil, fmt.Errorf("unknown type for InputFile: %T", opts.Cover) + } + } + params["start_timestamp"] = strconv.FormatInt(opts.StartTimestamp, 10) params["caption"] = opts.Caption params["parse_mode"] = opts.ParseMode @@ -835,8 +951,18 @@ func (b *Bot) SendVideo(chatId int64, video types.InputFile, opts *SendVideoOpts params["supports_streaming"] = strconv.FormatBool(opts.SupportsStreaming) params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + + if opts.ReplyParameters != nil { bs, err := json.Marshal(opts.ReplyParameters) if err != nil { @@ -872,6 +998,7 @@ func (b *Bot) SendVideo(chatId int64, video types.InputFile, opts *SendVideoOpts type SendAnimationOpts struct { BusinessConnectionId string `json:"business_connection_id,omitempty"` MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` Duration int64 `json:"duration,omitempty"` Width int64 `json:"width,omitempty"` Height int64 `json:"height,omitempty"` @@ -883,7 +1010,9 @@ type SendAnimationOpts struct { HasSpoiler bool `json:"has_spoiler,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup types.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -912,6 +1041,7 @@ func (b *Bot) SendAnimation(chatId int64, animation types.InputFile, opts *SendA if opts != nil { params["business_connection_id"] = opts.BusinessConnectionId params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) params["duration"] = strconv.FormatInt(opts.Duration, 10) params["width"] = strconv.FormatInt(opts.Width, 10) params["height"] = strconv.FormatInt(opts.Height, 10) @@ -945,8 +1075,18 @@ func (b *Bot) SendAnimation(chatId int64, animation types.InputFile, opts *SendA params["has_spoiler"] = strconv.FormatBool(opts.HasSpoiler) params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + + if opts.ReplyParameters != nil { bs, err := json.Marshal(opts.ReplyParameters) if err != nil { @@ -982,13 +1122,16 @@ func (b *Bot) SendAnimation(chatId int64, animation types.InputFile, opts *SendA type SendVoiceOpts struct { BusinessConnectionId string `json:"business_connection_id,omitempty"` MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` Caption string `json:"caption,omitempty"` ParseMode string `json:"parse_mode,omitempty"` CaptionEntities []types.MessageEntity `json:"caption_entities,omitempty"` Duration int64 `json:"duration,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup types.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -1017,6 +1160,7 @@ func (b *Bot) SendVoice(chatId int64, voice types.InputFile, opts *SendVoiceOpts if opts != nil { params["business_connection_id"] = opts.BusinessConnectionId params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) params["caption"] = opts.Caption params["parse_mode"] = opts.ParseMode @@ -1031,8 +1175,18 @@ func (b *Bot) SendVoice(chatId int64, voice types.InputFile, opts *SendVoiceOpts params["duration"] = strconv.FormatInt(opts.Duration, 10) params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + + if opts.ReplyParameters != nil { bs, err := json.Marshal(opts.ReplyParameters) if err != nil { @@ -1068,12 +1222,15 @@ func (b *Bot) SendVoice(chatId int64, voice types.InputFile, opts *SendVoiceOpts type SendVideoNoteOpts struct { BusinessConnectionId string `json:"business_connection_id,omitempty"` MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` Duration int64 `json:"duration,omitempty"` Length int64 `json:"length,omitempty"` Thumbnail types.InputFile `json:"thumbnail,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup types.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -1102,6 +1259,7 @@ func (b *Bot) SendVideoNote(chatId int64, videoNote types.InputFile, opts *SendV if opts != nil { params["business_connection_id"] = opts.BusinessConnectionId params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) params["duration"] = strconv.FormatInt(opts.Duration, 10) params["length"] = strconv.FormatInt(opts.Length, 10) @@ -1121,8 +1279,18 @@ func (b *Bot) SendVideoNote(chatId int64, videoNote types.InputFile, opts *SendV } params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + + if opts.ReplyParameters != nil { bs, err := json.Marshal(opts.ReplyParameters) if err != nil { @@ -1156,17 +1324,23 @@ func (b *Bot) SendVideoNote(chatId int64, videoNote types.InputFile, opts *SendV // SendPaidMedia methods's optional params type SendPaidMediaOpts struct { + BusinessConnectionId string `json:"business_connection_id,omitempty"` + MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` + Payload string `json:"payload,omitempty"` Caption string `json:"caption,omitempty"` ParseMode string `json:"parse_mode,omitempty"` CaptionEntities []types.MessageEntity `json:"caption_entities,omitempty"` ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup types.ReplyMarkup `json:"reply_markup,omitempty"` } -// Use this method to send paid media to channel chats. On success, the sent Message is returned. +// Use this method to send paid media. On success, the sent Message is returned. func (b *Bot) SendPaidMedia(chatId int64, starCount int64, media []types.InputPaidMedia, opts *SendPaidMediaOpts) (*types.Message, error) { params := map[string]string{} data_params := map[string]string{} @@ -1183,6 +1357,10 @@ func (b *Bot) SendPaidMedia(chatId int64, starCount int64, media []types.InputPa } if opts != nil { + params["business_connection_id"] = opts.BusinessConnectionId + params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) + params["payload"] = opts.Payload params["caption"] = opts.Caption params["parse_mode"] = opts.ParseMode @@ -1197,6 +1375,16 @@ func (b *Bot) SendPaidMedia(chatId int64, starCount int64, media []types.InputPa params["show_caption_above_media"] = strconv.FormatBool(opts.ShowCaptionAboveMedia) params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) + + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + if opts.ReplyParameters != nil { bs, err := json.Marshal(opts.ReplyParameters) @@ -1233,13 +1421,15 @@ func (b *Bot) SendPaidMedia(chatId int64, starCount int64, media []types.InputPa type SendMediaGroupOpts struct { BusinessConnectionId string `json:"business_connection_id,omitempty"` MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` } -// Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned. +// Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Message objects that were sent is returned. func (b *Bot) SendMediaGroup(chatId int64, media []types.InputMediaAudio, opts *SendMediaGroupOpts) ([]types.Message, error) { params := map[string]string{} data_params := map[string]string{} @@ -1257,8 +1447,10 @@ func (b *Bot) SendMediaGroup(chatId int64, media []types.InputMediaAudio, opts * if opts != nil { params["business_connection_id"] = opts.BusinessConnectionId params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId if opts.ReplyParameters != nil { @@ -1287,13 +1479,16 @@ func (b *Bot) SendMediaGroup(chatId int64, media []types.InputMediaAudio, opts * type SendLocationOpts struct { BusinessConnectionId string `json:"business_connection_id,omitempty"` MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"` LivePeriod int64 `json:"live_period,omitempty"` Heading int64 `json:"heading,omitempty"` ProximityAlertRadius int64 `json:"proximity_alert_radius,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup types.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -1309,14 +1504,25 @@ func (b *Bot) SendLocation(chatId int64, latitude float64, longitude float64, op if opts != nil { params["business_connection_id"] = opts.BusinessConnectionId params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) params["horizontal_accuracy"] = strconv.FormatFloat(opts.HorizontalAccuracy, 'E', -1, 64) params["live_period"] = strconv.FormatInt(opts.LivePeriod, 10) params["heading"] = strconv.FormatInt(opts.Heading, 10) params["proximity_alert_radius"] = strconv.FormatInt(opts.ProximityAlertRadius, 10) params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + + if opts.ReplyParameters != nil { bs, err := json.Marshal(opts.ReplyParameters) if err != nil { @@ -1352,13 +1558,16 @@ func (b *Bot) SendLocation(chatId int64, latitude float64, longitude float64, op type SendVenueOpts struct { BusinessConnectionId string `json:"business_connection_id,omitempty"` MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` FoursquareId string `json:"foursquare_id,omitempty"` FoursquareType string `json:"foursquare_type,omitempty"` GooglePlaceId string `json:"google_place_id,omitempty"` GooglePlaceType string `json:"google_place_type,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup types.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -1376,14 +1585,25 @@ func (b *Bot) SendVenue(chatId int64, latitude float64, longitude float64, title if opts != nil { params["business_connection_id"] = opts.BusinessConnectionId params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) params["foursquare_id"] = opts.FoursquareId params["foursquare_type"] = opts.FoursquareType params["google_place_id"] = opts.GooglePlaceId params["google_place_type"] = opts.GooglePlaceType params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + + if opts.ReplyParameters != nil { bs, err := json.Marshal(opts.ReplyParameters) if err != nil { @@ -1419,11 +1639,14 @@ func (b *Bot) SendVenue(chatId int64, latitude float64, longitude float64, title type SendContactOpts struct { BusinessConnectionId string `json:"business_connection_id,omitempty"` MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` LastName string `json:"last_name,omitempty"` Vcard string `json:"vcard,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup types.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -1439,12 +1662,23 @@ func (b *Bot) SendContact(chatId int64, phoneNumber string, firstName string, op if opts != nil { params["business_connection_id"] = opts.BusinessConnectionId params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) params["last_name"] = opts.LastName params["vcard"] = opts.Vcard params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + + if opts.ReplyParameters != nil { bs, err := json.Marshal(opts.ReplyParameters) if err != nil { @@ -1485,15 +1719,23 @@ type SendPollOpts struct { IsAnonymous bool `json:"is_anonymous,omitempty"` Type string `json:"type,omitempty"` AllowsMultipleAnswers bool `json:"allows_multiple_answers,omitempty"` - CorrectOptionId int64 `json:"correct_option_id,omitempty"` + AllowsRevoting bool `json:"allows_revoting,omitempty"` + ShuffleOptions bool `json:"shuffle_options,omitempty"` + AllowAddingOptions bool `json:"allow_adding_options,omitempty"` + HideResultsUntilCloses bool `json:"hide_results_until_closes,omitempty"` + CorrectOptionIds []int64 `json:"correct_option_ids,omitempty"` Explanation string `json:"explanation,omitempty"` ExplanationParseMode string `json:"explanation_parse_mode,omitempty"` ExplanationEntities []types.MessageEntity `json:"explanation_entities,omitempty"` OpenPeriod int64 `json:"open_period,omitempty"` CloseDate int64 `json:"close_date,omitempty"` IsClosed bool `json:"is_closed,omitempty"` + Description string `json:"description,omitempty"` + DescriptionParseMode string `json:"description_parse_mode,omitempty"` + DescriptionEntities []types.MessageEntity `json:"description_entities,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup types.ReplyMarkup `json:"reply_markup,omitempty"` @@ -1531,7 +1773,19 @@ func (b *Bot) SendPoll(chatId int64, question string, options []types.InputPollO params["is_anonymous"] = strconv.FormatBool(opts.IsAnonymous) params["type"] = opts.Type params["allows_multiple_answers"] = strconv.FormatBool(opts.AllowsMultipleAnswers) - params["correct_option_id"] = strconv.FormatInt(opts.CorrectOptionId, 10) + params["allows_revoting"] = strconv.FormatBool(opts.AllowsRevoting) + params["shuffle_options"] = strconv.FormatBool(opts.ShuffleOptions) + params["allow_adding_options"] = strconv.FormatBool(opts.AllowAddingOptions) + params["hide_results_until_closes"] = strconv.FormatBool(opts.HideResultsUntilCloses) + + if opts.CorrectOptionIds != nil { + bs, err := json.Marshal(opts.CorrectOptionIds) + if err != nil { + return nil, fmt.Errorf("failed to marshal field correct_option_ids: %w", err) + } + params["correct_option_ids"] = string(bs) + } + params["explanation"] = opts.Explanation params["explanation_parse_mode"] = opts.ExplanationParseMode @@ -1546,8 +1800,20 @@ func (b *Bot) SendPoll(chatId int64, question string, options []types.InputPollO params["open_period"] = strconv.FormatInt(opts.OpenPeriod, 10) params["close_date"] = strconv.FormatInt(opts.CloseDate, 10) params["is_closed"] = strconv.FormatBool(opts.IsClosed) + params["description"] = opts.Description + params["description_parse_mode"] = opts.DescriptionParseMode + + if opts.DescriptionEntities != nil { + bs, err := json.Marshal(opts.DescriptionEntities) + if err != nil { + return nil, fmt.Errorf("failed to marshal field description_entities: %w", err) + } + params["description_entities"] = string(bs) + } + params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId if opts.ReplyParameters != nil { @@ -1581,14 +1847,78 @@ func (b *Bot) SendPoll(chatId int64, question string, options []types.InputPollO } +// SendChecklist methods's optional params +type SendChecklistOpts struct { + DisableNotification bool `json:"disable_notification,omitempty"` + ProtectContent bool `json:"protect_content,omitempty"` + MessageEffectId string `json:"message_effect_id,omitempty"` + ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` + ReplyMarkup *types.InlineKeyboardMarkup `json:"reply_markup,omitempty"` +} + +// Use this method to send a checklist on behalf of a connected business account. On success, the sent Message is returned. +func (b *Bot) SendChecklist(businessConnectionId string, chatId int64, checklist *types.InputChecklist, opts *SendChecklistOpts) (*types.Message, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["business_connection_id"] = businessConnectionId + params["chat_id"] = strconv.FormatInt(chatId, 10) + + if checklist != nil { + bs, err := json.Marshal(checklist) + if err != nil { + return nil, fmt.Errorf("failed to marshal field checklist: %w", err) + } + params["checklist"] = string(bs) + } + + if opts != nil { + params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) + params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["message_effect_id"] = opts.MessageEffectId + + if opts.ReplyParameters != nil { + bs, err := json.Marshal(opts.ReplyParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err) + } + params["reply_parameters"] = string(bs) + } + + + if opts.ReplyMarkup != nil { + bs, err := json.Marshal(opts.ReplyMarkup) + if err != nil { + return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err) + } + params["reply_markup"] = string(bs) + } + + } + + + r, err := b.Request("sendChecklist", params, data_params) + if err != nil { + return nil, err + } + + + var res *types.Message + return res, json.Unmarshal(r, &res) + +} + // SendDice methods's optional params type SendDiceOpts struct { BusinessConnectionId string `json:"business_connection_id,omitempty"` MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` Emoji string `json:"emoji,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup types.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -1602,11 +1932,22 @@ func (b *Bot) SendDice(chatId int64, opts *SendDiceOpts) (*types.Message, error) if opts != nil { params["business_connection_id"] = opts.BusinessConnectionId params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) params["emoji"] = opts.Emoji params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + + if opts.ReplyParameters != nil { bs, err := json.Marshal(opts.ReplyParameters) if err != nil { @@ -1638,6 +1979,47 @@ func (b *Bot) SendDice(chatId int64, opts *SendDiceOpts) (*types.Message, error) } +// SendMessageDraft methods's optional params +type SendMessageDraftOpts struct { + MessageThreadId int64 `json:"message_thread_id,omitempty"` + ParseMode string `json:"parse_mode,omitempty"` + Entities []types.MessageEntity `json:"entities,omitempty"` +} + +// Use this method to stream a partial message to a user while the message is being generated. Returns True on success. +func (b *Bot) SendMessageDraft(chatId int64, draftId int64, text string, opts *SendMessageDraftOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["chat_id"] = strconv.FormatInt(chatId, 10) + params["draft_id"] = strconv.FormatInt(draftId, 10) + params["text"] = text + if opts != nil { + params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["parse_mode"] = opts.ParseMode + + if opts.Entities != nil { + bs, err := json.Marshal(opts.Entities) + if err != nil { + return false, fmt.Errorf("failed to marshal field entities: %w", err) + } + params["entities"] = string(bs) + } + + } + + + r, err := b.Request("sendMessageDraft", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + // SendChatAction methods's optional params type SendChatActionOpts struct { BusinessConnectionId string `json:"business_connection_id,omitempty"` @@ -1675,7 +2057,7 @@ type SetMessageReactionOpts struct { IsBig bool `json:"is_big,omitempty"` } -// 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. 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. func (b *Bot) SetMessageReaction(chatId int64, messageId int64, opts *SetMessageReactionOpts) (bool, error) { params := map[string]string{} data_params := map[string]string{} @@ -1736,6 +2118,64 @@ func (b *Bot) GetUserProfilePhotos(userId int64, opts *GetUserProfilePhotosOpts) } +// GetUserProfileAudios methods's optional params +type GetUserProfileAudiosOpts struct { + Offset int64 `json:"offset,omitempty"` + Limit int64 `json:"limit,omitempty"` +} + +// Use this method to get a list of profile audios for a user. Returns a UserProfileAudios object. +func (b *Bot) GetUserProfileAudios(userId int64, opts *GetUserProfileAudiosOpts) (*types.UserProfileAudios, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["user_id"] = strconv.FormatInt(userId, 10) + if opts != nil { + params["offset"] = strconv.FormatInt(opts.Offset, 10) + params["limit"] = strconv.FormatInt(opts.Limit, 10) + } + + + r, err := b.Request("getUserProfileAudios", params, data_params) + if err != nil { + return nil, err + } + + + var res *types.UserProfileAudios + return res, json.Unmarshal(r, &res) + +} + +// SetUserEmojiStatus methods's optional params +type SetUserEmojiStatusOpts struct { + EmojiStatusCustomEmojiId string `json:"emoji_status_custom_emoji_id,omitempty"` + EmojiStatusExpirationDate int64 `json:"emoji_status_expiration_date,omitempty"` +} + +// 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. +func (b *Bot) SetUserEmojiStatus(userId int64, opts *SetUserEmojiStatusOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["user_id"] = strconv.FormatInt(userId, 10) + if opts != nil { + params["emoji_status_custom_emoji_id"] = opts.EmojiStatusCustomEmojiId + params["emoji_status_expiration_date"] = strconv.FormatInt(opts.EmojiStatusExpirationDate, 10) + } + + + r, err := b.Request("setUserEmojiStatus", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + // Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot/, where is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again. // Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received. func (b *Bot) GetFile(fileId string) (*types.File, error) { @@ -1867,6 +2307,8 @@ type PromoteChatMemberOpts struct { CanEditMessages bool `json:"can_edit_messages,omitempty"` CanPinMessages bool `json:"can_pin_messages,omitempty"` CanManageTopics bool `json:"can_manage_topics,omitempty"` + CanManageDirectMessages bool `json:"can_manage_direct_messages,omitempty"` + CanManageTags bool `json:"can_manage_tags,omitempty"` } // Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success. @@ -1892,6 +2334,8 @@ func (b *Bot) PromoteChatMember(chatId int64, userId int64, opts *PromoteChatMem params["can_edit_messages"] = strconv.FormatBool(opts.CanEditMessages) params["can_pin_messages"] = strconv.FormatBool(opts.CanPinMessages) params["can_manage_topics"] = strconv.FormatBool(opts.CanManageTopics) + params["can_manage_direct_messages"] = strconv.FormatBool(opts.CanManageDirectMessages) + params["can_manage_tags"] = strconv.FormatBool(opts.CanManageTags) } @@ -1924,6 +2368,34 @@ func (b *Bot) SetChatAdministratorCustomTitle(chatId int64, userId int64, custom } +// SetChatMemberTag methods's optional params +type SetChatMemberTagOpts struct { + Tag string `json:"tag,omitempty"` +} + +// Use this method to set a tag for a regular member in a group or a supergroup. The bot must be an administrator in the chat for this to work and must have the can_manage_tags administrator right. Returns True on success. +func (b *Bot) SetChatMemberTag(chatId int64, userId int64, opts *SetChatMemberTagOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["chat_id"] = strconv.FormatInt(chatId, 10) + params["user_id"] = strconv.FormatInt(userId, 10) + if opts != nil { + params["tag"] = opts.Tag + } + + + r, err := b.Request("setChatMemberTag", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + // Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success. func (b *Bot) BanChatSenderChat(chatId int64, senderChatId int64) (bool, error) { params := map[string]string{} @@ -2077,8 +2549,65 @@ func (b *Bot) EditChatInviteLink(chatId int64, inviteLink string, opts *EditChat } -// Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object. -func (b *Bot) RevokeChatInviteLink(chatId int64, inviteLink string) (*types.ChatInviteLink, error) { +// CreateChatSubscriptionInviteLink methods's optional params +type CreateChatSubscriptionInviteLinkOpts struct { + Name string `json:"name,omitempty"` +} + +// 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. +func (b *Bot) CreateChatSubscriptionInviteLink(chatId int64, subscriptionPeriod int64, subscriptionPrice int64, opts *CreateChatSubscriptionInviteLinkOpts) (*types.ChatInviteLink, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["chat_id"] = strconv.FormatInt(chatId, 10) + params["subscription_period"] = strconv.FormatInt(subscriptionPeriod, 10) + params["subscription_price"] = strconv.FormatInt(subscriptionPrice, 10) + if opts != nil { + params["name"] = opts.Name + } + + + r, err := b.Request("createChatSubscriptionInviteLink", params, data_params) + if err != nil { + return nil, err + } + + + var res *types.ChatInviteLink + return res, json.Unmarshal(r, &res) + +} + +// EditChatSubscriptionInviteLink methods's optional params +type EditChatSubscriptionInviteLinkOpts struct { + Name string `json:"name,omitempty"` +} + +// Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object. +func (b *Bot) EditChatSubscriptionInviteLink(chatId int64, inviteLink string, opts *EditChatSubscriptionInviteLinkOpts) (*types.ChatInviteLink, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["chat_id"] = strconv.FormatInt(chatId, 10) + params["invite_link"] = inviteLink + if opts != nil { + params["name"] = opts.Name + } + + + r, err := b.Request("editChatSubscriptionInviteLink", params, data_params) + if err != nil { + return nil, err + } + + + var res *types.ChatInviteLink + return res, json.Unmarshal(r, &res) + +} + +// Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object. +func (b *Bot) RevokeChatInviteLink(chatId int64, inviteLink string) (*types.ChatInviteLink, error) { params := map[string]string{} data_params := map[string]string{} params["chat_id"] = strconv.FormatInt(chatId, 10) @@ -2221,10 +2750,11 @@ func (b *Bot) SetChatDescription(chatId int64, opts *SetChatDescriptionOpts) (bo // PinChatMessage methods's optional params type PinChatMessageOpts struct { + BusinessConnectionId string `json:"business_connection_id,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` } -// Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success. +// Use this method to add a message to the list of pinned messages in a chat. In private chats and channel direct messages chats, all non-service messages can be pinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to pin messages in groups and channels respectively. Returns True on success. func (b *Bot) PinChatMessage(chatId int64, messageId int64, opts *PinChatMessageOpts) (bool, error) { params := map[string]string{} data_params := map[string]string{} @@ -2232,6 +2762,7 @@ func (b *Bot) PinChatMessage(chatId int64, messageId int64, opts *PinChatMessage params["chat_id"] = strconv.FormatInt(chatId, 10) params["message_id"] = strconv.FormatInt(messageId, 10) if opts != nil { + params["business_connection_id"] = opts.BusinessConnectionId params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) } @@ -2249,16 +2780,18 @@ func (b *Bot) PinChatMessage(chatId int64, messageId int64, opts *PinChatMessage // UnpinChatMessage methods's optional params type UnpinChatMessageOpts struct { + BusinessConnectionId string `json:"business_connection_id,omitempty"` MessageId int64 `json:"message_id,omitempty"` } -// Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success. +// Use this method to remove a message from the list of pinned messages in a chat. In private chats and channel direct messages chats, all messages can be unpinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin messages in groups and channels respectively. Returns True on success. func (b *Bot) UnpinChatMessage(chatId int64, opts *UnpinChatMessageOpts) (bool, error) { params := map[string]string{} data_params := map[string]string{} params["chat_id"] = strconv.FormatInt(chatId, 10) if opts != nil { + params["business_connection_id"] = opts.BusinessConnectionId params["message_id"] = strconv.FormatInt(opts.MessageId, 10) } @@ -2274,7 +2807,7 @@ func (b *Bot) UnpinChatMessage(chatId int64, opts *UnpinChatMessageOpts) (bool, } -// Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success. +// Use this method to clear the list of pinned messages in a chat. In private chats and channel direct messages chats, no additional rights are required to unpin all pinned messages. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin all pinned messages in groups and channels respectively. Returns True on success. func (b *Bot) UnpinAllChatMessages(chatId int64) (bool, error) { params := map[string]string{} data_params := map[string]string{} @@ -2425,7 +2958,7 @@ type CreateForumTopicOpts struct { IconCustomEmojiId string `json:"icon_custom_emoji_id,omitempty"` } -// Use this method to create 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. Returns information about the created topic as a ForumTopic object. +// Use this method to create 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 right. Returns information about the created topic as a ForumTopic object. func (b *Bot) CreateForumTopic(chatId int64, name string, opts *CreateForumTopicOpts) (*types.ForumTopic, error) { params := map[string]string{} data_params := map[string]string{} @@ -2455,7 +2988,7 @@ type EditForumTopicOpts struct { IconCustomEmojiId string `json:"icon_custom_emoji_id,omitempty"` } -// 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 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. func (b *Bot) EditForumTopic(chatId int64, messageThreadId int64, opts *EditForumTopicOpts) (bool, error) { params := map[string]string{} data_params := map[string]string{} @@ -2513,7 +3046,7 @@ func (b *Bot) ReopenForumTopic(chatId int64, messageThreadId int64) (bool, error } -// 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. func (b *Bot) DeleteForumTopic(chatId int64, messageThreadId int64) (bool, error) { params := map[string]string{} data_params := map[string]string{} @@ -2530,7 +3063,7 @@ func (b *Bot) DeleteForumTopic(chatId int64, messageThreadId int64) (bool, error } -// 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. func (b *Bot) UnpinAllForumTopicMessages(chatId int64, messageThreadId int64) (bool, error) { params := map[string]string{} data_params := map[string]string{} @@ -2547,7 +3080,7 @@ func (b *Bot) UnpinAllForumTopicMessages(chatId int64, messageThreadId int64) (b } -// Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success. +// Use this method to edit the name of the 'General' 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. Returns True on success. func (b *Bot) EditGeneralForumTopic(chatId int64, name string) (bool, error) { params := map[string]string{} data_params := map[string]string{} @@ -2710,6 +3243,38 @@ func (b *Bot) GetBusinessConnection(businessConnectionId string) (*types.Busines } +// Use this method to get the token of a managed bot. Returns the token as String on success. +func (b *Bot) GetManagedBotToken(userId int64) (string, error) { + params := map[string]string{} + data_params := map[string]string{} + params["user_id"] = strconv.FormatInt(userId, 10) + + r, err := b.Request("getManagedBotToken", params, data_params) + if err != nil { + return "", err + } + + var res string + return res, json.Unmarshal(r, &res) + +} + +// Use this method to revoke the current token of a managed bot and generate a new one. Returns the new token as String on success. +func (b *Bot) ReplaceManagedBotToken(userId int64) (string, error) { + params := map[string]string{} + data_params := map[string]string{} + params["user_id"] = strconv.FormatInt(userId, 10) + + r, err := b.Request("replaceManagedBotToken", params, data_params) + if err != nil { + return "", err + } + + var res string + return res, json.Unmarshal(r, &res) + +} + // SetMyCommands methods's optional params type SetMyCommandsOpts struct { Scope *types.BotCommandScope `json:"scope,omitempty"` @@ -2974,141 +3539,1084 @@ func (b *Bot) GetMyShortDescription(opts *GetMyShortDescriptionOpts) (*types.Bot data_params := map[string]string{} if opts != nil { - params["language_code"] = opts.LanguageCode + params["language_code"] = opts.LanguageCode + } + + + r, err := b.Request("getMyShortDescription", params, data_params) + if err != nil { + return nil, err + } + + + var res *types.BotShortDescription + return res, json.Unmarshal(r, &res) + +} + +// Changes the profile photo of the bot. Returns True on success. +func (b *Bot) SetMyProfilePhoto(photo *types.InputProfilePhoto) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + if photo != nil { + bs, err := json.Marshal(photo) + if err != nil { + return false, fmt.Errorf("failed to marshal field photo: %w", err) + } + params["photo"] = string(bs) + } + + + r, err := b.Request("setMyProfilePhoto", params, data_params) + if err != nil { + return false, err + } + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// Removes the profile photo of the bot. Requires no parameters. Returns True on success. +func (b *Bot) RemoveMyProfilePhoto() (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + r, err := b.Request("removeMyProfilePhoto", params, data_params) + if err != nil { + return false, err + } + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// SetChatMenuButton methods's optional params +type SetChatMenuButtonOpts struct { + ChatId int64 `json:"chat_id,omitempty"` + MenuButton *types.MenuButton `json:"menu_button,omitempty"` +} + +// Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success. +func (b *Bot) SetChatMenuButton(opts *SetChatMenuButtonOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + if opts != nil { + params["chat_id"] = strconv.FormatInt(opts.ChatId, 10) + + if opts.MenuButton != nil { + bs, err := json.Marshal(opts.MenuButton) + if err != nil { + return false, fmt.Errorf("failed to marshal field menu_button: %w", err) + } + params["menu_button"] = string(bs) + } + + } + + + r, err := b.Request("setChatMenuButton", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// GetChatMenuButton methods's optional params +type GetChatMenuButtonOpts struct { + ChatId int64 `json:"chat_id,omitempty"` +} + +// Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success. +func (b *Bot) GetChatMenuButton(opts *GetChatMenuButtonOpts) (*types.MenuButton, error) { + params := map[string]string{} + data_params := map[string]string{} + + if opts != nil { + params["chat_id"] = strconv.FormatInt(opts.ChatId, 10) + } + + + r, err := b.Request("getChatMenuButton", params, data_params) + if err != nil { + return nil, err + } + + + var res *types.MenuButton + return res, json.Unmarshal(r, &res) + +} + +// SetMyDefaultAdministratorRights methods's optional params +type SetMyDefaultAdministratorRightsOpts struct { + Rights *types.ChatAdministratorRights `json:"rights,omitempty"` + ForChannels bool `json:"for_channels,omitempty"` +} + +// Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are free to modify the list before adding the bot. Returns True on success. +func (b *Bot) SetMyDefaultAdministratorRights(opts *SetMyDefaultAdministratorRightsOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + if opts != nil { + + if opts.Rights != nil { + bs, err := json.Marshal(opts.Rights) + if err != nil { + return false, fmt.Errorf("failed to marshal field rights: %w", err) + } + params["rights"] = string(bs) + } + + params["for_channels"] = strconv.FormatBool(opts.ForChannels) + } + + + r, err := b.Request("setMyDefaultAdministratorRights", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// GetMyDefaultAdministratorRights methods's optional params +type GetMyDefaultAdministratorRightsOpts struct { + ForChannels bool `json:"for_channels,omitempty"` +} + +// Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success. +func (b *Bot) GetMyDefaultAdministratorRights(opts *GetMyDefaultAdministratorRightsOpts) (*types.ChatAdministratorRights, error) { + params := map[string]string{} + data_params := map[string]string{} + + if opts != nil { + params["for_channels"] = strconv.FormatBool(opts.ForChannels) + } + + + r, err := b.Request("getMyDefaultAdministratorRights", params, data_params) + if err != nil { + return nil, err + } + + + var res *types.ChatAdministratorRights + return res, json.Unmarshal(r, &res) + +} + +// Returns the list of gifts that can be sent by the bot to users and channel chats. Requires no parameters. Returns a Gifts object. +func (b *Bot) GetAvailableGifts() (*types.Gifts, error) { + params := map[string]string{} + data_params := map[string]string{} + + r, err := b.Request("getAvailableGifts", params, data_params) + if err != nil { + return nil, err + } + + var res *types.Gifts + return res, json.Unmarshal(r, &res) + +} + +// SendGift methods's optional params +type SendGiftOpts struct { + UserId int64 `json:"user_id,omitempty"` + ChatId int64 `json:"chat_id,omitempty"` + PayForUpgrade bool `json:"pay_for_upgrade,omitempty"` + Text string `json:"text,omitempty"` + TextParseMode string `json:"text_parse_mode,omitempty"` + TextEntities []types.MessageEntity `json:"text_entities,omitempty"` +} + +// 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. +func (b *Bot) SendGift(giftId string, opts *SendGiftOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["gift_id"] = giftId + if opts != nil { + params["user_id"] = strconv.FormatInt(opts.UserId, 10) + params["chat_id"] = strconv.FormatInt(opts.ChatId, 10) + params["pay_for_upgrade"] = strconv.FormatBool(opts.PayForUpgrade) + params["text"] = opts.Text + params["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) + } + params["text_entities"] = string(bs) + } + + } + + + r, err := b.Request("sendGift", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// GiftPremiumSubscription methods's optional params +type GiftPremiumSubscriptionOpts struct { + Text string `json:"text,omitempty"` + TextParseMode string `json:"text_parse_mode,omitempty"` + TextEntities []types.MessageEntity `json:"text_entities,omitempty"` +} + +// Gifts a Telegram Premium subscription to the given user. Returns True on success. +func (b *Bot) GiftPremiumSubscription(userId int64, monthCount int64, starCount int64, opts *GiftPremiumSubscriptionOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["user_id"] = strconv.FormatInt(userId, 10) + params["month_count"] = strconv.FormatInt(monthCount, 10) + params["star_count"] = strconv.FormatInt(starCount, 10) + if opts != nil { + params["text"] = opts.Text + params["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) + } + params["text_entities"] = string(bs) + } + + } + + + r, err := b.Request("giftPremiumSubscription", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// VerifyUser methods's optional params +type VerifyUserOpts struct { + CustomDescription string `json:"custom_description,omitempty"` +} + +// Verifies a user on behalf of the organization which is represented by the bot. Returns True on success. +func (b *Bot) VerifyUser(userId int64, opts *VerifyUserOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["user_id"] = strconv.FormatInt(userId, 10) + if opts != nil { + params["custom_description"] = opts.CustomDescription + } + + + r, err := b.Request("verifyUser", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// VerifyChat methods's optional params +type VerifyChatOpts struct { + CustomDescription string `json:"custom_description,omitempty"` +} + +// Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success. +func (b *Bot) VerifyChat(chatId int64, opts *VerifyChatOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["chat_id"] = strconv.FormatInt(chatId, 10) + if opts != nil { + params["custom_description"] = opts.CustomDescription + } + + + r, err := b.Request("verifyChat", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success. +func (b *Bot) RemoveUserVerification(userId int64) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + params["user_id"] = strconv.FormatInt(userId, 10) + + r, err := b.Request("removeUserVerification", params, data_params) + if err != nil { + return false, err + } + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success. +func (b *Bot) RemoveChatVerification(chatId int64) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + params["chat_id"] = strconv.FormatInt(chatId, 10) + + r, err := b.Request("removeChatVerification", params, data_params) + if err != nil { + return false, err + } + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success. +func (b *Bot) ReadBusinessMessage(businessConnectionId string, chatId int64, messageId int64) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + params["business_connection_id"] = businessConnectionId + params["chat_id"] = strconv.FormatInt(chatId, 10) + params["message_id"] = strconv.FormatInt(messageId, 10) + + r, err := b.Request("readBusinessMessage", params, data_params) + if err != nil { + return false, err + } + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// Delete messages on behalf of a business account. Requires the can_delete_sent_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. +func (b *Bot) DeleteBusinessMessages(businessConnectionId string, messageIds []int64) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + params["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) + } + params["message_ids"] = string(bs) + } + + + r, err := b.Request("deleteBusinessMessages", params, data_params) + if err != nil { + return false, err + } + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// SetBusinessAccountName methods's optional params +type SetBusinessAccountNameOpts struct { + LastName string `json:"last_name,omitempty"` +} + +// Changes the first and last name of a managed business account. Requires the can_change_name business bot right. Returns True on success. +func (b *Bot) SetBusinessAccountName(businessConnectionId string, firstName string, opts *SetBusinessAccountNameOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["business_connection_id"] = businessConnectionId + params["first_name"] = firstName + if opts != nil { + params["last_name"] = opts.LastName + } + + + r, err := b.Request("setBusinessAccountName", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// SetBusinessAccountUsername methods's optional params +type SetBusinessAccountUsernameOpts struct { + Username string `json:"username,omitempty"` +} + +// Changes the username of a managed business account. Requires the can_change_username business bot right. Returns True on success. +func (b *Bot) SetBusinessAccountUsername(businessConnectionId string, opts *SetBusinessAccountUsernameOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["business_connection_id"] = businessConnectionId + if opts != nil { + params["username"] = opts.Username + } + + + r, err := b.Request("setBusinessAccountUsername", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// SetBusinessAccountBio methods's optional params +type SetBusinessAccountBioOpts struct { + Bio string `json:"bio,omitempty"` +} + +// Changes the bio of a managed business account. Requires the can_change_bio business bot right. Returns True on success. +func (b *Bot) SetBusinessAccountBio(businessConnectionId string, opts *SetBusinessAccountBioOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["business_connection_id"] = businessConnectionId + if opts != nil { + params["bio"] = opts.Bio + } + + + r, err := b.Request("setBusinessAccountBio", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// SetBusinessAccountProfilePhoto methods's optional params +type SetBusinessAccountProfilePhotoOpts struct { + IsPublic bool `json:"is_public,omitempty"` +} + +// Changes the profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success. +func (b *Bot) SetBusinessAccountProfilePhoto(businessConnectionId string, photo *types.InputProfilePhoto, opts *SetBusinessAccountProfilePhotoOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["business_connection_id"] = businessConnectionId + + if photo != nil { + bs, err := json.Marshal(photo) + if err != nil { + return false, fmt.Errorf("failed to marshal field photo: %w", err) + } + params["photo"] = string(bs) + } + + if opts != nil { + params["is_public"] = strconv.FormatBool(opts.IsPublic) + } + + + r, err := b.Request("setBusinessAccountProfilePhoto", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// RemoveBusinessAccountProfilePhoto methods's optional params +type RemoveBusinessAccountProfilePhotoOpts struct { + IsPublic bool `json:"is_public,omitempty"` +} + +// Removes the current profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success. +func (b *Bot) RemoveBusinessAccountProfilePhoto(businessConnectionId string, opts *RemoveBusinessAccountProfilePhotoOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["business_connection_id"] = businessConnectionId + if opts != nil { + params["is_public"] = strconv.FormatBool(opts.IsPublic) + } + + + r, err := b.Request("removeBusinessAccountProfilePhoto", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// 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. +func (b *Bot) SetBusinessAccountGiftSettings(businessConnectionId string, showGiftButton bool, acceptedGiftTypes *types.AcceptedGiftTypes) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + params["business_connection_id"] = businessConnectionId + params["show_gift_button"] = strconv.FormatBool(showGiftButton) + + if acceptedGiftTypes != nil { + bs, err := json.Marshal(acceptedGiftTypes) + if err != nil { + return false, fmt.Errorf("failed to marshal field accepted_gift_types: %w", err) + } + params["accepted_gift_types"] = string(bs) + } + + + r, err := b.Request("setBusinessAccountGiftSettings", params, data_params) + if err != nil { + return false, err + } + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// 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. +func (b *Bot) GetBusinessAccountStarBalance(businessConnectionId string) (*types.StarAmount, error) { + params := map[string]string{} + data_params := map[string]string{} + params["business_connection_id"] = businessConnectionId + + r, err := b.Request("getBusinessAccountStarBalance", params, data_params) + if err != nil { + return nil, err + } + + var res *types.StarAmount + return res, json.Unmarshal(r, &res) + +} + +// 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. +func (b *Bot) TransferBusinessAccountStars(businessConnectionId string, starCount int64) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + params["business_connection_id"] = businessConnectionId + params["star_count"] = strconv.FormatInt(starCount, 10) + + r, err := b.Request("transferBusinessAccountStars", params, data_params) + if err != nil { + return false, err + } + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// GetBusinessAccountGifts methods's optional params +type GetBusinessAccountGiftsOpts struct { + ExcludeUnsaved bool `json:"exclude_unsaved,omitempty"` + ExcludeSaved bool `json:"exclude_saved,omitempty"` + ExcludeUnlimited bool `json:"exclude_unlimited,omitempty"` + ExcludeLimitedUpgradable bool `json:"exclude_limited_upgradable,omitempty"` + ExcludeLimitedNonUpgradable bool `json:"exclude_limited_non_upgradable,omitempty"` + ExcludeUnique bool `json:"exclude_unique,omitempty"` + ExcludeFromBlockchain bool `json:"exclude_from_blockchain,omitempty"` + SortByPrice bool `json:"sort_by_price,omitempty"` + Offset string `json:"offset,omitempty"` + Limit int64 `json:"limit,omitempty"` +} + +// 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. +func (b *Bot) GetBusinessAccountGifts(businessConnectionId string, opts *GetBusinessAccountGiftsOpts) (*types.OwnedGifts, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["business_connection_id"] = businessConnectionId + if opts != nil { + params["exclude_unsaved"] = strconv.FormatBool(opts.ExcludeUnsaved) + params["exclude_saved"] = strconv.FormatBool(opts.ExcludeSaved) + params["exclude_unlimited"] = strconv.FormatBool(opts.ExcludeUnlimited) + params["exclude_limited_upgradable"] = strconv.FormatBool(opts.ExcludeLimitedUpgradable) + params["exclude_limited_non_upgradable"] = strconv.FormatBool(opts.ExcludeLimitedNonUpgradable) + params["exclude_unique"] = strconv.FormatBool(opts.ExcludeUnique) + params["exclude_from_blockchain"] = strconv.FormatBool(opts.ExcludeFromBlockchain) + params["sort_by_price"] = strconv.FormatBool(opts.SortByPrice) + params["offset"] = opts.Offset + params["limit"] = strconv.FormatInt(opts.Limit, 10) + } + + + r, err := b.Request("getBusinessAccountGifts", params, data_params) + if err != nil { + return nil, err + } + + + var res *types.OwnedGifts + return res, json.Unmarshal(r, &res) + +} + +// GetUserGifts methods's optional params +type GetUserGiftsOpts struct { + ExcludeUnlimited bool `json:"exclude_unlimited,omitempty"` + ExcludeLimitedUpgradable bool `json:"exclude_limited_upgradable,omitempty"` + ExcludeLimitedNonUpgradable bool `json:"exclude_limited_non_upgradable,omitempty"` + ExcludeFromBlockchain bool `json:"exclude_from_blockchain,omitempty"` + ExcludeUnique bool `json:"exclude_unique,omitempty"` + SortByPrice bool `json:"sort_by_price,omitempty"` + Offset string `json:"offset,omitempty"` + Limit int64 `json:"limit,omitempty"` +} + +// Returns the gifts owned and hosted by a user. Returns OwnedGifts on success. +func (b *Bot) GetUserGifts(userId int64, opts *GetUserGiftsOpts) (*types.OwnedGifts, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["user_id"] = strconv.FormatInt(userId, 10) + if opts != nil { + params["exclude_unlimited"] = strconv.FormatBool(opts.ExcludeUnlimited) + params["exclude_limited_upgradable"] = strconv.FormatBool(opts.ExcludeLimitedUpgradable) + params["exclude_limited_non_upgradable"] = strconv.FormatBool(opts.ExcludeLimitedNonUpgradable) + params["exclude_from_blockchain"] = strconv.FormatBool(opts.ExcludeFromBlockchain) + params["exclude_unique"] = strconv.FormatBool(opts.ExcludeUnique) + params["sort_by_price"] = strconv.FormatBool(opts.SortByPrice) + params["offset"] = opts.Offset + params["limit"] = strconv.FormatInt(opts.Limit, 10) + } + + + r, err := b.Request("getUserGifts", params, data_params) + if err != nil { + return nil, err + } + + + var res *types.OwnedGifts + return res, json.Unmarshal(r, &res) + +} + +// GetChatGifts methods's optional params +type GetChatGiftsOpts struct { + ExcludeUnsaved bool `json:"exclude_unsaved,omitempty"` + ExcludeSaved bool `json:"exclude_saved,omitempty"` + ExcludeUnlimited bool `json:"exclude_unlimited,omitempty"` + ExcludeLimitedUpgradable bool `json:"exclude_limited_upgradable,omitempty"` + ExcludeLimitedNonUpgradable bool `json:"exclude_limited_non_upgradable,omitempty"` + ExcludeFromBlockchain bool `json:"exclude_from_blockchain,omitempty"` + ExcludeUnique bool `json:"exclude_unique,omitempty"` + SortByPrice bool `json:"sort_by_price,omitempty"` + Offset string `json:"offset,omitempty"` + Limit int64 `json:"limit,omitempty"` +} + +// Returns the gifts owned by a chat. Returns OwnedGifts on success. +func (b *Bot) GetChatGifts(chatId int64, opts *GetChatGiftsOpts) (*types.OwnedGifts, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["chat_id"] = strconv.FormatInt(chatId, 10) + if opts != nil { + params["exclude_unsaved"] = strconv.FormatBool(opts.ExcludeUnsaved) + params["exclude_saved"] = strconv.FormatBool(opts.ExcludeSaved) + params["exclude_unlimited"] = strconv.FormatBool(opts.ExcludeUnlimited) + params["exclude_limited_upgradable"] = strconv.FormatBool(opts.ExcludeLimitedUpgradable) + params["exclude_limited_non_upgradable"] = strconv.FormatBool(opts.ExcludeLimitedNonUpgradable) + params["exclude_from_blockchain"] = strconv.FormatBool(opts.ExcludeFromBlockchain) + params["exclude_unique"] = strconv.FormatBool(opts.ExcludeUnique) + params["sort_by_price"] = strconv.FormatBool(opts.SortByPrice) + params["offset"] = opts.Offset + params["limit"] = strconv.FormatInt(opts.Limit, 10) + } + + + r, err := b.Request("getChatGifts", params, data_params) + if err != nil { + return nil, err + } + + + var res *types.OwnedGifts + return res, json.Unmarshal(r, &res) + +} + +// Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns True on success. +func (b *Bot) ConvertGiftToStars(businessConnectionId string, ownedGiftId string) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + params["business_connection_id"] = businessConnectionId + params["owned_gift_id"] = ownedGiftId + + r, err := b.Request("convertGiftToStars", params, data_params) + if err != nil { + return false, err + } + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// UpgradeGift methods's optional params +type UpgradeGiftOpts struct { + KeepOriginalDetails bool `json:"keep_original_details,omitempty"` + StarCount int64 `json:"star_count,omitempty"` +} + +// 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. +func (b *Bot) UpgradeGift(businessConnectionId string, ownedGiftId string, opts *UpgradeGiftOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["business_connection_id"] = businessConnectionId + params["owned_gift_id"] = ownedGiftId + if opts != nil { + params["keep_original_details"] = strconv.FormatBool(opts.KeepOriginalDetails) + params["star_count"] = strconv.FormatInt(opts.StarCount, 10) + } + + + r, err := b.Request("upgradeGift", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// TransferGift methods's optional params +type TransferGiftOpts struct { + StarCount int64 `json:"star_count,omitempty"` +} + +// 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. +func (b *Bot) TransferGift(businessConnectionId string, ownedGiftId string, newOwnerChatId int64, opts *TransferGiftOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["business_connection_id"] = businessConnectionId + params["owned_gift_id"] = ownedGiftId + params["new_owner_chat_id"] = strconv.FormatInt(newOwnerChatId, 10) + if opts != nil { + params["star_count"] = strconv.FormatInt(opts.StarCount, 10) + } + + + r, err := b.Request("transferGift", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// PostStory methods's optional params +type PostStoryOpts struct { + Caption string `json:"caption,omitempty"` + ParseMode string `json:"parse_mode,omitempty"` + CaptionEntities []types.MessageEntity `json:"caption_entities,omitempty"` + Areas []types.StoryArea `json:"areas,omitempty"` + PostToChatPage bool `json:"post_to_chat_page,omitempty"` + ProtectContent bool `json:"protect_content,omitempty"` +} + +// Posts a story on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success. +func (b *Bot) PostStory(businessConnectionId string, content *types.InputStoryContent, activePeriod int64, opts *PostStoryOpts) (*types.Story, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["business_connection_id"] = businessConnectionId + + if content != nil { + bs, err := json.Marshal(content) + if err != nil { + return nil, fmt.Errorf("failed to marshal field content: %w", err) + } + params["content"] = string(bs) + } + + params["active_period"] = strconv.FormatInt(activePeriod, 10) + if opts != nil { + params["caption"] = opts.Caption + params["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) + } + params["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) + } + params["areas"] = string(bs) + } + + params["post_to_chat_page"] = strconv.FormatBool(opts.PostToChatPage) + params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + } + + + r, err := b.Request("postStory", params, data_params) + if err != nil { + return nil, err + } + + + var res *types.Story + return res, json.Unmarshal(r, &res) + +} + +// RepostStory methods's optional params +type RepostStoryOpts struct { + PostToChatPage bool `json:"post_to_chat_page,omitempty"` + ProtectContent bool `json:"protect_content,omitempty"` +} + +// 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. +func (b *Bot) RepostStory(businessConnectionId string, fromChatId int64, fromStoryId int64, activePeriod int64, opts *RepostStoryOpts) (*types.Story, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["business_connection_id"] = businessConnectionId + params["from_chat_id"] = strconv.FormatInt(fromChatId, 10) + params["from_story_id"] = strconv.FormatInt(fromStoryId, 10) + params["active_period"] = strconv.FormatInt(activePeriod, 10) + if opts != nil { + params["post_to_chat_page"] = strconv.FormatBool(opts.PostToChatPage) + params["protect_content"] = strconv.FormatBool(opts.ProtectContent) } - r, err := b.Request("getMyShortDescription", params, data_params) + r, err := b.Request("repostStory", params, data_params) if err != nil { return nil, err } - var res *types.BotShortDescription + var res *types.Story return res, json.Unmarshal(r, &res) } -// SetChatMenuButton methods's optional params -type SetChatMenuButtonOpts struct { - ChatId int64 `json:"chat_id,omitempty"` - MenuButton *types.MenuButton `json:"menu_button,omitempty"` +// EditStory methods's optional params +type EditStoryOpts struct { + Caption string `json:"caption,omitempty"` + ParseMode string `json:"parse_mode,omitempty"` + CaptionEntities []types.MessageEntity `json:"caption_entities,omitempty"` + Areas []types.StoryArea `json:"areas,omitempty"` } -// Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success. -func (b *Bot) SetChatMenuButton(opts *SetChatMenuButtonOpts) (bool, error) { +// 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. +func (b *Bot) EditStory(businessConnectionId string, storyId int64, content *types.InputStoryContent, opts *EditStoryOpts) (*types.Story, error) { params := map[string]string{} data_params := map[string]string{} + params["business_connection_id"] = businessConnectionId + params["story_id"] = strconv.FormatInt(storyId, 10) + + if content != nil { + bs, err := json.Marshal(content) + if err != nil { + return nil, fmt.Errorf("failed to marshal field content: %w", err) + } + params["content"] = string(bs) + } + if opts != nil { - params["chat_id"] = strconv.FormatInt(opts.ChatId, 10) + params["caption"] = opts.Caption + params["parse_mode"] = opts.ParseMode - if opts.MenuButton != nil { - bs, err := json.Marshal(opts.MenuButton) + if opts.CaptionEntities != nil { + bs, err := json.Marshal(opts.CaptionEntities) if err != nil { - return false, fmt.Errorf("failed to marshal field menu_button: %w", err) + return nil, fmt.Errorf("failed to marshal field caption_entities: %w", err) } - params["menu_button"] = string(bs) + params["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) + } + params["areas"] = string(bs) } } - r, err := b.Request("setChatMenuButton", params, data_params) + r, err := b.Request("editStory", params, data_params) if err != nil { - return false, err + return nil, err } - var res bool + var res *types.Story return res, json.Unmarshal(r, &res) } -// GetChatMenuButton methods's optional params -type GetChatMenuButtonOpts struct { - ChatId int64 `json:"chat_id,omitempty"` +// 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. +func (b *Bot) DeleteStory(businessConnectionId string, storyId int64) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + params["business_connection_id"] = businessConnectionId + params["story_id"] = strconv.FormatInt(storyId, 10) + + r, err := b.Request("deleteStory", params, data_params) + if err != nil { + return false, err + } + + var res bool + return res, json.Unmarshal(r, &res) + } -// Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success. -func (b *Bot) GetChatMenuButton(opts *GetChatMenuButtonOpts) (*types.MenuButton, error) { +// Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object is returned. +func (b *Bot) AnswerWebAppQuery(webAppQueryId string, result *types.InlineQueryResult) (*types.SentWebAppMessage, error) { params := map[string]string{} data_params := map[string]string{} + params["web_app_query_id"] = webAppQueryId - if opts != nil { - params["chat_id"] = strconv.FormatInt(opts.ChatId, 10) + if result != nil { + bs, err := json.Marshal(result) + if err != nil { + return nil, fmt.Errorf("failed to marshal field result: %w", err) + } + params["result"] = string(bs) } - r, err := b.Request("getChatMenuButton", params, data_params) + r, err := b.Request("answerWebAppQuery", params, data_params) if err != nil { return nil, err } - - var res *types.MenuButton + var res *types.SentWebAppMessage return res, json.Unmarshal(r, &res) } -// SetMyDefaultAdministratorRights methods's optional params -type SetMyDefaultAdministratorRightsOpts struct { - Rights *types.ChatAdministratorRights `json:"rights,omitempty"` - ForChannels bool `json:"for_channels,omitempty"` +// SavePreparedInlineMessage methods's optional params +type SavePreparedInlineMessageOpts struct { + AllowUserChats bool `json:"allow_user_chats,omitempty"` + AllowBotChats bool `json:"allow_bot_chats,omitempty"` + AllowGroupChats bool `json:"allow_group_chats,omitempty"` + AllowChannelChats bool `json:"allow_channel_chats,omitempty"` } -// Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are free to modify the list before adding the bot. Returns True on success. -func (b *Bot) SetMyDefaultAdministratorRights(opts *SetMyDefaultAdministratorRightsOpts) (bool, error) { +// Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object. +func (b *Bot) SavePreparedInlineMessage(userId int64, result *types.InlineQueryResult, opts *SavePreparedInlineMessageOpts) (*types.PreparedInlineMessage, error) { params := map[string]string{} data_params := map[string]string{} - if opts != nil { + params["user_id"] = strconv.FormatInt(userId, 10) - if opts.Rights != nil { - bs, err := json.Marshal(opts.Rights) - if err != nil { - return false, fmt.Errorf("failed to marshal field rights: %w", err) - } - params["rights"] = string(bs) + if result != nil { + bs, err := json.Marshal(result) + if err != nil { + return nil, fmt.Errorf("failed to marshal field result: %w", err) } + params["result"] = string(bs) + } - params["for_channels"] = strconv.FormatBool(opts.ForChannels) + if opts != nil { + params["allow_user_chats"] = strconv.FormatBool(opts.AllowUserChats) + params["allow_bot_chats"] = strconv.FormatBool(opts.AllowBotChats) + params["allow_group_chats"] = strconv.FormatBool(opts.AllowGroupChats) + params["allow_channel_chats"] = strconv.FormatBool(opts.AllowChannelChats) } - r, err := b.Request("setMyDefaultAdministratorRights", params, data_params) + r, err := b.Request("savePreparedInlineMessage", params, data_params) if err != nil { - return false, err + return nil, err } - var res bool + var res *types.PreparedInlineMessage return res, json.Unmarshal(r, &res) } -// GetMyDefaultAdministratorRights methods's optional params -type GetMyDefaultAdministratorRightsOpts struct { - ForChannels bool `json:"for_channels,omitempty"` -} - -// Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success. -func (b *Bot) GetMyDefaultAdministratorRights(opts *GetMyDefaultAdministratorRightsOpts) (*types.ChatAdministratorRights, error) { +// Stores a keyboard button that can be used by a user within a Mini App. Returns a PreparedKeyboardButton object. +func (b *Bot) SavePreparedKeyboardButton(userId int64, button *types.KeyboardButton) (*types.PreparedKeyboardButton, error) { params := map[string]string{} data_params := map[string]string{} + params["user_id"] = strconv.FormatInt(userId, 10) - if opts != nil { - params["for_channels"] = strconv.FormatBool(opts.ForChannels) + if button != nil { + bs, err := json.Marshal(button) + if err != nil { + return nil, fmt.Errorf("failed to marshal field button: %w", err) + } + params["button"] = string(bs) } - r, err := b.Request("getMyDefaultAdministratorRights", params, data_params) + r, err := b.Request("savePreparedKeyboardButton", params, data_params) if err != nil { return nil, err } - - var res *types.ChatAdministratorRights + var res *types.PreparedKeyboardButton return res, json.Unmarshal(r, &res) } @@ -3245,7 +4753,7 @@ type EditMessageMediaOpts struct { ReplyMarkup *types.InlineKeyboardMarkup `json:"reply_markup,omitempty"` } -// Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. +// Use this method to edit animation, audio, document, photo, or video messages, or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. func (b *Bot) EditMessageMedia(media *types.InputMedia, opts *EditMessageMediaOpts) (*types.Message, error) { params := map[string]string{} data_params := map[string]string{} @@ -3381,6 +4889,52 @@ func (b *Bot) StopMessageLiveLocation(opts *StopMessageLiveLocationOpts) (*types } +// EditMessageChecklist methods's optional params +type EditMessageChecklistOpts struct { + ReplyMarkup *types.InlineKeyboardMarkup `json:"reply_markup,omitempty"` +} + +// Use this method to edit a checklist on behalf of a connected business account. On success, the edited Message is returned. +func (b *Bot) EditMessageChecklist(businessConnectionId string, chatId int64, messageId int64, checklist *types.InputChecklist, opts *EditMessageChecklistOpts) (*types.Message, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["business_connection_id"] = businessConnectionId + params["chat_id"] = strconv.FormatInt(chatId, 10) + params["message_id"] = strconv.FormatInt(messageId, 10) + + if checklist != nil { + bs, err := json.Marshal(checklist) + if err != nil { + return nil, fmt.Errorf("failed to marshal field checklist: %w", err) + } + params["checklist"] = string(bs) + } + + if opts != nil { + + if opts.ReplyMarkup != nil { + bs, err := json.Marshal(opts.ReplyMarkup) + if err != nil { + return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err) + } + params["reply_markup"] = string(bs) + } + + } + + + r, err := b.Request("editMessageChecklist", params, data_params) + if err != nil { + return nil, err + } + + + var res *types.Message + return res, json.Unmarshal(r, &res) + +} + // EditMessageReplyMarkup methods's optional params type EditMessageReplyMarkupOpts struct { BusinessConnectionId string `json:"business_connection_id,omitempty"` @@ -3461,6 +5015,62 @@ func (b *Bot) StopPoll(chatId int64, messageId int64, opts *StopPollOpts) (*type } +// ApproveSuggestedPost methods's optional params +type ApproveSuggestedPostOpts struct { + SendDate int64 `json:"send_date,omitempty"` +} + +// Use this method to approve a suggested post in a direct messages chat. The bot must have the 'can_post_messages' administrator right in the corresponding channel chat. Returns True on success. +func (b *Bot) ApproveSuggestedPost(chatId int64, messageId int64, opts *ApproveSuggestedPostOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["chat_id"] = strconv.FormatInt(chatId, 10) + params["message_id"] = strconv.FormatInt(messageId, 10) + if opts != nil { + params["send_date"] = strconv.FormatInt(opts.SendDate, 10) + } + + + r, err := b.Request("approveSuggestedPost", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + +// DeclineSuggestedPost methods's optional params +type DeclineSuggestedPostOpts struct { + Comment string `json:"comment,omitempty"` +} + +// Use this method to decline a suggested post in a direct messages chat. The bot must have the 'can_manage_direct_messages' administrator right in the corresponding channel chat. Returns True on success. +func (b *Bot) DeclineSuggestedPost(chatId int64, messageId int64, opts *DeclineSuggestedPostOpts) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + + params["chat_id"] = strconv.FormatInt(chatId, 10) + params["message_id"] = strconv.FormatInt(messageId, 10) + if opts != nil { + params["comment"] = opts.Comment + } + + + r, err := b.Request("declineSuggestedPost", params, data_params) + if err != nil { + return false, err + } + + + var res bool + return res, json.Unmarshal(r, &res) + +} + // Use this method to delete a message, including service messages, with the following limitations: // - A message can only be deleted if it was sent less than 48 hours ago. // - Service messages about a supergroup, channel, or forum topic creation can't be deleted. @@ -3469,7 +5079,8 @@ func (b *Bot) StopPoll(chatId int64, messageId int64, opts *StopPollOpts) (*type // - Bots can delete incoming messages in private chats. // - Bots granted can_post_messages permissions can delete outgoing messages in channels. // - If the bot is an administrator of a group, it can delete any message there. -// - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there. +// - If the bot has can_delete_messages administrator right in a supergroup or a channel, it can delete any message there. +// - If the bot has can_manage_direct_messages administrator right in a channel, it can delete any message in the corresponding direct messages chat. // Returns True on success. func (b *Bot) DeleteMessage(chatId int64, messageId int64) (bool, error) { params := map[string]string{} @@ -3516,10 +5127,13 @@ func (b *Bot) DeleteMessages(chatId int64, messageIds []int64) (bool, error) { type SendStickerOpts struct { BusinessConnectionId string `json:"business_connection_id,omitempty"` MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` Emoji string `json:"emoji,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup types.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -3548,11 +5162,22 @@ func (b *Bot) SendSticker(chatId int64, sticker types.InputFile, opts *SendStick if opts != nil { params["business_connection_id"] = opts.BusinessConnectionId params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) params["emoji"] = opts.Emoji params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + + if opts.ReplyParameters != nil { bs, err := json.Marshal(opts.ReplyParameters) if err != nil { @@ -4031,34 +5656,10 @@ func (b *Bot) AnswerInlineQuery(inlineQueryId string, results []types.InlineQuer } -// Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object is returned. -func (b *Bot) AnswerWebAppQuery(webAppQueryId string, result *types.InlineQueryResult) (*types.SentWebAppMessage, error) { - params := map[string]string{} - data_params := map[string]string{} - params["web_app_query_id"] = webAppQueryId - - if result != nil { - bs, err := json.Marshal(result) - if err != nil { - return nil, fmt.Errorf("failed to marshal field result: %w", err) - } - params["result"] = string(bs) - } - - - r, err := b.Request("answerWebAppQuery", params, data_params) - if err != nil { - return nil, err - } - - var res *types.SentWebAppMessage - return res, json.Unmarshal(r, &res) - -} - // SendInvoice methods's optional params type SendInvoiceOpts struct { MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopicId int64 `json:"direct_messages_topic_id,omitempty"` ProviderToken string `json:"provider_token,omitempty"` MaxTipAmount int64 `json:"max_tip_amount,omitempty"` SuggestedTipAmounts []int64 `json:"suggested_tip_amounts,omitempty"` @@ -4077,7 +5678,9 @@ type SendInvoiceOpts struct { IsFlexible bool `json:"is_flexible,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *types.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup *types.InlineKeyboardMarkup `json:"reply_markup,omitempty"` } @@ -4103,6 +5706,7 @@ func (b *Bot) SendInvoice(chatId int64, title string, description string, payloa if opts != nil { params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) + params["direct_messages_topic_id"] = strconv.FormatInt(opts.DirectMessagesTopicId, 10) params["provider_token"] = opts.ProviderToken params["max_tip_amount"] = strconv.FormatInt(opts.MaxTipAmount, 10) @@ -4129,8 +5733,18 @@ func (b *Bot) SendInvoice(chatId int64, title string, description string, payloa params["is_flexible"] = strconv.FormatBool(opts.IsFlexible) params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId + if opts.SuggestedPostParameters != nil { + bs, err := json.Marshal(opts.SuggestedPostParameters) + if err != nil { + return nil, fmt.Errorf("failed to marshal field suggested_post_parameters: %w", err) + } + params["suggested_post_parameters"] = string(bs) + } + + if opts.ReplyParameters != nil { bs, err := json.Marshal(opts.ReplyParameters) if err != nil { @@ -4164,7 +5778,9 @@ func (b *Bot) SendInvoice(chatId int64, title string, description string, payloa // CreateInvoiceLink methods's optional params type CreateInvoiceLinkOpts struct { + BusinessConnectionId string `json:"business_connection_id,omitempty"` ProviderToken string `json:"provider_token,omitempty"` + SubscriptionPeriod int64 `json:"subscription_period,omitempty"` MaxTipAmount int64 `json:"max_tip_amount,omitempty"` SuggestedTipAmounts []int64 `json:"suggested_tip_amounts,omitempty"` ProviderData string `json:"provider_data,omitempty"` @@ -4200,7 +5816,9 @@ func (b *Bot) CreateInvoiceLink(title string, description string, payload string } if opts != nil { + params["business_connection_id"] = opts.BusinessConnectionId params["provider_token"] = opts.ProviderToken + params["subscription_period"] = strconv.FormatInt(opts.SubscriptionPeriod, 10) params["max_tip_amount"] = strconv.FormatInt(opts.MaxTipAmount, 10) if opts.SuggestedTipAmounts != nil { @@ -4303,6 +5921,21 @@ func (b *Bot) AnswerPreCheckoutQuery(preCheckoutQueryId string, ok bool, opts *A } +// A method to get the current Telegram Stars balance of the bot. Requires no parameters. On success, returns a StarAmount object. +func (b *Bot) GetMyStarBalance() (*types.StarAmount, error) { + params := map[string]string{} + data_params := map[string]string{} + + r, err := b.Request("getMyStarBalance", params, data_params) + if err != nil { + return nil, err + } + + var res *types.StarAmount + return res, json.Unmarshal(r, &res) + +} + // GetStarTransactions methods's optional params type GetStarTransactionsOpts struct { Offset int64 `json:"offset,omitempty"` @@ -4348,6 +5981,24 @@ func (b *Bot) RefundStarPayment(userId int64, telegramPaymentChargeId string) (b } +// Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success. +func (b *Bot) EditUserStarSubscription(userId int64, telegramPaymentChargeId string, isCanceled bool) (bool, error) { + params := map[string]string{} + data_params := map[string]string{} + params["user_id"] = strconv.FormatInt(userId, 10) + params["telegram_payment_charge_id"] = telegramPaymentChargeId + params["is_canceled"] = strconv.FormatBool(isCanceled) + + r, err := b.Request("editUserStarSubscription", params, data_params) + if err != nil { + return false, err + } + + var res bool + return res, json.Unmarshal(r, &res) + +} + // Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success. // Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues. func (b *Bot) SetPassportDataErrors(userId int64, errors []types.PassportElementError) (bool, error) { @@ -4380,6 +6031,7 @@ type SendGameOpts struct { MessageThreadId int64 `json:"message_thread_id,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` MessageEffectId string `json:"message_effect_id,omitempty"` ReplyParameters *types.ReplyParameters `json:"reply_parameters,omitempty"` ReplyMarkup *types.InlineKeyboardMarkup `json:"reply_markup,omitempty"` @@ -4397,6 +6049,7 @@ func (b *Bot) SendGame(chatId int64, gameShortName string, opts *SendGameOpts) ( params["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10) params["disable_notification"] = strconv.FormatBool(opts.DisableNotification) params["protect_content"] = strconv.FormatBool(opts.ProtectContent) + params["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast) params["message_effect_id"] = opts.MessageEffectId if opts.ReplyParameters != nil { diff --git a/types/types.go b/types/types.go index 82ed21b..b4a22b3 100644 --- a/types/types.go +++ b/types/types.go @@ -38,6 +38,8 @@ type Update struct { ShippingQuery *ShippingQuery `json:"shipping_query,omitempty"` // Optional. New incoming pre-checkout query. Contains full information about checkout PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query,omitempty"` + // Optional. A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat + PurchasedPaidMedia *PaidMediaPurchased `json:"purchased_paid_media,omitempty"` // Optional. New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot Poll *Poll `json:"poll,omitempty"` // Optional. A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself. @@ -52,6 +54,8 @@ type Update struct { ChatBoost *ChatBoostUpdated `json:"chat_boost,omitempty"` // Optional. A boost was removed from a chat. The bot must be an administrator in the chat to receive these updates. RemovedChatBoost *ChatBoostRemoved `json:"removed_chat_boost,omitempty"` + // Optional. A new bot was created to be managed by the bot, or token or owner of a managed bot was changed + ManagedBot *ManagedBotUpdated `json:"managed_bot,omitempty"` } @@ -104,6 +108,14 @@ type User struct { SupportsInlineQueries bool `json:"supports_inline_queries,omitempty"` // Optional. True, if the bot can be connected to a Telegram Business account to receive its messages. Returned only in getMe. 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"` + // Optional. True, if the bot allows users to create and delete topics in private chats. Returned only in getMe. + AllowsUsersToCreateTopics bool `json:"allows_users_to_create_topics,omitempty"` + // Optional. True, if other bots can be created to be controlled by the bot. Returned only in getMe. + CanManageBots bool `json:"can_manage_bots,omitempty"` } @@ -123,6 +135,8 @@ type Chat struct { LastName string `json:"last_name,omitempty"` // Optional. True, if the supergroup chat is a forum (has topics enabled) IsForum bool `json:"is_forum,omitempty"` + // Optional. True, if the chat is the direct messages chat of a channel + IsDirectMessages bool `json:"is_direct_messages,omitempty"` } @@ -142,6 +156,8 @@ type ChatFullInfo struct { LastName string `json:"last_name,omitempty"` // Optional. True, if the supergroup chat is a forum (has topics enabled) IsForum bool `json:"is_forum,omitempty"` + // Optional. True, if the chat is the direct messages chat of a channel + IsDirectMessages bool `json:"is_direct_messages,omitempty"` // Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See accent colors for more details. AccentColorId int64 `json:"accent_color_id"` // The maximum number of reactions that can be set on a message in the chat @@ -160,6 +176,8 @@ type ChatFullInfo struct { BusinessOpeningHours *BusinessOpeningHours `json:"business_opening_hours,omitempty"` // Optional. For private chats, the personal channel of the user PersonalChat *Chat `json:"personal_chat,omitempty"` + // Optional. Information about the corresponding channel chat; for direct messages chats only + ParentChat *Chat `json:"parent_chat,omitempty"` // Optional. List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed. AvailableReactions []ReactionType `json:"available_reactions,omitempty"` // Optional. Custom emoji identifier of the emoji chosen by the chat for the reply header and link preview background @@ -190,6 +208,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 @@ -216,23 +236,35 @@ 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. For private chats, the first audio added to the profile of the user + FirstProfileAudio *Audio `json:"first_profile_audio,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"` } // This object represents a message. type Message struct { - // Unique message identifier inside this chat + // 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. Sender of the message; empty for messages sent to channels. For backward compatibility, the field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. + // Optional. Information about the direct messages chat topic that contains the message + DirectMessagesTopic *DirectMessagesTopic `json:"direct_messages_topic,omitempty"` + // Optional. Sender of the message; may be empty for messages sent to channels. For backward compatibility, if the message was sent on behalf of a chat, the field contains a fake sender user in non-channel chats From *User `json:"from,omitempty"` - // Optional. Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. For backward compatibility, the field from contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. + // Optional. Sender of the message when sent on behalf of a chat. For example, the supergroup itself for messages sent by its anonymous administrators or a linked channel for messages automatically forwarded to the channel's discussion group. For backward compatibility, if the message was sent on behalf of a chat, the field from contains a fake sender user in non-channel chats. SenderChat *Chat `json:"sender_chat,omitempty"` // Optional. If the sender of the message boosted the chat, the number of boosts added by the user SenderBoostCount int64 `json:"sender_boost_count,omitempty"` // Optional. The bot that actually sent the message on behalf of the business account. Available only for outgoing messages sent on behalf of the connected business account. SenderBusinessBot *User `json:"sender_business_bot,omitempty"` + // Optional. Tag or custom title of the sender of the message; for supergroups only + SenderTag string `json:"sender_tag,omitempty"` // Date the message was sent in Unix time. It is always a positive number, representing a valid date. Date int64 `json:"date"` // Optional. Unique identifier of the business connection from which the message was received. If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier. @@ -241,7 +273,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"` @@ -253,6 +285,10 @@ type Message struct { Quote *TextQuote `json:"quote,omitempty"` // Optional. For replies to a story, the original story ReplyToStory *Story `json:"reply_to_story,omitempty"` + // Optional. Identifier of the specific checklist task that is being replied to + ReplyToChecklistTaskId int64 `json:"reply_to_checklist_task_id,omitempty"` + // Optional. Persistent identifier of the specific poll option that is being replied to + ReplyToPollOptionId string `json:"reply_to_poll_option_id,omitempty"` // Optional. Bot through which the message was sent ViaBot *User `json:"via_bot,omitempty"` // Optional. Date the message was last edited in Unix time @@ -261,16 +297,22 @@ type Message struct { HasProtectedContent bool `json:"has_protected_content,omitempty"` // Optional. True, if the message was sent by an implicit action, for example, as an away or a greeting business message, or as a scheduled message IsFromOffline bool `json:"is_from_offline,omitempty"` - // Optional. The unique identifier of a media message group this message belongs to + // Optional. True, if the message is a paid post. Note that such posts must not be deleted for 24 hours to receive the payment and can't be edited. + IsPaidPost bool `json:"is_paid_post,omitempty"` + // Optional. The unique identifier inside this chat of a media message group this message belongs to 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 Entities []MessageEntity `json:"entities,omitempty"` // Optional. Options used for link preview generation for the message, if it is a text message and link preview options were changed LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"` + // Optional. Information about suggested post parameters if the message is a suggested post in a channel direct messages chat. If the message is an approved or declined suggested post, then it can't be edited. + SuggestedPostInfo *SuggestedPostInfo `json:"suggested_post_info,omitempty"` // Optional. Unique identifier of the message effect added to the message EffectId string `json:"effect_id,omitempty"` // Optional. Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set @@ -301,6 +343,8 @@ type Message struct { ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"` // Optional. True, if the message media is covered by a spoiler animation HasMediaSpoiler bool `json:"has_media_spoiler,omitempty"` + // Optional. Message is a checklist + Checklist *Checklist `json:"checklist,omitempty"` // Optional. Message is a shared contact, information about the contact Contact *Contact `json:"contact,omitempty"` // Optional. Message is a dice with random value @@ -317,6 +361,10 @@ type Message struct { NewChatMembers []User `json:"new_chat_members,omitempty"` // Optional. A member was removed from the group, information about them (this member may be the bot itself) LeftChatMember *User `json:"left_chat_member,omitempty"` + // Optional. Service message: chat owner has left + ChatOwnerLeft *ChatOwnerLeft `json:"chat_owner_left,omitempty"` + // Optional. Service message: chat owner has changed + ChatOwnerChanged *ChatOwnerChanged `json:"chat_owner_changed,omitempty"` // Optional. A chat title was changed to this value NewChatTitle string `json:"new_chat_title,omitempty"` // Optional. A chat photo was change to this value @@ -347,6 +395,12 @@ 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. 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 @@ -359,6 +413,12 @@ type Message struct { BoostAdded *ChatBoostAdded `json:"boost_added,omitempty"` // Optional. Service message: chat background set ChatBackgroundSet *ChatBackground `json:"chat_background_set,omitempty"` + // Optional. Service message: some tasks in a checklist were marked as done or not done + ChecklistTasksDone *ChecklistTasksDone `json:"checklist_tasks_done,omitempty"` + // Optional. Service message: tasks were added to a checklist + ChecklistTasksAdded *ChecklistTasksAdded `json:"checklist_tasks_added,omitempty"` + // Optional. Service message: the price for paid messages in the corresponding direct messages chat of a channel has changed + DirectMessagePriceChanged *DirectMessagePriceChanged `json:"direct_message_price_changed,omitempty"` // Optional. Service message: forum topic created ForumTopicCreated *ForumTopicCreated `json:"forum_topic_created,omitempty"` // Optional. Service message: forum topic edited @@ -379,6 +439,24 @@ 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: user created a bot that will be managed by the current bot + ManagedBotCreated *ManagedBotCreated `json:"managed_bot_created,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: answer option was added to a poll + PollOptionAdded *PollOptionAdded `json:"poll_option_added,omitempty"` + // Optional. Service message: answer option was deleted from a poll + PollOptionDeleted *PollOptionDeleted `json:"poll_option_deleted,omitempty"` + // Optional. Service message: a suggested post was approved + SuggestedPostApproved *SuggestedPostApproved `json:"suggested_post_approved,omitempty"` + // Optional. Service message: approval of a suggested post has failed + SuggestedPostApprovalFailed *SuggestedPostApprovalFailed `json:"suggested_post_approval_failed,omitempty"` + // Optional. Service message: a suggested post was declined + SuggestedPostDeclined *SuggestedPostDeclined `json:"suggested_post_declined,omitempty"` + // Optional. Service message: payment for a suggested post was received + SuggestedPostPaid *SuggestedPostPaid `json:"suggested_post_paid,omitempty"` + // Optional. Service message: payment for a suggested post was refunded + SuggestedPostRefunded *SuggestedPostRefunded `json:"suggested_post_refunded,omitempty"` // Optional. Service message: video chat scheduled VideoChatScheduled *VideoChatScheduled `json:"video_chat_scheduled,omitempty"` // Optional. Service message: video chat started @@ -396,7 +474,7 @@ type Message struct { // This object represents a unique message identifier. type MessageId struct { - // Unique message identifier + // Unique message identifier. 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"` } @@ -418,10 +496,12 @@ type InaccessibleMessage struct { type MaybeInaccessibleMessage struct { MessageId int64 `json:"message_id"` MessageThreadId int64 `json:"message_thread_id,omitempty"` + DirectMessagesTopic *DirectMessagesTopic `json:"direct_messages_topic,omitempty"` From *User `json:"from,omitempty"` SenderChat *Chat `json:"sender_chat,omitempty"` SenderBoostCount int64 `json:"sender_boost_count,omitempty"` SenderBusinessBot *User `json:"sender_business_bot,omitempty"` + SenderTag string `json:"sender_tag,omitempty"` Date int64 `json:"date"` BusinessConnectionId string `json:"business_connection_id,omitempty"` Chat *Chat `json:"chat"` @@ -432,15 +512,20 @@ type MaybeInaccessibleMessage struct { ExternalReply *ExternalReplyInfo `json:"external_reply,omitempty"` Quote *TextQuote `json:"quote,omitempty"` ReplyToStory *Story `json:"reply_to_story,omitempty"` + ReplyToChecklistTaskId int64 `json:"reply_to_checklist_task_id,omitempty"` + ReplyToPollOptionId string `json:"reply_to_poll_option_id,omitempty"` ViaBot *User `json:"via_bot,omitempty"` EditDate int64 `json:"edit_date,omitempty"` HasProtectedContent bool `json:"has_protected_content,omitempty"` IsFromOffline bool `json:"is_from_offline,omitempty"` + IsPaidPost bool `json:"is_paid_post,omitempty"` MediaGroupId string `json:"media_group_id,omitempty"` AuthorSignature string `json:"author_signature,omitempty"` + PaidStarCount int64 `json:"paid_star_count,omitempty"` Text string `json:"text,omitempty"` Entities []MessageEntity `json:"entities,omitempty"` LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"` + SuggestedPostInfo *SuggestedPostInfo `json:"suggested_post_info,omitempty"` EffectId string `json:"effect_id,omitempty"` Animation *Animation `json:"animation,omitempty"` Audio *Audio `json:"audio,omitempty"` @@ -456,6 +541,7 @@ type MaybeInaccessibleMessage struct { CaptionEntities []MessageEntity `json:"caption_entities,omitempty"` ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"` HasMediaSpoiler bool `json:"has_media_spoiler,omitempty"` + Checklist *Checklist `json:"checklist,omitempty"` Contact *Contact `json:"contact,omitempty"` Dice *Dice `json:"dice,omitempty"` Game *Game `json:"game,omitempty"` @@ -464,6 +550,8 @@ type MaybeInaccessibleMessage struct { Location *Location `json:"location,omitempty"` NewChatMembers []User `json:"new_chat_members,omitempty"` LeftChatMember *User `json:"left_chat_member,omitempty"` + ChatOwnerLeft *ChatOwnerLeft `json:"chat_owner_left,omitempty"` + ChatOwnerChanged *ChatOwnerChanged `json:"chat_owner_changed,omitempty"` NewChatTitle string `json:"new_chat_title,omitempty"` NewChatPhoto []PhotoSize `json:"new_chat_photo,omitempty"` DeleteChatPhoto bool `json:"delete_chat_photo,omitempty"` @@ -479,12 +567,18 @@ type MaybeInaccessibleMessage struct { RefundedPayment *RefundedPayment `json:"refunded_payment,omitempty"` UsersShared *UsersShared `json:"users_shared,omitempty"` ChatShared *ChatShared `json:"chat_shared,omitempty"` + Gift *GiftInfo `json:"gift,omitempty"` + UniqueGift *UniqueGiftInfo `json:"unique_gift,omitempty"` + GiftUpgradeSent *GiftInfo `json:"gift_upgrade_sent,omitempty"` ConnectedWebsite string `json:"connected_website,omitempty"` WriteAccessAllowed *WriteAccessAllowed `json:"write_access_allowed,omitempty"` PassportData *PassportData `json:"passport_data,omitempty"` ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered,omitempty"` BoostAdded *ChatBoostAdded `json:"boost_added,omitempty"` ChatBackgroundSet *ChatBackground `json:"chat_background_set,omitempty"` + ChecklistTasksDone *ChecklistTasksDone `json:"checklist_tasks_done,omitempty"` + ChecklistTasksAdded *ChecklistTasksAdded `json:"checklist_tasks_added,omitempty"` + DirectMessagePriceChanged *DirectMessagePriceChanged `json:"direct_message_price_changed,omitempty"` ForumTopicCreated *ForumTopicCreated `json:"forum_topic_created,omitempty"` ForumTopicEdited *ForumTopicEdited `json:"forum_topic_edited,omitempty"` ForumTopicClosed *ForumTopicClosed `json:"forum_topic_closed,omitempty"` @@ -495,6 +589,15 @@ type MaybeInaccessibleMessage struct { Giveaway *Giveaway `json:"giveaway,omitempty"` GiveawayWinners *GiveawayWinners `json:"giveaway_winners,omitempty"` GiveawayCompleted *GiveawayCompleted `json:"giveaway_completed,omitempty"` + ManagedBotCreated *ManagedBotCreated `json:"managed_bot_created,omitempty"` + PaidMessagePriceChanged *PaidMessagePriceChanged `json:"paid_message_price_changed,omitempty"` + PollOptionAdded *PollOptionAdded `json:"poll_option_added,omitempty"` + PollOptionDeleted *PollOptionDeleted `json:"poll_option_deleted,omitempty"` + SuggestedPostApproved *SuggestedPostApproved `json:"suggested_post_approved,omitempty"` + SuggestedPostApprovalFailed *SuggestedPostApprovalFailed `json:"suggested_post_approval_failed,omitempty"` + SuggestedPostDeclined *SuggestedPostDeclined `json:"suggested_post_declined,omitempty"` + SuggestedPostPaid *SuggestedPostPaid `json:"suggested_post_paid,omitempty"` + SuggestedPostRefunded *SuggestedPostRefunded `json:"suggested_post_refunded,omitempty"` VideoChatScheduled *VideoChatScheduled `json:"video_chat_scheduled,omitempty"` VideoChatStarted *VideoChatStarted `json:"video_chat_started,omitempty"` VideoChatEnded *VideoChatEnded `json:"video_chat_ended,omitempty"` @@ -506,7 +609,7 @@ type MaybeInaccessibleMessage struct { // This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc. type MessageEntity struct { - // Type of the entity. Currently, can be "mention" (@username), "hashtag" (#hashtag), "cashtag" ($USD), "bot_command" (/start@jobs_bot), "url" (https://telegram.org), "email" (do-not-reply@telegram.org), "phone_number" (+1-212-555-0123), "bold" (bold text), "italic" (italic text), "underline" (underlined text), "strikethrough" (strikethrough text), "spoiler" (spoiler message), "blockquote" (block quotation), "expandable_blockquote" (collapsed-by-default block quotation), "code" (monowidth string), "pre" (monowidth block), "text_link" (for clickable text URLs), "text_mention" (for users without usernames), "custom_emoji" (for inline custom emoji stickers) + // Type of the entity. Currently, can be "mention" (@username), "hashtag" (#hashtag or #hashtag@chatusername), "cashtag" ($USD or $USD@chatusername), "bot_command" (/start@jobs_bot), "url" (https://telegram.org), "email" (do-not-reply@telegram.org), "phone_number" (+1-212-555-0123), "bold" (bold text), "italic" (italic text), "underline" (underlined text), "strikethrough" (strikethrough text), "spoiler" (spoiler message), "blockquote" (block quotation), "expandable_blockquote" (collapsed-by-default block quotation), "code" (monowidth string), "pre" (monowidth block), "text_link" (for clickable text URLs), "text_mention" (for users without usernames), "custom_emoji" (for inline custom emoji stickers), or "date_time" (for formatted date and time) Type string `json:"type"` // Offset in UTF-16 code units to the start of the entity Offset int64 `json:"offset"` @@ -520,6 +623,10 @@ type MessageEntity struct { Language string `json:"language,omitempty"` // Optional. For "custom_emoji" only, unique identifier of the custom emoji. Use getCustomEmojiStickers to get full information about the sticker CustomEmojiId string `json:"custom_emoji_id,omitempty"` + // Optional. For "date_time" only, the Unix time associated with the entity + UnixTime int64 `json:"unix_time,omitempty"` + // Optional. For "date_time" only, the string that defines the formatting of the date and time. See date-time entity formatting for more details. + DateTimeFormat string `json:"date_time_format,omitempty"` } @@ -527,7 +634,7 @@ type MessageEntity struct { type TextQuote struct { // Text of the quoted part of a message that is replied to by the given message Text string `json:"text"` - // Optional. Special entities that appear in the quote. Currently, only bold, italic, underline, strikethrough, spoiler, and custom_emoji entities are kept in quotes. + // Optional. Special entities that appear in the quote. Currently, only bold, italic, underline, strikethrough, spoiler, custom_emoji, and date_time entities are kept in quotes. Entities []MessageEntity `json:"entities,omitempty"` // Approximate quote position in the original message in UTF-16 code units as specified by the sender Position int64 `json:"position"` @@ -568,6 +675,8 @@ type ExternalReplyInfo struct { Voice *Voice `json:"voice,omitempty"` // Optional. True, if the message media is covered by a spoiler animation HasMediaSpoiler bool `json:"has_media_spoiler,omitempty"` + // Optional. Message is a checklist + Checklist *Checklist `json:"checklist,omitempty"` // Optional. Message is a shared contact, information about the contact Contact *Contact `json:"contact,omitempty"` // Optional. Message is a dice with random value @@ -593,11 +702,11 @@ type ExternalReplyInfo struct { type ReplyParameters struct { // Identifier of the message that will be replied to in the current chat, or in the chat chat_id if it is specified MessageId int64 `json:"message_id"` - // Optional. If the message to be replied to is from a different chat, unique identifier for the chat or username of the channel (in the format @channelusername). Not supported for messages sent on behalf of a business account. + // Optional. If the message to be replied to is from a different chat, unique identifier for the chat or username of the channel (in the format @channelusername). Not supported for messages sent on behalf of a business account and messages from channel direct messages chats. ChatId int64 `json:"chat_id,omitempty"` // Optional. Pass True if the message should be sent even if the specified message to be replied to is not found. Always False for replies in another chat or forum topic. Always True for messages sent on behalf of a business account. AllowSendingWithoutReply bool `json:"allow_sending_without_reply,omitempty"` - // Optional. Quoted part of the message to be replied to; 0-1024 characters after entities parsing. The quote must be an exact substring of the message to be replied to, including bold, italic, underline, strikethrough, spoiler, and custom_emoji entities. The message will fail to send if the quote isn't found in the original message. + // Optional. Quoted part of the message to be replied to; 0-1024 characters after entities parsing. The quote must be an exact substring of the message to be replied to, including bold, italic, underline, strikethrough, spoiler, custom_emoji, and date_time entities. The message will fail to send if the quote isn't found in the original message. Quote string `json:"quote,omitempty"` // Optional. Mode for parsing entities in the quote. See formatting options for more details. QuoteParseMode string `json:"quote_parse_mode,omitempty"` @@ -605,6 +714,10 @@ type ReplyParameters struct { QuoteEntities []MessageEntity `json:"quote_entities,omitempty"` // Optional. Position of the quote in the original message in UTF-16 code units QuotePosition int64 `json:"quote_position,omitempty"` + // Optional. Identifier of the specific checklist task to be replied to + ChecklistTaskId int64 `json:"checklist_task_id,omitempty"` + // Optional. Persistent identifier of the specific poll option to be replied to + PollOptionId string `json:"poll_option_id,omitempty"` } @@ -774,6 +887,23 @@ type Story struct { } +// This object represents a video file of a specific quality. +type VideoQuality struct { + // Identifier for this file, which can be used to download or reuse the file + FileId string `json:"file_id"` + // Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + FileUniqueId string `json:"file_unique_id"` + // Video width + Width int64 `json:"width"` + // Video height + Height int64 `json:"height"` + // Codec that was used to encode the video, for example, "h264", "h265", or "av01" + Codec string `json:"codec"` + // Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value. + FileSize int64 `json:"file_size,omitempty"` +} + + // This object represents a video file. type Video struct { // Identifier for this file, which can be used to download or reuse the file @@ -788,6 +918,12 @@ 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. List of available qualities of the video + Qualities []VideoQuality `json:"qualities,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 @@ -918,12 +1054,20 @@ type Dice struct { // This object contains information about one answer option in a poll. type PollOption struct { + // Unique identifier of the option, persistent on option addition and deletion + PersistentId string `json:"persistent_id"` // Option text, 1-100 characters Text string `json:"text"` // Optional. Special entities that appear in the option text. Currently, only custom emoji entities are allowed in poll option texts TextEntities []MessageEntity `json:"text_entities,omitempty"` - // Number of users that voted for this option + // Number of users who voted for this option; may be 0 if unknown VoterCount int64 `json:"voter_count"` + // Optional. User who added the option; omitted if the option wasn't added by a user after poll creation + AddedByUser *User `json:"added_by_user,omitempty"` + // Optional. Chat that added the option; omitted if the option wasn't added by a chat after poll creation + AddedByChat *Chat `json:"added_by_chat,omitempty"` + // Optional. Point in time (Unix timestamp) when the option was added; omitted if the option existed in the original poll + AdditionDate int64 `json:"addition_date,omitempty"` } @@ -948,6 +1092,8 @@ type PollAnswer struct { User *User `json:"user,omitempty"` // 0-based identifiers of chosen answer options. May be empty if the vote was retracted. OptionIds []int64 `json:"option_ids"` + // Persistent identifiers of the chosen answer options. May be empty if the vote was retracted. + OptionPersistentIds []string `json:"option_persistent_ids"` } @@ -971,8 +1117,10 @@ type Poll struct { Type string `json:"type"` // True, if the poll allows multiple answers AllowsMultipleAnswers bool `json:"allows_multiple_answers"` - // Optional. 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot. - CorrectOptionId int64 `json:"correct_option_id,omitempty"` + // True, if the poll allows to change the chosen answer options + AllowsRevoting bool `json:"allows_revoting"` + // Optional. Array of 0-based identifiers of the correct answer options. Available only for polls in quiz mode which are closed or were sent (not forwarded) by the bot or to the private chat with the bot. + CorrectOptionIds []int64 `json:"correct_option_ids,omitempty"` // Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters Explanation string `json:"explanation,omitempty"` // Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the explanation @@ -981,6 +1129,92 @@ type Poll struct { OpenPeriod int64 `json:"open_period,omitempty"` // Optional. Point in time (Unix timestamp) when the poll will be automatically closed CloseDate int64 `json:"close_date,omitempty"` + // Optional. Description of the poll; for polls inside the Message object only + Description string `json:"description,omitempty"` + // Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the description + DescriptionEntities []MessageEntity `json:"description_entities,omitempty"` +} + + +// Describes a task in a checklist. +type ChecklistTask struct { + // Unique identifier of the task + Id int64 `json:"id"` + // Text of the task + 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 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"` +} + + +// Describes a checklist. +type Checklist struct { + // Title of the checklist + Title string `json:"title"` + // Optional. Special entities that appear in the checklist title + TitleEntities []MessageEntity `json:"title_entities,omitempty"` + // List of tasks in the checklist + Tasks []ChecklistTask `json:"tasks"` + // Optional. True, if users other than the creator of the list can add tasks to the list + OthersCanAddTasks bool `json:"others_can_add_tasks,omitempty"` + // Optional. True, if users other than the creator of the list can mark tasks as done or not done + OthersCanMarkTasksAsDone bool `json:"others_can_mark_tasks_as_done,omitempty"` +} + + +// Describes a task to add to a checklist. +type InputChecklistTask struct { + // Unique identifier of the task; must be positive and unique among all task identifiers currently present in the checklist + Id int64 `json:"id"` + // Text of the task; 1-100 characters after entities parsing + Text string `json:"text"` + // Optional. Mode for parsing entities in the text. See formatting options for more details. + ParseMode string `json:"parse_mode,omitempty"` + // Optional. List of special entities that appear in the text, which can be specified instead of parse_mode. Currently, only bold, italic, underline, strikethrough, spoiler, custom_emoji, and date_time entities are allowed. + TextEntities []MessageEntity `json:"text_entities,omitempty"` +} + + +// Describes a checklist to create. +type InputChecklist struct { + // Title of the checklist; 1-255 characters after entities parsing + Title string `json:"title"` + // Optional. Mode for parsing entities in the title. See formatting options for more details. + ParseMode string `json:"parse_mode,omitempty"` + // Optional. List of special entities that appear in the title, which can be specified instead of parse_mode. Currently, only bold, italic, underline, strikethrough, spoiler, custom_emoji, and date_time entities are allowed. + TitleEntities []MessageEntity `json:"title_entities,omitempty"` + // List of 1-30 tasks in the checklist + Tasks []InputChecklistTask `json:"tasks"` + // Optional. Pass True if other users can add tasks to the checklist + OthersCanAddTasks bool `json:"others_can_add_tasks,omitempty"` + // Optional. Pass True if other users can mark tasks as done or not done in the checklist + OthersCanMarkTasksAsDone bool `json:"others_can_mark_tasks_as_done,omitempty"` +} + + +// Describes a service message about checklist tasks marked as done or not done. +type ChecklistTasksDone struct { + // Optional. Message containing the checklist whose tasks were marked as done or not done. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. + ChecklistMessage *Message `json:"checklist_message,omitempty"` + // Optional. Identifiers of the tasks that were marked as done + MarkedAsDoneTaskIds []int64 `json:"marked_as_done_task_ids,omitempty"` + // Optional. Identifiers of the tasks that were marked as not done + MarkedAsNotDoneTaskIds []int64 `json:"marked_as_not_done_task_ids,omitempty"` +} + + +// Describes a service message about tasks added to a checklist. +type ChecklistTasksAdded struct { + // Optional. Message containing the checklist to which the tasks were added. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. + ChecklistMessage *Message `json:"checklist_message,omitempty"` + // List of tasks added to the checklist + Tasks []ChecklistTask `json:"tasks"` } @@ -1047,6 +1281,48 @@ type MessageAutoDeleteTimerChanged struct { } +// This object contains information about the bot that was created to be managed by the current bot. +type ManagedBotCreated struct { + // Information about the bot. The bot's token can be fetched using the method getManagedBotToken. + Bot *User `json:"bot"` +} + + +// This object contains information about the creation, token update, or owner update of a bot that is managed by the current bot. +type ManagedBotUpdated struct { + // User that created the bot + User *User `json:"user"` + // Information about the bot. Token of the bot can be fetched using the method getManagedBotToken. + Bot *User `json:"bot"` +} + + +// Describes a service message about an option added to a poll. +type PollOptionAdded struct { + // Optional. Message containing the poll to which the option was added, if known. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. + PollMessage *MaybeInaccessibleMessage `json:"poll_message,omitempty"` + // Unique identifier of the added option + OptionPersistentId string `json:"option_persistent_id"` + // Option text + OptionText string `json:"option_text"` + // Optional. Special entities that appear in the option_text + OptionTextEntities []MessageEntity `json:"option_text_entities,omitempty"` +} + + +// Describes a service message about an option deleted from a poll. +type PollOptionDeleted struct { + // Optional. Message containing the poll from which the option was deleted, if known. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. + PollMessage *MaybeInaccessibleMessage `json:"poll_message,omitempty"` + // Unique identifier of the deleted option + OptionPersistentId string `json:"option_persistent_id"` + // Option text + OptionText string `json:"option_text"` + // Optional. Special entities that appear in the option_text + OptionTextEntities []MessageEntity `json:"option_text_entities,omitempty"` +} + + // This object represents a service message about a user boosting a chat. type ChatBoostAdded struct { // Number of boosts added by the user @@ -1158,7 +1434,7 @@ func (v BackgroundTypeWallpaper) GetBackgroundType() BackgroundTypeWallpaper { return v } -// 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 { // Type of the background, always "pattern" Type string `json:"type"` @@ -1205,6 +1481,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"` } @@ -1318,9 +1596,77 @@ type VideoChatParticipantsInvited struct { } -// This object represents a service message about the creation of a scheduled giveaway. Currently holds no information. -type GiveawayCreated interface { +// 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"` +} + + +// Describes a service message about a change in the price of direct messages sent to a channel chat. +type DirectMessagePriceChanged struct { + // True, if direct messages are enabled for the channel chat; false otherwise + AreDirectMessagesEnabled bool `json:"are_direct_messages_enabled"` + // Optional. The new number of Telegram Stars that must be paid by users for each direct message sent to the channel. Does not apply to users who have been exempted by administrators. Defaults to 0. + DirectMessageStarCount int64 `json:"direct_message_star_count,omitempty"` +} + + +// Describes a service message about the approval of a suggested post. +type SuggestedPostApproved struct { + // Optional. Message containing the suggested post. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. + SuggestedPostMessage *Message `json:"suggested_post_message,omitempty"` + // Optional. Amount paid for the post + Price *SuggestedPostPrice `json:"price,omitempty"` + // Date when the post will be published + SendDate int64 `json:"send_date"` +} + + +// Describes a service message about the failed approval of a suggested post. Currently, only caused by insufficient user funds at the time of approval. +type SuggestedPostApprovalFailed struct { + // Optional. Message containing the suggested post whose approval has failed. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. + SuggestedPostMessage *Message `json:"suggested_post_message,omitempty"` + // Expected price of the post + Price *SuggestedPostPrice `json:"price"` +} + + +// Describes a service message about the rejection of a suggested post. +type SuggestedPostDeclined struct { + // Optional. Message containing the suggested post. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. + SuggestedPostMessage *Message `json:"suggested_post_message,omitempty"` + // Optional. Comment with which the post was declined + Comment string `json:"comment,omitempty"` +} + + +// Describes a service message about a successful payment for a suggested post. +type SuggestedPostPaid struct { + // Optional. Message containing the suggested post. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. + SuggestedPostMessage *Message `json:"suggested_post_message,omitempty"` + // Currency in which the payment was made. Currently, one of "XTR" for Telegram Stars or "TON" for toncoins + Currency string `json:"currency"` + // Optional. The amount of the currency that was received by the channel in nanotoncoins; for payments in toncoins only + Amount int64 `json:"amount,omitempty"` + // Optional. The amount of Telegram Stars that was received by the channel; for payments in Telegram Stars only + StarAmount *StarAmount `json:"star_amount,omitempty"` +} + +// Describes a service message about a payment refund for a suggested post. +type SuggestedPostRefunded struct { + // Optional. Message containing the suggested post. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. + SuggestedPostMessage *Message `json:"suggested_post_message,omitempty"` + // Reason for the refund. Currently, one of "post_deleted" if the post was deleted within 24 hours of being posted or removed from scheduled messages without being posted, or "payment_refunded" if the payer refunded their payment. + Reason string `json:"reason"` +} + + +// This object represents a service message about the creation of a scheduled giveaway. +type GiveawayCreated struct { + // Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only + PrizeStarCount int64 `json:"prize_star_count,omitempty"` } @@ -1340,7 +1686,9 @@ type Giveaway struct { PrizeDescription string `json:"prize_description,omitempty"` // Optional. A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users for the giveaway must come. If empty, then all users can participate in the giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways. CountryCodes []string `json:"country_codes,omitempty"` - // Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for + // Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only + PrizeStarCount int64 `json:"prize_star_count,omitempty"` + // Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only PremiumSubscriptionMonthCount int64 `json:"premium_subscription_month_count,omitempty"` } @@ -1359,7 +1707,9 @@ type GiveawayWinners struct { Winners []User `json:"winners"` // Optional. The number of other chats the user had to join in order to be eligible for the giveaway AdditionalChatCount int64 `json:"additional_chat_count,omitempty"` - // Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for + // Optional. The number of Telegram Stars that were split between giveaway winners; for Telegram Star giveaways only + PrizeStarCount int64 `json:"prize_star_count,omitempty"` + // Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only PremiumSubscriptionMonthCount int64 `json:"premium_subscription_month_count,omitempty"` // Optional. Number of undistributed prizes UnclaimedPrizeCount int64 `json:"unclaimed_prize_count,omitempty"` @@ -1380,6 +1730,8 @@ type GiveawayCompleted struct { UnclaimedPrizeCount int64 `json:"unclaimed_prize_count,omitempty"` // Optional. Message with the giveaway that was completed, if it wasn't deleted GiveawayMessage *Message `json:"giveaway_message,omitempty"` + // Optional. True, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway. + IsStarGiveaway bool `json:"is_star_giveaway,omitempty"` } @@ -1398,6 +1750,44 @@ type LinkPreviewOptions struct { } +// 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"` + // The amount of the currency that will be paid for the post in the smallest units of the currency, i.e. Telegram Stars or nanotoncoins. Currently, price in Telegram Stars must be between 5 and 100000, and price in nanotoncoins must be between 10000000 and 10000000000000. + Amount int64 `json:"amount"` +} + + +// Contains information about a suggested post. +type SuggestedPostInfo struct { + // State of the suggested post. Currently, it can be one of "pending", "approved", "declined". + State string `json:"state"` + // Optional. Proposed price of the post. If the field is omitted, then the post is unpaid. + Price *SuggestedPostPrice `json:"price,omitempty"` + // Optional. Proposed send date of the post. If the field is omitted, then the post can be published at any time within 30 days at the sole discretion of the user or administrator who approves it. + SendDate int64 `json:"send_date,omitempty"` +} + + +// Contains parameters of a post that is being suggested by the bot. +type SuggestedPostParameters struct { + // Optional. Proposed price for the post. If the field is omitted, then the post is unpaid. + Price *SuggestedPostPrice `json:"price,omitempty"` + // Optional. Proposed send date of the post. If specified, then the date must be between 300 second and 2678400 seconds (30 days) in the future. If the field is omitted, then the post can be published at any time within 30 days at the sole discretion of the user who approves it. + SendDate int64 `json:"send_date,omitempty"` +} + + +// Describes a topic of a direct messages chat. +type DirectMessagesTopic struct { + // 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"` +} + + // This object represent a user's profile pictures. type UserProfilePhotos struct { // Total number of profile pictures the target user has @@ -1407,6 +1797,15 @@ type UserProfilePhotos struct { } +// This object represents the audios displayed on a user's profile. +type UserProfileAudios struct { + // Total number of profile audios for the target user + TotalCount int64 `json:"total_count"` + // Requested profile audios + Audios []Audio `json:"audios"` +} + + // This object represents a file ready to be downloaded. The file can be downloaded via the link https://api.telegram.org/file/bot/. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile. type File struct { // Identifier for this file, which can be used to download or reuse the file @@ -1446,15 +1845,20 @@ type ReplyKeyboardMarkup struct { func (m ReplyKeyboardMarkup) replyMarkup() {} -// This object represents one button of the reply keyboard. At most one of the optional fields must be used to specify type of the button. For simple text buttons, String can be used instead of this object to specify the button text. -// Note: request_users and request_chat options will only work in Telegram versions released after 3 February, 2023. Older clients will display unsupported message. +// This object represents one button of the reply keyboard. At most one of the fields other than text, icon_custom_emoji_id, and style must be used to specify the type of the button. For simple text buttons, String can be used instead of this object to specify the button text. type KeyboardButton struct { - // Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed + // Text of the button. If none of the fields other than text, icon_custom_emoji_id, and style are used, it will be sent as a message when the button is pressed Text string `json:"text"` + // Optional. Unique identifier of the custom emoji shown before the text of the button. Can only be used by bots that purchased additional usernames on Fragment or in the messages directly sent by the bot to private, group and supergroup chats if the owner of the bot has a Telegram Premium subscription. + IconCustomEmojiId string `json:"icon_custom_emoji_id,omitempty"` + // Optional. Style of the button. Must be one of "danger" (red), "success" (green) or "primary" (blue). If omitted, then an app-specific style is used. + Style string `json:"style,omitempty"` // Optional. If specified, pressing the button will open a list of suitable users. Identifiers of selected users will be sent to the bot in a "users_shared" service message. Available in private chats only. RequestUsers *KeyboardButtonRequestUsers `json:"request_users,omitempty"` // Optional. If specified, pressing the button will open a list of suitable chats. Tapping on a chat will send its identifier to the bot in a "chat_shared" service message. Available in private chats only. RequestChat *KeyboardButtonRequestChat `json:"request_chat,omitempty"` + // Optional. If specified, pressing the button will ask the user to create and share a bot that will be managed by the current bot. Available for bots that enabled management of other bots in the @BotFather Mini App. Available in private chats only. + RequestManagedBot *KeyboardButtonRequestManagedBot `json:"request_managed_bot,omitempty"` // Optional. If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only. RequestContact bool `json:"request_contact,omitempty"` // Optional. If True, the user's current location will be sent when the button is pressed. Available in private chats only. @@ -1512,6 +1916,17 @@ type KeyboardButtonRequestChat struct { } +// This object defines the parameters for the creation of a managed bot. Information about the created bot will be shared with the bot using the update managed_bot and a Message with the field managed_bot_created. +type KeyboardButtonRequestManagedBot struct { + // Signed 32-bit identifier of the request. Must be unique within the message + RequestId int64 `json:"request_id"` + // Optional. Suggested name for the bot + SuggestedName string `json:"suggested_name,omitempty"` + // Optional. Suggested username for the bot + SuggestedUsername string `json:"suggested_username,omitempty"` +} + + // This object represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed. type KeyboardButtonPollType struct { // Optional. If quiz is passed, the user will be allowed to create only polls in the quiz mode. If regular is passed, only regular polls will be allowed. Otherwise, the user will be allowed to create a poll of any type. @@ -1539,10 +1954,14 @@ type InlineKeyboardMarkup struct { func (m InlineKeyboardMarkup) replyMarkup() {} -// This object represents one button of an inline keyboard. Exactly one of the optional fields must be used to specify type of the button. +// This object represents one button of an inline keyboard. Exactly one of the fields other than text, icon_custom_emoji_id, and style must be used to specify the type of the button. type InlineKeyboardButton struct { // Label text on the button Text string `json:"text"` + // Optional. Unique identifier of the custom emoji shown before the text of the button. Can only be used by bots that purchased additional usernames on Fragment or in the messages directly sent by the bot to private, group and supergroup chats if the owner of the bot has a Telegram Premium subscription. + IconCustomEmojiId string `json:"icon_custom_emoji_id,omitempty"` + // Optional. Style of the button. Must be one of "danger" (red), "success" (green) or "primary" (blue). If omitted, then an app-specific style is used. + Style string `json:"style,omitempty"` // Optional. HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?id= can be used to mention a user by their identifier without using a username, if this is allowed by their privacy settings. Url string `json:"url,omitempty"` // Optional. Data to be sent in a callback query to the bot when the button is pressed, 1-64 bytes @@ -1551,12 +1970,14 @@ type InlineKeyboardButton struct { WebApp *WebAppInfo `json:"web_app,omitempty"` // Optional. An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget. LoginUrl *LoginUrl `json:"login_url,omitempty"` - // Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted. Not supported for messages sent on behalf of a Telegram Business account. + // Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted. Not supported for messages sent in channel direct messages chats and on behalf of a Telegram Business account. SwitchInlineQuery string `json:"switch_inline_query,omitempty"` - // Optional. If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. May be empty, in which case only the bot's username will be inserted. This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting something from multiple options. Not supported in channels and for messages sent on behalf of a Telegram Business account. + // Optional. If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. May be empty, in which case only the bot's username will be inserted. This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting something from multiple options. Not supported in channels and for messages sent in channel direct messages chats and on behalf of a Telegram Business account. SwitchInlineQueryCurrentChat string `json:"switch_inline_query_current_chat,omitempty"` - // Optional. If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field. Not supported for messages sent on behalf of a Telegram Business account. + // Optional. If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field. Not supported for messages sent in channel direct messages chats and on behalf of a Telegram Business account. SwitchInlineQueryChosenChat *SwitchInlineQueryChosenChat `json:"switch_inline_query_chosen_chat,omitempty"` + // Optional. Description of the button that copies the specified text to the clipboard. + CopyText *CopyTextButton `json:"copy_text,omitempty"` // Optional. Description of the game that will be launched when the user presses the button. NOTE: This type of button must always be the first button in the first row. CallbackGame *CallbackGame `json:"callback_game,omitempty"` // Optional. Specify True, to send a Pay button. Substrings "โญ" and "XTR" in the buttons's text will be replaced with a Telegram Star icon. NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages. @@ -1593,6 +2014,13 @@ type SwitchInlineQueryChosenChat struct { } +// This object represents an inline keyboard button that copies specified text to the clipboard. +type CopyTextButton struct { + // The text to be copied to the clipboard; 1-256 characters + Text string `json:"text"` +} + + // This object represents an incoming callback query from a callback button in an inline keyboard. If the button that originated the query was attached to a message sent by the bot, the field message will be present. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be present. Exactly one of the fields data or game_short_name will be present. type CallbackQuery struct { // Unique identifier for this query @@ -1658,6 +2086,10 @@ type ChatInviteLink struct { MemberLimit int64 `json:"member_limit,omitempty"` // Optional. Number of pending join requests created using this link PendingJoinRequestCount int64 `json:"pending_join_request_count,omitempty"` + // Optional. The number of seconds the subscription will be active for before the next payment + SubscriptionPeriod int64 `json:"subscription_period,omitempty"` + // Optional. The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat using the link + SubscriptionPrice int64 `json:"subscription_price,omitempty"` } @@ -1665,7 +2097,7 @@ type ChatInviteLink struct { type ChatAdministratorRights struct { // True, if the user's presence in the chat is hidden IsAnonymous bool `json:"is_anonymous"` - // True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages and ignore slow mode. Implied by any other administrator privilege. + // True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages, ignore slow mode, and send messages to the chat without paying Telegram Stars. Implied by any other administrator privilege. CanManageChat bool `json:"can_manage_chat"` // True, if the administrator can delete messages of other users CanDeleteMessages bool `json:"can_delete_messages"` @@ -1685,7 +2117,7 @@ type ChatAdministratorRights struct { CanEditStories bool `json:"can_edit_stories"` // True, if the administrator can delete stories posted by other users CanDeleteStories bool `json:"can_delete_stories"` - // Optional. True, if the administrator can post messages in the channel, or access channel statistics; for channels only + // Optional. True, if the administrator can post messages in the channel, approve suggested posts, or access channel statistics; for channels only CanPostMessages bool `json:"can_post_messages,omitempty"` // Optional. True, if the administrator can edit messages of other users and can pin messages; for channels only CanEditMessages bool `json:"can_edit_messages,omitempty"` @@ -1693,6 +2125,10 @@ type ChatAdministratorRights struct { CanPinMessages bool `json:"can_pin_messages,omitempty"` // Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only CanManageTopics bool `json:"can_manage_topics,omitempty"` + // Optional. True, if the administrator can manage direct messages of the channel and decline suggested posts; for channels only + CanManageDirectMessages bool `json:"can_manage_direct_messages,omitempty"` + // Optional. True, if the administrator can edit the tags of regular members; for groups and supergroups only. If omitted defaults to the value of can_pin_messages. + CanManageTags bool `json:"can_manage_tags,omitempty"` } @@ -1744,6 +2180,10 @@ type ChatMember struct { CanEditMessages bool `json:"can_edit_messages,omitempty"` CanPinMessages bool `json:"can_pin_messages,omitempty"` CanManageTopics bool `json:"can_manage_topics,omitempty"` + CanManageDirectMessages bool `json:"can_manage_direct_messages,omitempty"` + CanManageTags bool `json:"can_manage_tags,omitempty"` + Tag string `json:"tag,omitempty"` + UntilDate int64 `json:"until_date,omitempty"` IsMember bool `json:"is_member"` CanSendMessages bool `json:"can_send_messages"` CanSendAudios bool `json:"can_send_audios"` @@ -1755,7 +2195,7 @@ type ChatMember struct { CanSendPolls bool `json:"can_send_polls"` CanSendOtherMessages bool `json:"can_send_other_messages"` CanAddWebPagePreviews bool `json:"can_add_web_page_previews"` - UntilDate int64 `json:"until_date"` + CanEditTag bool `json:"can_edit_tag"` } @@ -1785,7 +2225,7 @@ type ChatMemberAdministrator struct { CanBeEdited bool `json:"can_be_edited"` // True, if the user's presence in the chat is hidden IsAnonymous bool `json:"is_anonymous"` - // True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages and ignore slow mode. Implied by any other administrator privilege. + // True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages, ignore slow mode, and send messages to the chat without paying Telegram Stars. Implied by any other administrator privilege. CanManageChat bool `json:"can_manage_chat"` // True, if the administrator can delete messages of other users CanDeleteMessages bool `json:"can_delete_messages"` @@ -1805,7 +2245,7 @@ type ChatMemberAdministrator struct { CanEditStories bool `json:"can_edit_stories"` // True, if the administrator can delete stories posted by other users CanDeleteStories bool `json:"can_delete_stories"` - // Optional. True, if the administrator can post messages in the channel, or access channel statistics; for channels only + // Optional. True, if the administrator can post messages in the channel, approve suggested posts, or access channel statistics; for channels only CanPostMessages bool `json:"can_post_messages,omitempty"` // Optional. True, if the administrator can edit messages of other users and can pin messages; for channels only CanEditMessages bool `json:"can_edit_messages,omitempty"` @@ -1813,6 +2253,10 @@ type ChatMemberAdministrator struct { CanPinMessages bool `json:"can_pin_messages,omitempty"` // Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only CanManageTopics bool `json:"can_manage_topics,omitempty"` + // Optional. True, if the administrator can manage direct messages of the channel and decline suggested posts; for channels only + CanManageDirectMessages bool `json:"can_manage_direct_messages,omitempty"` + // Optional. True, if the administrator can edit the tags of regular members; for groups and supergroups only. If omitted defaults to the value of can_pin_messages. + CanManageTags bool `json:"can_manage_tags,omitempty"` // Optional. Custom title for this user CustomTitle string `json:"custom_title,omitempty"` } @@ -1825,8 +2269,12 @@ func (v ChatMemberAdministrator) GetChatMember() ChatMemberAdministrator { type ChatMemberMember struct { // The member's status in the chat, always "member" Status string `json:"status"` + // Optional. Tag of the member + Tag string `json:"tag,omitempty"` // Information about the user User *User `json:"user"` + // Optional. Date when the user's subscription will expire; Unix time + UntilDate int64 `json:"until_date,omitempty"` } func (v ChatMemberMember) GetChatMember() ChatMemberMember { @@ -1837,6 +2285,8 @@ func (v ChatMemberMember) GetChatMember() ChatMemberMember { type ChatMemberRestricted struct { // The member's status in the chat, always "restricted" Status string `json:"status"` + // Optional. Tag of the member + Tag string `json:"tag,omitempty"` // Information about the user User *User `json:"user"` // True, if the user is a member of the chat at the moment of the request @@ -1855,12 +2305,14 @@ type ChatMemberRestricted struct { CanSendVideoNotes bool `json:"can_send_video_notes"` // True, if the user is allowed to send voice notes CanSendVoiceNotes bool `json:"can_send_voice_notes"` - // True, if the user is allowed to send polls + // True, if the user is allowed to send polls and checklists CanSendPolls bool `json:"can_send_polls"` // True, if the user is allowed to send animations, games, stickers and use inline bots CanSendOtherMessages bool `json:"can_send_other_messages"` // True, if the user is allowed to add web page previews to their messages CanAddWebPagePreviews bool `json:"can_add_web_page_previews"` + // True, if the user is allowed to edit their own tag + CanEditTag bool `json:"can_edit_tag"` // True, if the user is allowed to change the chat title, photo and other settings CanChangeInfo bool `json:"can_change_info"` // True, if the user is allowed to invite new users to the chat @@ -1936,12 +2388,14 @@ type ChatPermissions struct { CanSendVideoNotes bool `json:"can_send_video_notes,omitempty"` // Optional. True, if the user is allowed to send voice notes CanSendVoiceNotes bool `json:"can_send_voice_notes,omitempty"` - // Optional. True, if the user is allowed to send polls + // Optional. True, if the user is allowed to send polls and checklists CanSendPolls bool `json:"can_send_polls,omitempty"` // Optional. True, if the user is allowed to send animations, games, stickers and use inline bots CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"` // Optional. True, if the user is allowed to add web page previews to their messages CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"` + // Optional. True, if the user is allowed to edit their own tag + CanEditTag bool `json:"can_edit_tag,omitempty"` // Optional. True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups CanChangeInfo bool `json:"can_change_info,omitempty"` // Optional. True, if the user is allowed to invite new users to the chat @@ -2002,6 +2456,152 @@ type BusinessOpeningHours struct { } +// 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"` +} + + +// 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"` +} + + +// 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"` +} + + +// Describes the type of a clickable area on a story. Currently, it can be one of +// - StoryAreaTypeLocation +// - StoryAreaTypeSuggestedReaction +// - StoryAreaTypeLink +// - StoryAreaTypeWeather +// - StoryAreaTypeUniqueGift +type StoryAreaType struct { + Type string `json:"type"` + Latitude float64 `json:"latitude"` + Longitude float64 `json:"longitude"` + Address *LocationAddress `json:"address,omitempty"` + ReactionType *ReactionType `json:"reaction_type"` + IsDark bool `json:"is_dark,omitempty"` + IsFlipped bool `json:"is_flipped,omitempty"` + Url string `json:"url"` + Temperature float64 `json:"temperature"` + Emoji string `json:"emoji"` + BackgroundColor int64 `json:"background_color"` + Name string `json:"name"` +} + + +// Describes a story area pointing to a location. Currently, a story can have up to 10 location areas. +type StoryAreaTypeLocation struct { + // Type of the area, always "location" + Type string `json:"type"` + // 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"` +} + +func (v StoryAreaTypeLocation) GetStoryAreaType() StoryAreaTypeLocation { + return v +} + +// 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 area, always "suggested_reaction" + Type string `json:"type"` + // 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"` +} + +func (v StoryAreaTypeSuggestedReaction) GetStoryAreaType() StoryAreaTypeSuggestedReaction { + return v +} + +// Describes a story area pointing to an HTTP or tg:// link. Currently, a story can have up to 3 link areas. +type StoryAreaTypeLink struct { + // Type of the area, always "link" + Type string `json:"type"` + // HTTP or tg:// URL to be opened when the area is clicked + Url string `json:"url"` +} + +func (v StoryAreaTypeLink) GetStoryAreaType() StoryAreaTypeLink { + return v +} + +// Describes a story area containing weather information. Currently, a story can have up to 3 weather areas. +type StoryAreaTypeWeather struct { + // Type of the area, always "weather" + Type string `json:"type"` + // 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"` +} + +func (v StoryAreaTypeWeather) GetStoryAreaType() StoryAreaTypeWeather { + return v +} + +// Describes a story area pointing to a unique gift. Currently, a story can have at most 1 unique gift area. +type StoryAreaTypeUniqueGift struct { + // Type of the area, always "unique_gift" + Type string `json:"type"` + // Unique name of the gift + Name string `json:"name"` +} + +func (v StoryAreaTypeUniqueGift) GetStoryAreaType() StoryAreaTypeUniqueGift { + return v +} + +// 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"` +} + + // Represents a location to which a chat is connected. type ChatLocation struct { // The location to which the supergroup is connected. Can't be a live location. @@ -2014,6 +2614,7 @@ type ChatLocation struct { // This object describes the type of a reaction. Currently, it can be one of // - ReactionTypeEmoji // - ReactionTypeCustomEmoji +// - ReactionTypePaid type ReactionType struct { Type string `json:"type"` Emoji string `json:"emoji"` @@ -2025,7 +2626,7 @@ type ReactionType struct { type ReactionTypeEmoji struct { // Type of the reaction, always "emoji" Type string `json:"type"` - // Reaction emoji. Currently, it can be one of "๐Ÿ‘", "๐Ÿ‘Ž", "โค", "๐Ÿ”ฅ", "๐Ÿฅฐ", "๐Ÿ‘", "๐Ÿ˜", "๐Ÿค”", "๐Ÿคฏ", "๐Ÿ˜ฑ", "๐Ÿคฌ", "๐Ÿ˜ข", "๐ŸŽ‰", "๐Ÿคฉ", "๐Ÿคฎ", "๐Ÿ’ฉ", "๐Ÿ™", "๐Ÿ‘Œ", "๐Ÿ•Š", "๐Ÿคก", "๐Ÿฅฑ", "๐Ÿฅด", "๐Ÿ˜", "๐Ÿณ", "โคโ€๐Ÿ”ฅ", "๐ŸŒš", "๐ŸŒญ", "๐Ÿ’ฏ", "๐Ÿคฃ", "โšก", "๐ŸŒ", "๐Ÿ†", "๐Ÿ’”", "๐Ÿคจ", "๐Ÿ˜", "๐Ÿ“", "๐Ÿพ", "๐Ÿ’‹", "๐Ÿ–•", "๐Ÿ˜ˆ", "๐Ÿ˜ด", "๐Ÿ˜ญ", "๐Ÿค“", "๐Ÿ‘ป", "๐Ÿ‘จโ€๐Ÿ’ป", "๐Ÿ‘€", "๐ŸŽƒ", "๐Ÿ™ˆ", "๐Ÿ˜‡", "๐Ÿ˜จ", "๐Ÿค", "โœ", "๐Ÿค—", "๐Ÿซก", "๐ŸŽ…", "๐ŸŽ„", "โ˜ƒ", "๐Ÿ’…", "๐Ÿคช", "๐Ÿ—ฟ", "๐Ÿ†’", "๐Ÿ’˜", "๐Ÿ™‰", "๐Ÿฆ„", "๐Ÿ˜˜", "๐Ÿ’Š", "๐Ÿ™Š", "๐Ÿ˜Ž", "๐Ÿ‘พ", "๐Ÿคทโ€โ™‚", "๐Ÿคท", "๐Ÿคทโ€โ™€", "๐Ÿ˜ก" + // Reaction emoji. Currently, it can be one of "โค", "๐Ÿ‘", "๐Ÿ‘Ž", "๐Ÿ”ฅ", "๐Ÿฅฐ", "๐Ÿ‘", "๐Ÿ˜", "๐Ÿค”", "๐Ÿคฏ", "๐Ÿ˜ฑ", "๐Ÿคฌ", "๐Ÿ˜ข", "๐ŸŽ‰", "๐Ÿคฉ", "๐Ÿคฎ", "๐Ÿ’ฉ", "๐Ÿ™", "๐Ÿ‘Œ", "๐Ÿ•Š", "๐Ÿคก", "๐Ÿฅฑ", "๐Ÿฅด", "๐Ÿ˜", "๐Ÿณ", "โคโ€๐Ÿ”ฅ", "๐ŸŒš", "๐ŸŒญ", "๐Ÿ’ฏ", "๐Ÿคฃ", "โšก", "๐ŸŒ", "๐Ÿ†", "๐Ÿ’”", "๐Ÿคจ", "๐Ÿ˜", "๐Ÿ“", "๐Ÿพ", "๐Ÿ’‹", "๐Ÿ–•", "๐Ÿ˜ˆ", "๐Ÿ˜ด", "๐Ÿ˜ญ", "๐Ÿค“", "๐Ÿ‘ป", "๐Ÿ‘จโ€๐Ÿ’ป", "๐Ÿ‘€", "๐ŸŽƒ", "๐Ÿ™ˆ", "๐Ÿ˜‡", "๐Ÿ˜จ", "๐Ÿค", "โœ", "๐Ÿค—", "๐Ÿซก", "๐ŸŽ…", "๐ŸŽ„", "โ˜ƒ", "๐Ÿ’…", "๐Ÿคช", "๐Ÿ—ฟ", "๐Ÿ†’", "๐Ÿ’˜", "๐Ÿ™‰", "๐Ÿฆ„", "๐Ÿ˜˜", "๐Ÿ’Š", "๐Ÿ™Š", "๐Ÿ˜Ž", "๐Ÿ‘พ", "๐Ÿคทโ€โ™‚", "๐Ÿคท", "๐Ÿคทโ€โ™€", "๐Ÿ˜ก" Emoji string `json:"emoji"` } @@ -2045,6 +2646,16 @@ func (v ReactionTypeCustomEmoji) GetReactionType() ReactionTypeCustomEmoji { return v } +// The reaction is paid. +type ReactionTypePaid struct { + // Type of the reaction, always "paid" + Type string `json:"type"` +} + +func (v ReactionTypePaid) GetReactionType() ReactionTypePaid { + return v +} + // Represents a reaction added to a message along with the number of times it was added. type ReactionCount struct { // Type of the reaction @@ -2096,6 +2707,319 @@ 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"` +} + + +// 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"` +} + + +// 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. 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 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"` +} + + +// This object represent a list of gifts. +type Gifts struct { + // The list of gifts + Gifts []Gift `json:"gifts"` +} + + +// 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 gift upgrades. Always 0 for crafted gifts. + RarityPerMille int64 `json:"rarity_per_mille"` + // Optional. Rarity of the model if it is a crafted model. Currently, can be "uncommon", "rare", "epic", or "legendary". + Rarity string `json:"rarity,omitempty"` +} + + +// 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"` +} + + +// 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"` +} + + +// 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"` +} + + +// 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"` + // 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"` +} + + +// 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 + 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"` + // 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 was used to craft another gift and isn't available anymore + IsBurned bool `json:"is_burned,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"` +} + + +// 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 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 + 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. Unique number reserved for this gift when upgraded. See the number field in UniqueGift + UniqueGiftNumber int64 `json:"unique_gift_number,omitempty"` +} + + +// 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, "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 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 + TransferStarCount int64 `json:"transfer_star_count,omitempty"` + // Optional. Point in time (Unix timestamp) when the gift can be transferred. If it is in the past, then the gift can be transferred now + NextTransferDate int64 `json:"next_transfer_date,omitempty"` +} + + +// This object describes a gift received and owned by a user or a chat. Currently, it can be one of +// - OwnedGiftRegular +// - OwnedGiftUnique +type OwnedGift struct { + Type string `json:"type"` + Gift *Gift `json:"gift"` + OwnedGiftId string `json:"owned_gift_id,omitempty"` + SenderUser *User `json:"sender_user,omitempty"` + SendDate int64 `json:"send_date"` + Text string `json:"text,omitempty"` + Entities []MessageEntity `json:"entities,omitempty"` + IsPrivate bool `json:"is_private,omitempty"` + IsSaved bool `json:"is_saved,omitempty"` + CanBeUpgraded bool `json:"can_be_upgraded,omitempty"` + WasRefunded bool `json:"was_refunded,omitempty"` + ConvertStarCount int64 `json:"convert_star_count,omitempty"` + PrepaidUpgradeStarCount int64 `json:"prepaid_upgrade_star_count,omitempty"` + IsUpgradeSeparate bool `json:"is_upgrade_separate,omitempty"` + UniqueGiftNumber int64 `json:"unique_gift_number,omitempty"` + CanBeTransferred bool `json:"can_be_transferred,omitempty"` + TransferStarCount int64 `json:"transfer_star_count,omitempty"` + NextTransferDate int64 `json:"next_transfer_date,omitempty"` +} + + +// Describes a regular gift owned by a user or a chat. +type OwnedGiftRegular struct { + // Type of the gift, always "regular" + Type string `json:"type"` + // 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; for gifts received on behalf of business accounts only + ConvertStarCount int64 `json:"convert_star_count,omitempty"` + // 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"` +} + +func (v OwnedGiftRegular) GetOwnedGift() OwnedGiftRegular { + return v +} + +// Describes a unique gift received and owned by a user or a chat. +type OwnedGiftUnique struct { + // Type of the gift, always "unique" + Type string `json:"type"` + // 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"` + // Optional. Point in time (Unix timestamp) when the gift can be transferred. If it is in the past, then the gift can be transferred now + NextTransferDate int64 `json:"next_transfer_date,omitempty"` +} + +func (v OwnedGiftUnique) GetOwnedGift() OwnedGiftUnique { + return v +} + +// 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"` + // Optional. Offset for the next request. If empty, then there are no more results + NextOffset string `json:"next_offset,omitempty"` +} + + +// 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"` + // True, if transfers of unique gifts from channels are accepted + GiftsFromChannels bool `json:"gifts_from_channels"` +} + + +// 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"` } @@ -2167,7 +3091,7 @@ func (v BotCommandScopeAllChatAdministrators) GetBotCommandScope() BotCommandSco type BotCommandScopeChat struct { // Scope type, must be chat Type string `json:"type"` - // Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + // Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername). Channel direct messages chats and channel chats aren't supported. ChatId int64 `json:"chat_id"` } @@ -2179,7 +3103,7 @@ func (v BotCommandScopeChat) GetBotCommandScope() BotCommandScopeChat { type BotCommandScopeChatAdministrators struct { // Scope type, must be chat_administrators Type string `json:"type"` - // Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + // Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername). Channel direct messages chats and channel chats aren't supported. ChatId int64 `json:"chat_id"` } @@ -2191,7 +3115,7 @@ func (v BotCommandScopeChatAdministrators) GetBotCommandScope() BotCommandScopeC type BotCommandScopeChatMember struct { // Scope type, must be chat_member Type string `json:"type"` - // Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + // Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername). Channel direct messages chats and channel chats aren't supported. ChatId int64 `json:"chat_id"` // Unique identifier of the target user UserId int64 `json:"user_id"` @@ -2276,6 +3200,7 @@ type ChatBoostSource struct { Source string `json:"source"` User *User `json:"user"` GiveawayMessageId int64 `json:"giveaway_message_id"` + PrizeStarCount int64 `json:"prize_star_count,omitempty"` IsUnclaimed bool `json:"is_unclaimed,omitempty"` } @@ -2304,14 +3229,16 @@ func (v ChatBoostSourceGiftCode) GetChatBoostSource() ChatBoostSourceGiftCode { return v } -// The boost was obtained by the creation of a Telegram Premium giveaway. This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription. +// The boost was obtained by the creation of a Telegram Premium or a Telegram Star giveaway. This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription for Telegram Premium giveaways and prize_star_count / 500 times for one year for Telegram Star giveaways. type ChatBoostSourceGiveaway struct { // Source of the boost, always "giveaway" Source string `json:"source"` // Identifier of a message in the chat with the giveaway; the message could have been deleted already. May be 0 if the message isn't sent yet. GiveawayMessageId int64 `json:"giveaway_message_id"` - // Optional. User that won the prize in the giveaway if any + // Optional. User that won the prize in the giveaway if any; for Telegram Premium giveaways only User *User `json:"user,omitempty"` + // Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only + PrizeStarCount int64 `json:"prize_star_count,omitempty"` // Optional. True, if the giveaway was completed, but there was no user to win the prize IsUnclaimed bool `json:"is_unclaimed,omitempty"` } @@ -2355,6 +3282,20 @@ type ChatBoostRemoved struct { } +// Describes a service message about the chat owner leaving the chat. +type ChatOwnerLeft struct { + // Optional. The user which will be the new owner of the chat if the previous owner does not return to the chat + NewOwner *User `json:"new_owner,omitempty"` +} + + +// Describes a service message about an ownership change in the chat. +type ChatOwnerChanged struct { + // The new owner of the chat + NewOwner *User `json:"new_owner"` +} + + // This object represents a list of boosts added to a chat by a user. type UserChatBoosts struct { // The list of boosts added to the chat by the user @@ -2362,6 +3303,39 @@ type UserChatBoosts struct { } +// 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 + CanDeleteSentMessages bool `json:"can_delete_sent_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"` +} + + // Describes the connection of the bot with a business account. type BusinessConnection struct { // Unique identifier of the business connection @@ -2372,8 +3346,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"` } @@ -2390,6 +3364,29 @@ type BusinessMessagesDeleted struct { } +// Describes an inline message sent by a Web App on behalf of a user. +type SentWebAppMessage struct { + // Optional. Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. + InlineMessageId string `json:"inline_message_id,omitempty"` +} + + +// 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"` +} + + +// Describes a keyboard button to be used by a user of a Mini App. +type PreparedKeyboardButton struct { + // Unique identifier of the keyboard button + Id string `json:"id"` +} + + // Describes why a request was unsuccessful. type ResponseParameters struct { // Optional. The group has been migrated to a supergroup with the specified identifier. 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 signed 64-bit integer or double-precision float type are safe for storing this identifier. @@ -2420,6 +3417,8 @@ type InputMedia struct { DisableContentTypeDetection bool `json:"disable_content_type_detection,omitempty"` Performer string `json:"performer,omitempty"` Title string `json:"title,omitempty"` + Cover string `json:"cover,omitempty"` + StartTimestamp int64 `json:"start_timestamp,omitempty"` SupportsStreaming bool `json:"supports_streaming,omitempty"` } @@ -2454,6 +3453,10 @@ type InputMediaVideo struct { Media string `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 string `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. @@ -2569,6 +3572,8 @@ type InputPaidMedia struct { Type string `json:"type"` Media string `json:"media"` Thumbnail string `json:"thumbnail,omitempty"` + Cover string `json:"cover,omitempty"` + StartTimestamp int64 `json:"start_timestamp,omitempty"` Width int64 `json:"width,omitempty"` Height int64 `json:"height,omitempty"` Duration int64 `json:"duration,omitempty"` @@ -2596,6 +3601,10 @@ type InputPaidMediaVideo struct { Media string `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 string `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 @@ -2610,6 +3619,86 @@ func (v InputPaidMediaVideo) GetInputPaidMedia() InputPaidMediaVideo { return v } +// This object describes a profile photo to set. Currently, it can be one of +// - InputProfilePhotoStatic +// - InputProfilePhotoAnimated +type InputProfilePhoto struct { + Type string `json:"type"` + Photo string `json:"photo"` + Animation string `json:"animation"` + MainFrameTimestamp float64 `json:"main_frame_timestamp,omitempty"` +} + + +// A static profile photo in the .JPG format. +type InputProfilePhotoStatic struct { + // Type of the profile photo, must be static + Type string `json:"type"` + // 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"` +} + +func (v InputProfilePhotoStatic) GetInputProfilePhoto() InputProfilePhotoStatic { + return v +} + +// An animated profile photo in the MPEG4 format. +type InputProfilePhotoAnimated struct { + // Type of the profile photo, must be animated + Type string `json:"type"` + // 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"` +} + +func (v InputProfilePhotoAnimated) GetInputProfilePhoto() InputProfilePhotoAnimated { + return v +} + +// This object describes the content of a story to post. Currently, it can be one of +// - InputStoryContentPhoto +// - InputStoryContentVideo +type InputStoryContent struct { + Type string `json:"type"` + Photo string `json:"photo"` + Video string `json:"video"` + Duration float64 `json:"duration,omitempty"` + CoverFrameTimestamp float64 `json:"cover_frame_timestamp,omitempty"` + IsAnimation bool `json:"is_animation,omitempty"` +} + + +// Describes a photo to post as a story. +type InputStoryContentPhoto struct { + // Type of the content, must be photo + Type string `json:"type"` + // 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"` +} + +func (v InputStoryContentPhoto) GetInputStoryContent() InputStoryContentPhoto { + return v +} + +// Describes a video to post as a story. +type InputStoryContentVideo struct { + // Type of the content, must be video + Type string `json:"type"` + // 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"` +} + +func (v InputStoryContentVideo) GetInputStoryContent() InputStoryContentVideo { + return v +} + // This object represents a sticker. type Sticker struct { // Identifier for this file, which can be used to download or reuse the file @@ -2675,9 +3764,9 @@ type MaskPosition struct { // 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 + // 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 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"` @@ -2758,7 +3847,6 @@ type InlineQueryResult struct { VideoFileId string `json:"video_file_id"` VoiceFileId string `json:"voice_file_id"` Url string `json:"url,omitempty"` - HideUrl bool `json:"hide_url,omitempty"` ThumbnailUrl string `json:"thumbnail_url,omitempty"` ThumbnailWidth int64 `json:"thumbnail_width,omitempty"` ThumbnailHeight int64 `json:"thumbnail_height,omitempty"` @@ -2818,8 +3906,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 @@ -2876,7 +3962,7 @@ type InlineQueryResultGif struct { Type string `json:"type"` // 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"` @@ -2914,7 +4000,7 @@ type InlineQueryResultMpeg4Gif struct { Type string `json:"type"` // 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"` @@ -3543,7 +4629,7 @@ type InputInvoiceMessageContent struct { Title string `json:"title"` // Product description, 1-255 characters Description string `json:"description"` - // Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. + // Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes. Payload string `json:"payload"` // Optional. Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars. ProviderToken string `json:"provider_token,omitempty"` @@ -3601,13 +4687,6 @@ type ChosenInlineResult struct { } -// Describes an inline message sent by a Web App on behalf of a user. -type SentWebAppMessage struct { - // Optional. Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. - InlineMessageId string `json:"inline_message_id,omitempty"` -} - - // This object represents a portion of the price for goods or services. type LabeledPrice struct { // Portion label @@ -3673,7 +4752,7 @@ type ShippingOption struct { } -// 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"` @@ -3681,6 +4760,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 @@ -3739,6 +4824,15 @@ type PreCheckoutQuery struct { } +// This object contains information about a paid media purchase. +type PaidMediaPurchased struct { + // User who purchased the media + From *User `json:"from"` + // Bot-specified paid media payload + PaidMediaPayload string `json:"paid_media_payload"` +} + + // This object describes the state of a revenue withdrawal operation. Currently, it can be one of // - RevenueWithdrawalStatePending // - RevenueWithdrawalStateSucceeded @@ -3784,16 +4878,45 @@ func (v RevenueWithdrawalStateFailed) GetRevenueWithdrawalState() RevenueWithdra return v } +// 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"` +} + + // 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 // - TransactionPartnerOther type TransactionPartner struct { Type string `json:"type"` + TransactionType string `json:"transaction_type"` User *User `json:"user"` + Affiliate *AffiliateInfo `json:"affiliate,omitempty"` InvoicePayload string `json:"invoice_payload,omitempty"` + SubscriptionPeriod int64 `json:"subscription_period,omitempty"` + PaidMedia []PaidMedia `json:"paid_media,omitempty"` + PaidMediaPayload string `json:"paid_media_payload,omitempty"` + Gift *Gift `json:"gift,omitempty"` + PremiumSubscriptionDuration int64 `json:"premium_subscription_duration,omitempty"` + Chat *Chat `json:"chat"` + SponsorUser *User `json:"sponsor_user,omitempty"` + CommissionPerMille int64 `json:"commission_per_mille"` WithdrawalState *RevenueWithdrawalState `json:"withdrawal_state,omitempty"` + RequestCount int64 `json:"request_count"` } @@ -3801,16 +4924,58 @@ type TransactionPartner struct { type TransactionPartnerUser struct { // Type of the transaction partner, always "user" Type string `json:"type"` + // 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. 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. 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"` } func (v TransactionPartnerUser) GetTransactionPartner() TransactionPartnerUser { return v } +// Describes a transaction with a chat. +type TransactionPartnerChat struct { + // Type of the transaction partner, always "chat" + Type string `json:"type"` + // Information about the chat + Chat *Chat `json:"chat"` + // Optional. The gift sent to the chat by the bot + Gift *Gift `json:"gift,omitempty"` +} + +func (v TransactionPartnerChat) GetTransactionPartner() TransactionPartnerChat { + return v +} + +// Describes the affiliate program that issued the affiliate commission received via this transaction. +type TransactionPartnerAffiliateProgram struct { + // Type of the transaction partner, always "affiliate_program" + Type string `json:"type"` + // 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"` +} + +func (v TransactionPartnerAffiliateProgram) GetTransactionPartner() TransactionPartnerAffiliateProgram { + return v +} + // Describes a withdrawal transaction with Fragment. type TransactionPartnerFragment struct { // Type of the transaction partner, always "fragment" @@ -3833,6 +4998,18 @@ func (v TransactionPartnerTelegramAds) GetTransactionPartner() TransactionPartne return v } +// Describes a transaction with payment for paid broadcasting. +type TransactionPartnerTelegramApi struct { + // Type of the transaction partner, always "telegram_api" + Type string `json:"type"` + // The number of successful requests that exceeded regular limits and were therefore billed + RequestCount int64 `json:"request_count"` +} + +func (v TransactionPartnerTelegramApi) GetTransactionPartner() TransactionPartnerTelegramApi { + return v +} + // Describes a transaction with an unknown source or recipient. type TransactionPartnerOther struct { // Type of the transaction partner, always "other" @@ -3843,12 +5020,14 @@ func (v TransactionPartnerOther) GetTransactionPartner() TransactionPartnerOther return v } -// 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 identifer of the original transaction for refund transactions. Coincides with SuccessfulPayment.telegram_payment_charge_id for successful incoming payments from users. + // 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 @@ -4168,6 +5347,16 @@ func UnmarshalUserArray(r json.RawMessage) (*[]User, error) { return tmp, err } +// Unmarshal VideoQuality json arrays +func UnmarshalVideoQualityArray(r json.RawMessage) (*[]VideoQuality, error) { + var tmp *[]VideoQuality + err := json.Unmarshal(r, &tmp) + if err != nil { + return nil, err + } + return tmp, err +} + // Unmarshal PaidMedia json arrays func UnmarshalPaidMediaArray(r json.RawMessage) (*[]PaidMedia, error) { var tmp *[]PaidMedia @@ -4188,6 +5377,26 @@ func UnmarshalPollOptionArray(r json.RawMessage) (*[]PollOption, error) { return tmp, err } +// Unmarshal ChecklistTask json arrays +func UnmarshalChecklistTaskArray(r json.RawMessage) (*[]ChecklistTask, error) { + var tmp *[]ChecklistTask + err := json.Unmarshal(r, &tmp) + if err != nil { + return nil, err + } + return tmp, err +} + +// Unmarshal InputChecklistTask json arrays +func UnmarshalInputChecklistTaskArray(r json.RawMessage) (*[]InputChecklistTask, error) { + var tmp *[]InputChecklistTask + err := json.Unmarshal(r, &tmp) + if err != nil { + return nil, err + } + return tmp, err +} + // Unmarshal SharedUser json arrays func UnmarshalSharedUserArray(r json.RawMessage) (*[]SharedUser, error) { var tmp *[]SharedUser @@ -4208,6 +5417,16 @@ func UnmarshalChatArray(r json.RawMessage) (*[]Chat, error) { return tmp, err } +// Unmarshal Audio json arrays +func UnmarshalAudioArray(r json.RawMessage) (*[]Audio, error) { + var tmp *[]Audio + err := json.Unmarshal(r, &tmp) + if err != nil { + return nil, err + } + return tmp, err +} + // Unmarshal BusinessOpeningHoursInterval json arrays func UnmarshalBusinessOpeningHoursIntervalArray(r json.RawMessage) (*[]BusinessOpeningHoursInterval, error) { var tmp *[]BusinessOpeningHoursInterval @@ -4228,6 +5447,26 @@ func UnmarshalReactionCountArray(r json.RawMessage) (*[]ReactionCount, error) { return tmp, err } +// Unmarshal Gift json arrays +func UnmarshalGiftArray(r json.RawMessage) (*[]Gift, error) { + var tmp *[]Gift + err := json.Unmarshal(r, &tmp) + if err != nil { + return nil, err + } + return tmp, err +} + +// Unmarshal OwnedGift json arrays +func UnmarshalOwnedGiftArray(r json.RawMessage) (*[]OwnedGift, error) { + var tmp *[]OwnedGift + err := json.Unmarshal(r, &tmp) + if err != nil { + return nil, err + } + return tmp, err +} + // Unmarshal ChatBoost json arrays func UnmarshalChatBoostArray(r json.RawMessage) (*[]ChatBoost, error) { var tmp *[]ChatBoost