diff --git a/configs.go b/configs.go index b11a584..dfb607f 100644 --- a/configs.go +++ b/configs.go @@ -379,11 +379,12 @@ func (config ForwardMessagesConfig) method() string { // 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 @@ func (config CopyMessageConfig) params() (Params, error) { 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 @@ func (config CopyMessagesConfig) method() string { 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 @@ func (config PhotoConfig) params() (Params, error) { 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 @@ func (config StickerConfig) files() []RequestFile { 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 @@ func (config VideoConfig) params() (Params, error) { 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 @@ func (config VideoConfig) files() []RequestFile { 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 @@ func (config AnimationConfig) params() (Params, error) { 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 @@ func (config EditMessageTextConfig) method() string { // 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 @@ func (config EditMessageCaptionConfig) params() (Params, error) { 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 @@ func (config InvoiceConfig) params() (Params, error) { 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 @@ func (config InvoiceLinkConfig) params() (Params, error) { 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) @@ -2025,6 +2035,26 @@ func (config PreCheckoutConfig) params() (Params, error) { 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 +} + // DeleteMessageConfig contains information of a message in a chat to delete. type DeleteMessageConfig struct { BaseChatMessage diff --git a/helper_structs.go b/helper_structs.go index 921099e..52d56b2 100644 --- a/helper_structs.go +++ b/helper_structs.go @@ -20,11 +20,12 @@ func (base ChatConfig) paramsWithKey(key string) (Params, error) { 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 @@ func (chat *BaseChat) params() (Params, error) { 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 { diff --git a/types.go b/types.go index 4aa4b81..16728d4 100644 --- a/types.go +++ b/types.go @@ -651,6 +651,10 @@ type Message struct { // // 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 @@ type Message struct { // // 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 @@ type MessageEntity struct { // “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 @@ type InlineKeyboardButton struct { // 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 @@ type BaseInputMedia struct { // // 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 @@ type InlineQueryResultCachedGIF struct { // // 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 @@ type InlineQueryResultCachedMPEG4GIF struct { // // 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 @@ type InlineQueryResultCachedPhoto struct { // // 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 @@ type InlineQueryResultCachedVideo struct { // // 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 @@ type InlineQueryResultGIF struct { // // 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 @@ type InlineQueryResultMPEG4GIF struct { // // 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 @@ type InlineQueryResultPhoto struct { // // 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 @@ type InlineQueryResultVideo struct { // // 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 @@ type InlineQueryResultVideo struct { ParseMode string `json:"parse_mode,omitempty"` // Width video width // - // optional + // optional Width int `json:"video_width,omitempty"` // Height video height // @@ -4617,9 +4668,11 @@ type InputInvoiceMessageContent struct { // 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 @@ type Invoice struct { 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 @@ type ShippingOption struct { // 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 @@ type PreCheckoutQuery struct { 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). diff --git a/types_test.go b/types_test.go index ac1f3bc..c4cd3fe 100644 --- a/types_test.go +++ b/types_test.go @@ -375,6 +375,7 @@ var ( _ Chattable = SetMyShortDescriptionConfig{} _ Chattable = GetMyNameConfig{} _ Chattable = SetMyNameConfig{} + _ Chattable = RefundStarPaymentConfig{} ) // Ensure all Fileable types are correct.