Bot API 7.4 implementation
@@ -379,11 +379,12 @@
// CopyMessageConfig contains information about a copyMessage request. type CopyMessageConfig struct { BaseChat - FromChat ChatConfig - MessageID int - Caption string - ParseMode string - CaptionEntities []MessageEntity + FromChat ChatConfig + MessageID int + Caption string + ParseMode string + CaptionEntities []MessageEntity + ShowCaptionAboveMedia bool } func (config CopyMessageConfig) params() (Params, error) {@@ -400,6 +401,7 @@ params.Merge(p1)
params.AddNonZero("message_id", config.MessageID) params.AddNonEmpty("caption", config.Caption) params.AddNonEmpty("parse_mode", config.ParseMode) + params.AddBool("show_caption_above_media", config.ShowCaptionAboveMedia) err = params.AddInterface("caption_entities", config.CaptionEntities) return params, err@@ -442,10 +444,11 @@ // PhotoConfig contains information about a SendPhoto request.
type PhotoConfig struct { BaseFile BaseSpoiler - Thumb RequestFileData - Caption string - ParseMode string - CaptionEntities []MessageEntity + Thumb RequestFileData + Caption string + ParseMode string + CaptionEntities []MessageEntity + ShowCaptionAboveMedia bool } func (config PhotoConfig) params() (Params, error) {@@ -456,6 +459,7 @@ }
params.AddNonEmpty("caption", config.Caption) params.AddNonEmpty("parse_mode", config.ParseMode) + params.AddBool("show_caption_above_media", config.ShowCaptionAboveMedia) err = params.AddInterface("caption_entities", config.CaptionEntities) if err != nil { return params, err@@ -609,12 +613,13 @@ // VideoConfig contains information about a SendVideo request.
type VideoConfig struct { BaseFile BaseSpoiler - Thumb RequestFileData - Duration int - Caption string - ParseMode string - CaptionEntities []MessageEntity - SupportsStreaming bool + Thumb RequestFileData + Duration int + Caption string + ParseMode string + CaptionEntities []MessageEntity + ShowCaptionAboveMedia bool + SupportsStreaming bool } func (config VideoConfig) params() (Params, error) {@@ -627,6 +632,7 @@ params.AddNonZero("duration", config.Duration)
params.AddNonEmpty("caption", config.Caption) params.AddNonEmpty("parse_mode", config.ParseMode) params.AddBool("supports_streaming", config.SupportsStreaming) + params.AddBool("show_caption_above_media", config.ShowCaptionAboveMedia) err = params.AddInterface("caption_entities", config.CaptionEntities) if err != nil { return params, err@@ -665,11 +671,12 @@ // AnimationConfig contains information about a SendAnimation request.
type AnimationConfig struct { BaseFile BaseSpoiler - Duration int - Thumb RequestFileData - Caption string - ParseMode string - CaptionEntities []MessageEntity + Duration int + Thumb RequestFileData + Caption string + ParseMode string + CaptionEntities []MessageEntity + ShowCaptionAboveMedia bool } func (config AnimationConfig) params() (Params, error) {@@ -681,6 +688,7 @@
params.AddNonZero("duration", config.Duration) params.AddNonEmpty("caption", config.Caption) params.AddNonEmpty("parse_mode", config.ParseMode) + params.AddBool("show_caption_above_media", config.ShowCaptionAboveMedia) err = params.AddInterface("caption_entities", config.CaptionEntities) if err != nil { return params, err@@ -1109,9 +1117,10 @@
// EditMessageCaptionConfig allows you to modify the caption of a message. type EditMessageCaptionConfig struct { BaseEdit - Caption string - ParseMode string - CaptionEntities []MessageEntity + Caption string + ParseMode string + CaptionEntities []MessageEntity + ShowCaptionAboveMedia bool } func (config EditMessageCaptionConfig) params() (Params, error) {@@ -1122,6 +1131,7 @@ }
params["caption"] = config.Caption params.AddNonEmpty("parse_mode", config.ParseMode) + params.AddBool("show_caption_above_media", config.ShowCaptionAboveMedia) err = params.AddInterface("caption_entities", config.CaptionEntities) return params, err@@ -1894,12 +1904,12 @@
params["title"] = config.Title params["description"] = config.Description params["payload"] = config.Payload - params["provider_token"] = config.ProviderToken params["currency"] = config.Currency if err = params.AddInterface("prices", config.Prices); err != nil { return params, err } + params.AddNonEmpty("provider_token", config.ProviderToken) params.AddNonZero("max_tip_amount", config.MaxTipAmount) err = params.AddInterface("suggested_tip_amounts", config.SuggestedTipAmounts) params.AddNonEmpty("start_parameter", config.StartParameter)@@ -1953,12 +1963,12 @@
params["title"] = config.Title params["description"] = config.Description params["payload"] = config.Payload - params["provider_token"] = config.ProviderToken params["currency"] = config.Currency if err := params.AddInterface("prices", config.Prices); err != nil { return params, err } + params.AddNonEmpty("provider_token", config.ProviderToken) params.AddNonZero("max_tip_amount", config.MaxTipAmount) err := params.AddInterface("suggested_tip_amounts", config.SuggestedTipAmounts) params.AddNonEmpty("provider_data", config.ProviderData)@@ -2021,6 +2031,26 @@
params["pre_checkout_query_id"] = config.PreCheckoutQueryID params.AddBool("ok", config.OK) params.AddNonEmpty("error_message", config.ErrorMessage) + + return params, nil +} + +// RefundStarPaymentConfig refunds a successful payment in Telegram Stars. +// Returns True on success. +type RefundStarPaymentConfig struct { + UserID int64 //required + TelegramPaymentChargeID string //required +} + +func (config RefundStarPaymentConfig) method() string { + return "refundStarPayment" +} + +func (config RefundStarPaymentConfig) params() (Params, error) { + params := make(Params) + + params["telegram_payment_charge_id"] = config.TelegramPaymentChargeID + params.AddNonZero64("user_id", config.UserID) return params, nil }
@@ -20,11 +20,12 @@ // BaseChat is base type for all chat config types.
type BaseChat struct { ChatConfig BusinessConnectionID BusinessConnectionID - MessageThreadID int - ProtectContent bool - ReplyMarkup interface{} - DisableNotification bool - ReplyParameters ReplyParameters + MessageThreadID int + ProtectContent bool + ReplyMarkup interface{} + DisableNotification bool + MessageEffectID string // for private chats only + ReplyParameters ReplyParameters } func (chat *BaseChat) params() (Params, error) {@@ -41,6 +42,7 @@
params.AddNonZero("message_thread_id", chat.MessageThreadID) params.AddBool("disable_notification", chat.DisableNotification) params.AddBool("protect_content", chat.ProtectContent) + params.AddNonEmpty("message_effect_id", chat.MessageEffectID) err = params.AddInterface("reply_markup", chat.ReplyMarkup) if err != nil {
@@ -651,6 +651,10 @@ // if it is a text message and link preview options were changed
// // Optional LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"` + // EffectID is the unique identifier of the message effect added to the message + // + // optional + EffectID string `json:"effect_id,omitempty"` // Animation message is an animation, information about the animation. // For backward compatibility, when this field is set, the document field will also be set; //@@ -701,6 +705,10 @@ // CaptionEntities;
// // optional CaptionEntities []MessageEntity `json:"caption_entities,omitempty"` + // ShowCaptionAboveMedia is True, if the caption must be shown above the message media + // + // optional + ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"` // HasSpoiler True, if the message media is covered by a spoiler animation // // optional@@ -1003,6 +1011,7 @@ // “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),@@ -2415,6 +2424,7 @@ //
// optional CallbackGame *CallbackGame `json:"callback_game,omitempty"` // Pay 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. //@@ -3289,6 +3299,10 @@ // which can be specified instead of parse_mode
// // optional CaptionEntities []MessageEntity `json:"caption_entities,omitempty"` + // Pass True, if the caption must be shown above the message media + // + // optional + ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"` // HasSpoiler pass True, if the photo needs to be covered with a spoiler animation // // optional@@ -3778,6 +3792,10 @@ // which can be specified instead of parse_mode
// // optional CaptionEntities []MessageEntity `json:"caption_entities,omitempty"` + // Pass True, if the caption must be shown above the message media + // + // optional + ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"` // ReplyMarkup inline keyboard attached to the message. // // optional@@ -3817,6 +3835,10 @@ // (https://core.telegram.org/bots/api#formatting-options).
// // optional CaptionEntities []MessageEntity `json:"caption_entities,omitempty"` + // Pass True, if the caption must be shown above the message media + // + // optional + ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"` // ReplyMarkup inline keyboard attached to the message. // // optional@@ -3858,6 +3880,10 @@ // which can be specified instead of parse_mode
// // optional CaptionEntities []MessageEntity `json:"caption_entities,omitempty"` + // Pass True, if the caption must be shown above the message media + // + // optional + ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"` // ReplyMarkup inline keyboard attached to the message. // // optional@@ -3917,6 +3943,10 @@ // which can be specified instead of parse_mode
// // optional CaptionEntities []MessageEntity `json:"caption_entities,omitempty"` + // Pass True, if the caption must be shown above the message media + // + // optional + ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"` // ReplyMarkup inline keyboard attached to the message // // optional@@ -4159,6 +4189,10 @@ // which can be specified instead of parse_mode
// // optional CaptionEntities []MessageEntity `json:"caption_entities,omitempty"` + // Pass True, if the caption must be shown above the message media + // + // optional + ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"` // ReplyMarkup inline keyboard attached to the message // // optional@@ -4267,6 +4301,10 @@ // which can be specified instead of parse_mode
// // optional CaptionEntities []MessageEntity `json:"caption_entities,omitempty"` + // Pass True, if the caption must be shown above the message media + // + // optional + ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"` // ReplyMarkup inline keyboard attached to the message // // optional@@ -4327,6 +4365,10 @@ // which can be specified instead of parse_mode
// // optional CaptionEntities []MessageEntity `json:"caption_entities,omitempty"` + // Pass True, if the caption must be shown above the message media + // + // optional + ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"` // InputMessageContent content of the message to be sent instead of the photo. // // optional@@ -4406,6 +4448,15 @@ // Caption of the video to be sent, 0-1024 characters after entities parsing
// // optional Caption string `json:"caption,omitempty"` + // CaptionEntities is a list of special entities that appear in the caption, + // which can be specified instead of parse_mode + // + // optional + CaptionEntities []MessageEntity `json:"caption_entities,omitempty"` + // Pass True, if the caption must be shown above the message media + // + // optional + ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"` // ParseMode mode for parsing entities in the video caption. // See formatting options for more details // (https://core.telegram.org/bots/api#formatting-options).@@ -4414,7 +4465,7 @@ // optional
ParseMode string `json:"parse_mode,omitempty"` // Width video width // - // optional + // optional Width int `json:"video_width,omitempty"` // Height video height //@@ -4617,9 +4668,11 @@ Description string `json:"description"`
// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to // the user, use for your internal processes. Payload string `json:"payload"` - // Payment provider token, obtained via Botfather + // Payment provider token, obtained via Botfather. Pass an empty string for payments in Telegram Stars. + // + // optional ProviderToken string `json:"provider_token"` - // Three-letter ISO 4217 currency code + // Three-letter ISO 4217 currency code. Pass “XTR” for payments in Telegram Stars. Currency string `json:"currency"` // Price breakdown, a JSON-serialized list of components (e.g. product // price, tax, discount, delivery cost, delivery tax, bonus, etc.)@@ -4711,7 +4764,7 @@ // Description product description
Description string `json:"description"` // StartParameter unique bot deep-linking parameter that can be used to generate this invoice StartParameter string `json:"start_parameter"` - // Currency three-letter ISO 4217 currency code + // Currency three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars // (see https://core.telegram.org/bots/payments#supported-currencies) Currency string `json:"currency"` // TotalAmount total price in the smallest units of the currency (integer, not float/double).@@ -4771,7 +4824,7 @@ }
// SuccessfulPayment contains basic information about a successful payment. type SuccessfulPayment struct { - // Currency three-letter ISO 4217 currency code + // Currency three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars // (see https://core.telegram.org/bots/payments#supported-currencies) Currency string `json:"currency"` // TotalAmount total price in the smallest units of the currency (integer, not float/double).@@ -4815,7 +4868,7 @@ // ID unique query identifier
ID string `json:"id"` // From user who sent the query From *User `json:"from"` - // Currency three-letter ISO 4217 currency code + // Currency three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars // // (see https://core.telegram.org/bots/payments#supported-currencies) Currency string `json:"currency"` // TotalAmount total price in the smallest units of the currency (integer, not float/double).
@@ -375,6 +375,7 @@ _ Chattable = GetMyShortDescriptionConfig{}
_ Chattable = SetMyShortDescriptionConfig{} _ Chattable = GetMyNameConfig{} _ Chattable = SetMyNameConfig{} + _ Chattable = RefundStarPaymentConfig{} ) // Ensure all Fileable types are correct.