From 6a83e6e519065dec0648c6a6e32d964afd71abec Mon Sep 17 00:00:00 2001 From: OvyFlash Date: Thu, 2 May 2024 22:49:19 +0300 Subject: [PATCH 1/5] BOT API 7.2 implementation --- configs.go | 68 ++++++++++++- helper_methods.go | 7 ++ helper_structs.go | 6 ++ types.go | 236 ++++++++++++++++++++++++++++++++++++++++++++-- types_test.go | 2 + 5 files changed, 309 insertions(+), 10 deletions(-) diff --git a/configs.go b/configs.go index 268c937..030d3c6 100644 --- a/configs.go +++ b/configs.go @@ -60,6 +60,19 @@ const ( // UpdateTypeEditedChannelPost is new version of a channel post that is known to the bot and was edited UpdateTypeEditedChannelPost = "edited_channel_post" + // UpdateTypeBusinessConnection is the bot was connected to or disconnected from a business account, + // or a user edited an existing connection with the bot + UpdateTypeBusinessConnection = "business_connection" + + // UpdateTypeBusinessMessage is a new non-service message from a connected business account + UpdateTypeBusinessMessage = "business_message" + + // UpdateTypeEditedBusinessMessage is a new version of a message from a connected business account + UpdateTypeEditedBusinessMessage = "edited_business_message" + + // UpdateTypeDeletedBusinessMessages are the messages were deleted from a connected business account + UpdateTypeDeletedBusinessMessages = "deleted_business_messages" + // UpdateTypeMessageReactionis is a reaction to a message was changed by a user UpdateTypeMessageReaction = "message_reaction" @@ -2216,7 +2229,6 @@ type NewStickerSetConfig struct { Name string Title string Stickers []InputSticker - StickerFormat string StickerType string NeedsRepainting bool //optional; Pass True if stickers in the sticker set must be repainted to the color of text when used in messages, the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; for custom emoji sticker sets only } @@ -2231,7 +2243,6 @@ func (config NewStickerSetConfig) params() (Params, error) { params.AddNonZero64("user_id", config.UserID) params["name"] = config.Name params["title"] = config.Title - params["sticker_format"] = config.StickerFormat params.AddBool("needs_repainting", config.NeedsRepainting) params.AddNonEmpty("sticker_type", string(config.StickerType)) @@ -2363,6 +2374,33 @@ func (config DeleteStickerConfig) params() (Params, error) { return params, nil } +// ReplaceStickerInSetConfig allows you to replace an existing sticker in a sticker set +// with a new one. The method is equivalent to calling deleteStickerFromSet, +// then addStickerToSet, then setStickerPositionInSet. +// Returns True on success. +type ReplaceStickerInSetConfig struct { + UserID int64 + Name string + OldSticker string + Sticker InputSticker +} + +func (config ReplaceStickerInSetConfig) method() string { + return "replaceStickerInSet" +} + +func (config ReplaceStickerInSetConfig) params() (Params, error) { + params := make(Params) + + params.AddNonZero64("user_id", config.UserID) + params["name"] = config.Name + params["old_sticker"] = config.OldSticker + + err := params.AddInterface("sticker", config.Sticker) + + return params, err +} + // SetStickerEmojiListConfig allows you to change the list of emoji assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot type SetStickerEmojiListConfig struct { Sticker string @@ -2425,6 +2463,7 @@ type SetStickerSetThumbConfig struct { Name string UserID int64 Thumb RequestFileData + Format string } func (config SetStickerSetThumbConfig) method() string { @@ -2435,6 +2474,8 @@ func (config SetStickerSetThumbConfig) params() (Params, error) { params := make(Params) params["name"] = config.Name + params["format"] = config.Format + params.AddNonZero64("user_id", config.UserID) return params, nil @@ -2739,6 +2780,29 @@ func (config GetUserChatBoostsConfig) params() (Params, error) { return params, err } +type ( + GetBusinessConnectionConfig struct { + BusinessConnectionID BusinessConnectionID + } + BusinessConnectionID string +) + +func (GetBusinessConnectionConfig) method() string { + return "getBusinessConnection" +} + +func (config GetBusinessConnectionConfig) params() (Params, error) { + return config.BusinessConnectionID.params() +} + +func (config BusinessConnectionID) params() (Params, error) { + params := make(Params) + + params["business_connection_id"] = string(config) + + return params, nil +} + // GetMyCommandsConfig gets a list of the currently registered commands. type GetMyCommandsConfig struct { Scope *BotCommandScope diff --git a/helper_methods.go b/helper_methods.go index 93901d9..db78644 100644 --- a/helper_methods.go +++ b/helper_methods.go @@ -1075,6 +1075,13 @@ func NewSetMyName(languageCode, name string) SetMyNameConfig { } } +// NewGetBusinessConnection gets business connection request struct +func NewGetBusinessConnection(id string) GetBusinessConnectionConfig { + return GetBusinessConnectionConfig{ + BusinessConnectionID: BusinessConnectionID(id), + } +} + // NewGetMyCommandsWithScope allows you to set the registered commands for a // given scope. func NewGetMyCommandsWithScope(scope BotCommandScope) GetMyCommandsConfig { diff --git a/helper_structs.go b/helper_structs.go index 008fc47..921099e 100644 --- a/helper_structs.go +++ b/helper_structs.go @@ -19,6 +19,7 @@ func (base ChatConfig) paramsWithKey(key string) (Params, error) { // BaseChat is base type for all chat config types. type BaseChat struct { ChatConfig + BusinessConnectionID BusinessConnectionID MessageThreadID int ProtectContent bool ReplyMarkup interface{} @@ -31,6 +32,11 @@ func (chat *BaseChat) params() (Params, error) { if err != nil { return params, err } + p1, err := chat.BusinessConnectionID.params() + if err != nil { + return params, err + } + params.Merge(p1) params.AddNonZero("message_thread_id", chat.MessageThreadID) params.AddBool("disable_notification", chat.DisableNotification) diff --git a/types.go b/types.go index 2da8b9c..51aa333 100644 --- a/types.go +++ b/types.go @@ -61,6 +61,26 @@ type Update struct { // // optional EditedChannelPost *Message `json:"edited_channel_post,omitempty"` + // BusinessConnection the bot was connected to or disconnected from a + // business account, or a user edited an existing connection with the bot + // + // optional + BusinessConnection *BusinessConnection `json:"business_connection,omitempty"` + // BusinessMessage is a new non-service message from a + // connected business account + // + // optional + BusinessMessage *Message `json:"business_message,omitempty"` + // EditedBusinessMessage is a new version of a message from a + // connected business account + // + // optional + EditedBusinessMessage *Message `json:"edited_business_message,omitempty"` + // DeletedBusinessMessages are the messages were deleted from a + // connected business account + // + // optional + DeletedBusinessMessages *BusinessMessagesDeleted `json:"deleted_business_messages,omitempty"` // MessageReaction is a reaction to a message was changed by a user. // // optional @@ -237,6 +257,12 @@ type User struct { // // optional SupportsInlineQueries bool `json:"supports_inline_queries,omitempty"` + // CanConnectToBusiness is true, if the bot can be connected to a + // Telegram Business account to receive its messages. + // Returned only in getMe. + // + // optional + CanConnectToBusiness bool `json:"can_connect_to_business,omitempty"` } // String displays a simple text version of a user. @@ -292,6 +318,31 @@ type Chat struct { // // optional ActiveUsernames []string `json:"active_usernames,omitempty"` + // Birthdate for private chats, the date of birth of the user. + // Returned only in getChat. + // + // optional + Birthdate *Birthdate `json:"birthdate,omitempty"` + // BusinessIntro is for private chats with business accounts, the intro of the business. + // Returned only in getChat. + // + // optional + BusinessIntro *BusinessIntro `json:"business_intro,omitempty"` + // BusinessLocation is for private chats with business accounts, the location + // of the business. Returned only in getChat. + // + // optional + BusinessLocation *BusinessLocation `json:"business_location,omitempty"` + // BusinessOpeningHours is for private chats with business accounts, + // the opening hours of the business. Returned only in getChat. + // + // optional + BusinessOpeningHours *BusinessOpeningHours `json:"business_opening_hours,omitempty"` + // PersonalChat is for private chats, the personal channel of the user. + // Returned only in getChat. + // + // optional + PersonalChat *Chat `json:"personal_chat,omitempty"` // AvailableReactions is a list of available reactions allowed in the chat. // If omitted, then all emoji reactions are allowed. Returned only in getChat. // @@ -426,8 +477,8 @@ type Chat struct { // // optional CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"` - // CustomEmojiStickerSetName is for supergroups, the name of the group's - // custom emoji sticker set. Custom emoji from this set can be used by all + // CustomEmojiStickerSetName is for supergroups, the name of the group's + // custom emoji sticker set. Custom emoji from this set can be used by all // users and bots in the group. Returned only in getChat. // // optional @@ -505,8 +556,21 @@ type Message struct { // // optional SenderBoostCount int `json:"sender_boost_count,omitempty"` + // SenderBusinessBot is 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. + // + // optional + SenderBusinessBot *User `json:"sender_business_bot,omitempty"` // Date of the message was sent in Unix time Date int `json:"date"` + // BusinessConnectionID is an 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. + // + // optional + BusinessConnectionID string `json:"business_connection_id,omitempty"` // Chat is the conversation the message belongs to Chat Chat `json:"chat"` // ForwardOrigin is information about the original message for forwarded messages @@ -553,6 +617,11 @@ type Message struct { // // optional HasProtectedContent bool `json:"has_protected_content,omitempty"` + // IsFromOffline is 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 + // + // optional + IsFromOffline bool `json:"is_from_offline,omitempty"` // MediaGroupID is the unique identifier of a media message group this message belongs to; // // optional @@ -1663,13 +1732,37 @@ type GeneralForumTopicHidden struct { type GeneralForumTopicUnhidden struct { } +// SharedUser contains information about a user that was +// shared with the bot using a KeyboardButtonRequestUsers button. +type SharedUser struct { + // UserID is the identifier of the shared user. + UserID int64 `json:"user_id"` + // FirstName of the user, if the name was requested by the bot. + // + // optional + FirstName *string `json:"first_name,omitempty"` + // LastName of the user, if the name was requested by the bot. + // + // optional + LastName *string `json:"last_name,omitempty"` + // Username of the user, if the username was requested by the bot. + // + // optional + UserName *string `json:"username,omitempty"` + // Photo is array of available sizes of the chat photo, + // if the photo was requested by the bot + // + // optional + Photo []PhotoSize `json:"photo,omitempty"` +} + // UsersShared object contains information about the user whose identifier // was shared with the bot using a KeyboardButtonRequestUser button. type UsersShared struct { // RequestID is an indentifier of the request. RequestID int `json:"request_id"` - // UserIDs are identifiers of the shared user. - UserIDs []int64 `json:"user_ids"` + // Users shared with the bot. + Users []SharedUser `json:"users"` } // ChatShared contains information about the chat whose identifier @@ -1679,6 +1772,20 @@ type ChatShared struct { RequestID int `json:"request_id"` // ChatID is an identifier of the shared chat. ChatID int64 `json:"chat_id"` + // Title of the chat, if the title was requested by the bot. + // + // optional + Title *string `json:"title,omitempty"` + // UserName of the chat, if the username was requested by + // the bot and available. + // + // optional + UserName *string `json:"username,omitempty"` + // Photo is array of available sizes of the chat photo, + // if the photo was requested by the bot + // + // optional + Photo []PhotoSize `json:"photo,omitempty"` } // WriteAccessAllowed represents a service message about a user allowing a bot @@ -2016,6 +2123,18 @@ type KeyboardButtonRequestUsers struct { // // optional MaxQuantity int `json:"max_quantity,omitempty"` + // RequestName pass True to request the users' first and last names + // + // optional + RequestName bool `json:"request_name,omitempty"` + // RequestUsername pass True to request the users' usernames + // + // optional + RequestUsername bool `json:"request_username,omitempty"` + // RequestPhoto pass True to request the users' photos + // + // optional + RequestPhoto bool `json:"request_photo,omitempty"` } // KeyboardButtonRequestChat defines the criteria used to request @@ -2062,6 +2181,18 @@ type KeyboardButtonRequestChat struct { // // optional BotIsMember bool `json:"bot_is_member,omitempty"` + // RequestTitle pass True to request the chat's title + // + // optional + RequestTitle bool `json:"request_title,omitempty"` + // RequestUsername pass True to request the chat's username + // + // optional + RequestUsername bool `json:"request_username,omitempty"` + // RequestPhoto pass True to request the chat's photo + // + // optional + RequestPhoto bool `json:"request_photo,omitempty"` } // KeyboardButtonPollType represents type of poll, which is allowed to @@ -2688,6 +2819,64 @@ func (c *ChatPermissions) CanSendMediaMessages() bool { c.CanSendVideoNotes && c.CanSendVoiceNotes } +// Birthdate represents a user's birthdate +type Birthdate struct { + // Day of the user's birth; 1-31 + Day int `json:"day"` + // Month of the user's birth; 1-12 + Month int `json:"month"` + // Year of the user's birth + // + // optional + Year *int `json:"year,omitempty"` +} + +// BusinessIntro represents a basic information about your business +type BusinessIntro struct { + // Title text of the business intro + // + // optional + Title *string `json:"title,omitempty"` + // Message text of the business intro + // + // optional + Message *string `json:"message,omitempty"` + // Sticker of the business intro + // + // optional + Sticker *Sticker `json:"sticker,omitempty"` +} + +// BusinessLocation represents a business geodata +type BusinessLocation struct { + // Address of the business + Address string `json:"address"` + // Location of the business + // + // optional + Location *Location `json:"location,omitempty"` +} + +// BusinessOpeningHoursInterval represents a business working interval +type BusinessOpeningHoursInterval struct { + // OpeningMinute is the minute's sequence number in a week, starting on Monday, + // marking the start of the time interval during which the business is open; 0 - 7 * 24 * 60 + OpeningMinute int `json:"opening_minute"` + // ClosingMinute is the minute's sequence number in a week, starting on Monday, + // marking the end of the time interval during which the business is open; 0 - 8 * 24 * 60 + ClosingMinute int `json:"closing_minute"` +} + +// BusinessOpeningHours represents a set of business working intervals +type BusinessOpeningHours struct { + // TimeZoneName is the unique name of the time zone + // for which the opening hours are defined + TimeZoneName string `json:"time_zone_name"` + // OpeningHours is the list of time intervals describing + // business opening hours + OpeningHours []BusinessOpeningHoursInterval `json:"opening_hours"` +} + // ChatLocation represents a location to which a chat is connected. type ChatLocation struct { // Location is the location to which the supergroup is connected. Can't be a @@ -2904,6 +3093,38 @@ type UserChatBoosts struct { Boosts []ChatBoost `json:"boosts"` } +// BusinessConnection describes the connection of the bot with a business account. +type BusinessConnection struct { + // ID is an unique identifier of the business connection + ID string `json:"id"` + // User is a business account user that created the business connection + User User `json:"user"` + // UserChatID identifier of a private chat with the user who + // created the business connection. + UserChatID int64 `json:"user_chat_id"` + // Date the connection was established in Unix time + Date int64 `json:"date"` + // CanReply is 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"` + // IsEnabled is True, if the connection is active + IsEnabled bool `json:"is_enabled"` +} + +// BusinessMessagesDeleted is received when messages are deleted +// from a connected business account. +type BusinessMessagesDeleted struct { + // BusinessConnectionID is an unique identifier + // of the business connection + BusinessConnectionID string `json:"business_connection_id"` + // Chat is the information about a chat in the business account. + // The bot may not have access to the chat or the corresponding user. + Chat Chat `json:"chat"` + // MessageIDs is a JSON-serialized list of identifiers of deleted messages + // in the chat of the business account + MessageIDs []int `json:"message_ids"` +} + // ResponseParameters are various errors that can be returned in APIResponse. type ResponseParameters struct { // The group has been migrated to a supergroup with the specified identifier. @@ -3139,10 +3360,6 @@ type StickerSet struct { Title string `json:"title"` // StickerType of stickers in the set, currently one of “regular”, “mask”, “custom_emoji” StickerType string `json:"sticker_type"` - // IsAnimated true, if the sticker set contains animated stickers - IsAnimated bool `json:"is_animated"` - // IsVideo true, if the sticker set contains video stickers - IsVideo bool `json:"is_video"` // ContainsMasks true, if the sticker set contains masks // // deprecated. Use sticker_type instead @@ -3190,6 +3407,9 @@ type MaskPosition struct { 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. Sticker RequestFile `json:"sticker"` + // Format of the added sticker, must be one of “static” for a + // .WEBP or .PNG image, “animated” for a .TGS animation, “video” for a WEBM video + Format string `json:"format"` // List of 1-20 emoji associated with the sticker EmojiList []string `json:"emoji_list"` // Position where the mask should be placed on faces. For “mask” stickers only. diff --git a/types_test.go b/types_test.go index 4fd9e44..ac1f3bc 100644 --- a/types_test.go +++ b/types_test.go @@ -308,6 +308,7 @@ var ( _ Chattable = FileConfig{} _ Chattable = ForwardConfig{} _ Chattable = GameConfig{} + _ Chattable = GetBusinessConnectionConfig{} _ Chattable = GetChatMemberConfig{} _ Chattable = GetChatMenuButtonConfig{} _ Chattable = GetGameHighScoresConfig{} @@ -324,6 +325,7 @@ var ( _ Chattable = PinChatMessageConfig{} _ Chattable = PreCheckoutConfig{} _ Chattable = PromoteChatMemberConfig{} + _ Chattable = ReplaceStickerInSetConfig{} _ Chattable = RestrictChatMemberConfig{} _ Chattable = RevokeChatInviteLinkConfig{} _ Chattable = SendPollConfig{} From 1ad852c7652bb1c0226da1214678f9dc70dcf3d5 Mon Sep 17 00:00:00 2001 From: stdkhai Date: Tue, 7 May 2024 17:32:47 +0300 Subject: [PATCH 2/5] Bot API 7.3 implementation --- bot.go | 6 +-- bot_test.go | 2 +- configs.go | 10 ++++- helper_methods.go | 9 +++- types.go | 111 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 132 insertions(+), 6 deletions(-) diff --git a/bot.go b/bot.go index 7a282fc..1a16c27 100644 --- a/bot.go +++ b/bot.go @@ -553,13 +553,13 @@ func WriteToHTTPResponse(w http.ResponseWriter, c Chattable) error { } // GetChat gets information about a chat. -func (bot *BotAPI) GetChat(config ChatInfoConfig) (Chat, error) { +func (bot *BotAPI) GetChat(config ChatInfoConfig) (ChatFullInfo, error) { resp, err := bot.Request(config) if err != nil { - return Chat{}, err + return ChatFullInfo{}, err } - var chat Chat + var chat ChatFullInfo err = json.Unmarshal(resp.Result, &chat) return chat, err diff --git a/bot_test.go b/bot_test.go index 40633d6..d61a73b 100644 --- a/bot_test.go +++ b/bot_test.go @@ -933,7 +933,7 @@ func TestUnpinAllChatMessages(t *testing.T) { func TestPolls(t *testing.T) { bot, _ := getBot(t) - poll := NewPoll(SupergroupChatID, "Are polls working?", "Yes", "No") + poll := NewPoll(SupergroupChatID, "Are polls working?", NewPollOption("Yes"), NewPollOption("No")) msg, err := bot.Send(poll) if err != nil { diff --git a/configs.go b/configs.go index 030d3c6..b11a584 100644 --- a/configs.go +++ b/configs.go @@ -829,6 +829,7 @@ type EditMessageLiveLocationConfig struct { BaseEdit Latitude float64 // required Longitude float64 // required + LivePeriod int //optional HorizontalAccuracy float64 // optional Heading int // optional ProximityAlertRadius int // optional @@ -841,6 +842,7 @@ func (config EditMessageLiveLocationConfig) params() (Params, error) { params.AddNonZeroFloat("longitude", config.Longitude) params.AddNonZeroFloat("horizontal_accuracy", config.HorizontalAccuracy) params.AddNonZero("heading", config.Heading) + params.AddNonZero("live_period", config.LivePeriod) params.AddNonZero("proximity_alert_radius", config.ProximityAlertRadius) return params, err @@ -924,7 +926,9 @@ func (config ContactConfig) method() string { type SendPollConfig struct { BaseChat Question string - Options []string + QuestionParseMode string // optional + QuestionEntities []MessageEntity // optional + Options []InputPollOption IsAnonymous bool Type string AllowsMultipleAnswers bool @@ -944,6 +948,10 @@ func (config SendPollConfig) params() (Params, error) { } params["question"] = config.Question + params.AddNonEmpty("question_parse_mode", config.QuestionParseMode) + if err = params.AddInterface("question_entities", config.QuestionEntities); err != nil { + return params, err + } if err = params.AddInterface("options", config.Options); err != nil { return params, err } diff --git a/helper_methods.go b/helper_methods.go index db78644..747d4a0 100644 --- a/helper_methods.go +++ b/helper_methods.go @@ -933,7 +933,7 @@ func NewDeleteChatPhoto(chatID int64) DeleteChatPhotoConfig { } // NewPoll allows you to create a new poll. -func NewPoll(chatID int64, question string, options ...string) SendPollConfig { +func NewPoll(chatID int64, question string, options ...InputPollOption) SendPollConfig { return SendPollConfig{ BaseChat: BaseChat{ ChatConfig: ChatConfig{ChatID: chatID}, @@ -944,6 +944,13 @@ func NewPoll(chatID int64, question string, options ...string) SendPollConfig { } } +// NewPollOption allows you to create poll option +func NewPollOption(text string) InputPollOption { + return InputPollOption{ + Text: text, + } +} + // NewStopPoll allows you to stop a poll. func NewStopPoll(chatID int64, messageID int) StopPollConfig { return StopPollConfig{ diff --git a/types.go b/types.go index 51aa333..ec75ffe 100644 --- a/types.go +++ b/types.go @@ -311,6 +311,11 @@ type Chat struct { // // optional IsForum bool `json:"is_forum,omitempty"` +} + +// ChatFullInfo contains full information about a chat. +type ChatFullInfo struct { + Chat // Photo is a chat photo Photo *ChatPhoto `json:"photo"` // If non-empty, the list of all active chat usernames; @@ -355,6 +360,8 @@ type Chat struct { // // optional AccentColorID int `json:"accent_color_id,omitempty"` + // The maximum number of reactions that can be set on a message in the chat + MaxReactionCount int `json:"max_reaction_count"` // BackgroundCustomEmojiID is a custom emoji identifier of emoji chosen by // the chat for the reply header and link preview background. // Returned only in getChat. @@ -833,6 +840,10 @@ type Message struct { // // optional BoostAdded *ChatBoostAdded `json:"boost_added,omitempty"` + // Service message: chat background set + // + // optional + ChatBackgroundSet *ChatBackground `json:"chat_background_set,omitempty"` // ForumTopicCreated is a service message: forum topic created // // optional @@ -1528,10 +1539,31 @@ type Dice struct { type PollOption struct { // Text is the option text, 1-100 characters Text string `json:"text"` + // Special entities that appear in the option text. + // Currently, only custom emoji entities are allowed in poll option texts + // + // optional + TextEntities []MessageEntity `json:"text_entities"` // VoterCount is the number of users that voted for this option VoterCount int `json:"voter_count"` } +// InputPollOption contains information about one answer option in a poll to send. +type InputPollOption struct { + // Option text, 1-100 characters + Text string `json:"text"` + // Mode for parsing entities in the text. See formatting options for more details. + // Currently, only custom emoji entities are allowed + // + // optional + TextParseMode string `json:"text_parse_mode"` + // A JSON-serialized list of special entities that appear in the poll option text. + // It can be specified instead of text_parse_mode + // + // optional + TextEntities []MessageEntity `json:"text_entities"` +} + // PollAnswer represents an answer of a user in a non-anonymous poll. type PollAnswer struct { // PollID is the unique poll identifier @@ -1557,6 +1589,11 @@ type Poll struct { ID string `json:"id"` // Question is the poll question, 1-255 characters Question string `json:"question"` + // Special entities that appear in the question. + // Currently, only custom emoji entities are allowed in poll questions + // + // optional + QuestionEntities []MessageEntity `json:"question_entities"` // Options is the list of poll options Options []PollOption `json:"options"` // TotalVoterCount is the total numbers of users who voted in the poll @@ -1610,6 +1647,7 @@ type Location struct { HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"` // LivePeriod is time relative to the message sending date, during which the // location can be updated, in seconds. For active live locations only. + // Use 0x7FFFFFFF (2147483647 - max positive Int) to edit indefinitely // // optional LivePeriod int `json:"live_period,omitempty"` @@ -1684,6 +1722,73 @@ type ChatBoostAdded struct { BoostCount int `json:"boost_count"` } +// BackgroundFill describes the way a background is filled based on the selected colors. +// Currently, it can be one of: +// - BackgroundFillSolid +// - BackgroundFillGradient +// - BackgroundFillFreeformGradient +type BackgroundFill struct { + // Type of the background fill, can be: + // - solid + // - gradient + // - freeform_gradient + Type string `json:"type"` + // The color of the background fill in the RGB24 format + Color int `json:"color"` + // Top color of the gradient in the RGB24 format + TopColor int `json:"top_color"` + // Bottom color of the gradient in the RGB24 format + BottomColor int `json:"bottom_color"` + // Clockwise rotation angle of the background fill in degrees; 0-359 + RotationAngle int `json:"rotation_angle"` + // A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format + Colors []int `json:"colors"` +} + +// BackgroundType describes the type of a background. Currently, it can be one of: +// - BackgroundTypeFill +// - BackgroundTypeWallpaper +// - BackgroundTypePattern +// - BackgroundTypeChatTheme +type BackgroundType struct { + // Type of the background. + // Currently, it can be one of: + // - fill + // - wallpaper + // - pattern + // - chat_theme + Type string `json:"type"` + // The background fill or fill that is combined with the pattern + Fill BackgroundFill `json:"fill"` + // Dimming of the background in dark themes, as a percentage; 0-100 + DarkThemeDimming int `json:"dark_theme_dimming"` + // Document with the wallpaper / pattern + Document Document `json:"document"` + // True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with radius 12 + // + // optional + IsBlurred bool `json:"is_blurred"` + // True, if the background moves slightly when the device is tilted + // + // optional + IsMoving bool `json:"is_moving"` + // Intensity of the pattern when it is shown above the filled background; 0-100 + Intensity int `json:"intensity"` + // True, if the background fill must be applied only to the pattern itself. + // All other pixels are black in this case. For dark themes only + // + // optional + IsInverted bool `json:"is_inverted"` + // Name of the chat theme, which is usually an emoji + ThemeName string `json:"theme_name"` +} + +// ChatBackground represents a chat background. +type ChatBackground struct { + // Type of the background + Type BackgroundType `json:"type"` +} + // ForumTopicCreated represents a service message about a new forum topic // created in the chat. type ForumTopicCreated struct { @@ -2702,6 +2807,12 @@ type ChatMemberUpdated struct { // // optional InviteLink *ChatInviteLink `json:"invite_link,omitempty"` + // ViaJoinRequest is true, if the user joined the chat + // after sending a direct join request + // and being approved by an administrator + // + // optional + ViaJoinRequest bool `json:"via_join_request,omitempty"` // ViaChatFolderInviteLink is True, if the user joined the chat // via a chat folder invite link // From 3dfc49d5c1144743b3911cc8ff22b49f114aca8e Mon Sep 17 00:00:00 2001 From: stdkhai Date: Fri, 10 May 2024 17:19:52 +0300 Subject: [PATCH 3/5] add missed omitempty tag & update comments --- types.go | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/types.go b/types.go index ec75ffe..0828a0b 100644 --- a/types.go +++ b/types.go @@ -1543,7 +1543,7 @@ type PollOption struct { // Currently, only custom emoji entities are allowed in poll option texts // // optional - TextEntities []MessageEntity `json:"text_entities"` + TextEntities []MessageEntity `json:"text_entities,omitempty"` // VoterCount is the number of users that voted for this option VoterCount int `json:"voter_count"` } @@ -1556,12 +1556,12 @@ type InputPollOption struct { // Currently, only custom emoji entities are allowed // // optional - TextParseMode string `json:"text_parse_mode"` + TextParseMode string `json:"text_parse_mode,omitempty"` // A JSON-serialized list of special entities that appear in the poll option text. // It can be specified instead of text_parse_mode // // optional - TextEntities []MessageEntity `json:"text_entities"` + TextEntities []MessageEntity `json:"text_entities,omitempty"` } // PollAnswer represents an answer of a user in a non-anonymous poll. @@ -1593,7 +1593,7 @@ type Poll struct { // Currently, only custom emoji entities are allowed in poll questions // // optional - QuestionEntities []MessageEntity `json:"question_entities"` + QuestionEntities []MessageEntity `json:"question_entities,omitempty"` // Options is the list of poll options Options []PollOption `json:"options"` // TotalVoterCount is the total numbers of users who voted in the poll @@ -1733,14 +1733,19 @@ type BackgroundFill struct { // - gradient // - freeform_gradient Type string `json:"type"` + // BackgroundFillSolid only. // The color of the background fill in the RGB24 format Color int `json:"color"` + // BackgroundFillGradient only. // Top color of the gradient in the RGB24 format TopColor int `json:"top_color"` + // BackgroundFillGradient only. // Bottom color of the gradient in the RGB24 format BottomColor int `json:"bottom_color"` + // BackgroundFillGradient only. // Clockwise rotation angle of the background fill in degrees; 0-359 RotationAngle int `json:"rotation_angle"` + // BackgroundFillFreeformGradient only. // A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format Colors []int `json:"colors"` } @@ -1758,27 +1763,35 @@ type BackgroundType struct { // - pattern // - chat_theme Type string `json:"type"` + // BackgroundTypeFill and BackgroundTypePattern only. // The background fill or fill that is combined with the pattern Fill BackgroundFill `json:"fill"` + // BackgroundTypeFill and BackgroundTypeWallpaper only. // Dimming of the background in dark themes, as a percentage; 0-100 DarkThemeDimming int `json:"dark_theme_dimming"` + // BackgroundTypeWallpaper and BackgroundTypePattern only. // Document with the wallpaper / pattern Document Document `json:"document"` + // BackgroundTypeWallpaper only. // True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with radius 12 // // optional - IsBlurred bool `json:"is_blurred"` + IsBlurred bool `json:"is_blurred,omitempty"` + // BackgroundTypeWallpaper and BackgroundTypePattern only. // True, if the background moves slightly when the device is tilted // // optional - IsMoving bool `json:"is_moving"` + IsMoving bool `json:"is_moving,omitempty"` + // BackgroundTypePattern only. // Intensity of the pattern when it is shown above the filled background; 0-100 Intensity int `json:"intensity"` + // BackgroundTypePattern only. // True, if the background fill must be applied only to the pattern itself. // All other pixels are black in this case. For dark themes only // // optional - IsInverted bool `json:"is_inverted"` + IsInverted bool `json:"is_inverted,omitempty"` + // BackgroundTypeChatTheme only. // Name of the chat theme, which is usually an emoji ThemeName string `json:"theme_name"` } From d0fa8e929e4d1416b1db97b1d0c004816ca4e5df Mon Sep 17 00:00:00 2001 From: bobra Date: Wed, 15 May 2024 02:57:25 +0200 Subject: [PATCH 4/5] Fix missing ParseMode in InlineQueryResultVideo ParseMode for this type actually exists, but was missed in the original repo. https://core.telegram.org/bots/api#inlinequeryresultvideo --- types.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/types.go b/types.go index 0828a0b..4aa4b81 100644 --- a/types.go +++ b/types.go @@ -4406,9 +4406,15 @@ type InlineQueryResultVideo struct { // // optional Caption string `json:"caption,omitempty"` - // Width video width + // ParseMode mode for parsing entities in the video caption. + // See formatting options for more details + // (https://core.telegram.org/bots/api#formatting-options). // // optional + ParseMode string `json:"parse_mode,omitempty"` + // Width video width + // + // optional Width int `json:"video_width,omitempty"` // Height video height // @@ -4448,7 +4454,7 @@ type InlineQueryResultVoice struct { // // optional Caption string `json:"caption,omitempty"` - // ParseMode mode for parsing entities in the video caption. + // ParseMode mode for parsing entities in the voice caption. // See formatting options for more details // (https://core.telegram.org/bots/api#formatting-options). // From bece330506ef0674ff37c1bc068794f18c1b4bd9 Mon Sep 17 00:00:00 2001 From: stdkhai Date: Fri, 31 May 2024 19:21:42 +0300 Subject: [PATCH 5/5] Bot API 7.4 implementation --- configs.go | 80 ++++++++++++++++++++++++++++++++--------------- helper_structs.go | 12 ++++--- types.go | 65 ++++++++++++++++++++++++++++++++++---- types_test.go | 1 + 4 files changed, 122 insertions(+), 36 deletions(-) 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.