From 5523ed2b064efc9c8bc6b4711242c1dd8787c7b5 Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Sat, 9 May 2026 20:26:08 +0100 Subject: [PATCH] refactor(api): unify per-variant single-value enums into shared union-level enums MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each sealed-interface union with N variants used to emit N typed-string enums, one per variant, each holding exactly one wire value. Codegen now detects this pattern and emits ONE unified enum at the union level, retyping every variant's discriminator field to point at it. Unified enums (11 unions, 44 constants total): - ChatMemberStatus (6) - MessageOriginType (4) - BackgroundFillType (3) - BackgroundTypeKind (4) - ChatBoostSourceKind (3) - OwnedGiftType (2) - PaidMediaType (4) - ReactionTypeKind (3) - RevenueWithdrawalStateKind (3) - StoryAreaTypeKind (5) - TransactionPartnerType (7) Naming-collision cases (union name already ends in a discriminator concept noun, so the natural concat would stutter): BackgroundType, ReactionType, StoryAreaType, ChatBoostSource, RevenueWithdrawalState. The unified name ends with 'Kind' instead. 44 obsolete per-variant single-value enum types removed (e.g. ChatMemberOwnerStatus, MessageOriginUserType). The variant struct types themselves (ChatMemberOwner etc.) are unchanged; only their per-variant single-value enum aliases go away. Auto-inject MarshalJSON (commit 370c9c0) is unaffected — variant wire values still come from the discriminator-extractor pass. Call-site cleanup: - dispatch/filters/chatmember/chatmember_test.go - api/marshaljson_variants_test.go New test: api/unifiedenum_test.go covers ChatMemberStatus and MessageOriginType: variant-field retype, direct comparison without conversion, marshal discriminator preservation, full round-trip, stutter-suffix Kind sanity check. --- api/enums.gen.go | 263 ++--- api/marshaljson_variants_test.go | 2 +- api/types.gen.go | 88 +- api/unifiedenum_test.go | 182 ++++ cmd/genapi/enums.go | 176 ++++ .../filters/chatmember/chatmember_test.go | 14 +- docs/reference/api.md | 907 ++++-------------- 7 files changed, 656 insertions(+), 976 deletions(-) create mode 100644 api/unifiedenum_test.go diff --git a/api/enums.gen.go b/api/enums.gen.go index 63162a3..9cff2d2 100644 --- a/api/enums.gen.go +++ b/api/enums.gen.go @@ -4,100 +4,40 @@ package api -type BackgroundFillFreeformGradientType string +type BackgroundFillType string const ( - BackgroundFillFreeformGradientTypeFreeformGradient BackgroundFillFreeformGradientType = "freeform_gradient" + BackgroundFillTypeSolid BackgroundFillType = "solid" + BackgroundFillTypeGradient BackgroundFillType = "gradient" + BackgroundFillTypeFreeformGradient BackgroundFillType = "freeform_gradient" ) -type BackgroundFillGradientType string +type BackgroundTypeKind string const ( - BackgroundFillGradientTypeGradient BackgroundFillGradientType = "gradient" + BackgroundTypeKindFill BackgroundTypeKind = "fill" + BackgroundTypeKindWallpaper BackgroundTypeKind = "wallpaper" + BackgroundTypeKindPattern BackgroundTypeKind = "pattern" + BackgroundTypeKindChatTheme BackgroundTypeKind = "chat_theme" ) -type BackgroundFillSolidType string +type ChatBoostSourceKind string const ( - BackgroundFillSolidTypeSolid BackgroundFillSolidType = "solid" + ChatBoostSourceKindPremium ChatBoostSourceKind = "premium" + ChatBoostSourceKindGiftCode ChatBoostSourceKind = "gift_code" + ChatBoostSourceKindGiveaway ChatBoostSourceKind = "giveaway" ) -type BackgroundTypeChatThemeType string +type ChatMemberStatus string const ( - BackgroundTypeChatThemeTypeChatTheme BackgroundTypeChatThemeType = "chat_theme" -) - -type BackgroundTypeFillType string - -const ( - BackgroundTypeFillTypeFill BackgroundTypeFillType = "fill" -) - -type BackgroundTypePatternType string - -const ( - BackgroundTypePatternTypePattern BackgroundTypePatternType = "pattern" -) - -type BackgroundTypeWallpaperType string - -const ( - BackgroundTypeWallpaperTypeWallpaper BackgroundTypeWallpaperType = "wallpaper" -) - -type ChatBoostSourceGiftCodeSource string - -const ( - ChatBoostSourceGiftCodeSourceGiftCode ChatBoostSourceGiftCodeSource = "gift_code" -) - -type ChatBoostSourceGiveawaySource string - -const ( - ChatBoostSourceGiveawaySourceGiveaway ChatBoostSourceGiveawaySource = "giveaway" -) - -type ChatBoostSourcePremiumSource string - -const ( - ChatBoostSourcePremiumSourcePremium ChatBoostSourcePremiumSource = "premium" -) - -type ChatMemberAdministratorStatus string - -const ( - ChatMemberAdministratorStatusAdministrator ChatMemberAdministratorStatus = "administrator" -) - -type ChatMemberBannedStatus string - -const ( - ChatMemberBannedStatusKicked ChatMemberBannedStatus = "kicked" -) - -type ChatMemberLeftStatus string - -const ( - ChatMemberLeftStatusLeft ChatMemberLeftStatus = "left" -) - -type ChatMemberMemberStatus string - -const ( - ChatMemberMemberStatusMember ChatMemberMemberStatus = "member" -) - -type ChatMemberOwnerStatus string - -const ( - ChatMemberOwnerStatusCreator ChatMemberOwnerStatus = "creator" -) - -type ChatMemberRestrictedStatus string - -const ( - ChatMemberRestrictedStatusRestricted ChatMemberRestrictedStatus = "restricted" + ChatMemberStatusCreator ChatMemberStatus = "creator" + ChatMemberStatusAdministrator ChatMemberStatus = "administrator" + ChatMemberStatusMember ChatMemberStatus = "member" + ChatMemberStatusRestricted ChatMemberStatus = "restricted" + ChatMemberStatusLeft ChatMemberStatus = "left" + ChatMemberStatusKicked ChatMemberStatus = "kicked" ) type ChatType string @@ -202,64 +142,29 @@ const ( MessageEntityTypeDateTime MessageEntityType = "date_time" ) -type MessageOriginChannelType string +type MessageOriginType string const ( - MessageOriginChannelTypeChannel MessageOriginChannelType = "channel" + MessageOriginTypeUser MessageOriginType = "user" + MessageOriginTypeHiddenUser MessageOriginType = "hidden_user" + MessageOriginTypeChat MessageOriginType = "chat" + MessageOriginTypeChannel MessageOriginType = "channel" ) -type MessageOriginChatType string +type OwnedGiftType string const ( - MessageOriginChatTypeChat MessageOriginChatType = "chat" + OwnedGiftTypeRegular OwnedGiftType = "regular" + OwnedGiftTypeUnique OwnedGiftType = "unique" ) -type MessageOriginHiddenUserType string +type PaidMediaType string const ( - MessageOriginHiddenUserTypeHiddenUser MessageOriginHiddenUserType = "hidden_user" -) - -type MessageOriginUserType string - -const ( - MessageOriginUserTypeUser MessageOriginUserType = "user" -) - -type OwnedGiftRegularType string - -const ( - OwnedGiftRegularTypeRegular OwnedGiftRegularType = "regular" -) - -type OwnedGiftUniqueType string - -const ( - OwnedGiftUniqueTypeUnique OwnedGiftUniqueType = "unique" -) - -type PaidMediaLivePhotoType string - -const ( - PaidMediaLivePhotoTypeLivePhoto PaidMediaLivePhotoType = "live_photo" -) - -type PaidMediaPhotoType string - -const ( - PaidMediaPhotoTypePhoto PaidMediaPhotoType = "photo" -) - -type PaidMediaPreviewType string - -const ( - PaidMediaPreviewTypePreview PaidMediaPreviewType = "preview" -) - -type PaidMediaVideoType string - -const ( - PaidMediaVideoTypeVideo PaidMediaVideoType = "video" + PaidMediaTypeLivePhoto PaidMediaType = "live_photo" + PaidMediaTypePhoto PaidMediaType = "photo" + PaidMediaTypePreview PaidMediaType = "preview" + PaidMediaTypeVideo PaidMediaType = "video" ) type ParseMode string @@ -328,22 +233,12 @@ const ( PollTypeQuiz PollType = "quiz" ) -type ReactionTypeCustomEmojiType string +type ReactionTypeKind string const ( - ReactionTypeCustomEmojiTypeCustomEmoji ReactionTypeCustomEmojiType = "custom_emoji" -) - -type ReactionTypeEmojiType string - -const ( - ReactionTypeEmojiTypeEmoji ReactionTypeEmojiType = "emoji" -) - -type ReactionTypePaidType string - -const ( - ReactionTypePaidTypePaid ReactionTypePaidType = "paid" + ReactionTypeKindEmoji ReactionTypeKind = "emoji" + ReactionTypeKindCustomEmoji ReactionTypeKind = "custom_emoji" + ReactionTypeKindPaid ReactionTypeKind = "paid" ) type RefundedPaymentCurrency string @@ -352,22 +247,12 @@ const ( RefundedPaymentCurrencyXTR RefundedPaymentCurrency = "XTR" ) -type RevenueWithdrawalStateFailedType string +type RevenueWithdrawalStateKind string const ( - RevenueWithdrawalStateFailedTypeFailed RevenueWithdrawalStateFailedType = "failed" -) - -type RevenueWithdrawalStatePendingType string - -const ( - RevenueWithdrawalStatePendingTypePending RevenueWithdrawalStatePendingType = "pending" -) - -type RevenueWithdrawalStateSucceededType string - -const ( - RevenueWithdrawalStateSucceededTypeSucceeded RevenueWithdrawalStateSucceededType = "succeeded" + RevenueWithdrawalStateKindPending RevenueWithdrawalStateKind = "pending" + RevenueWithdrawalStateKindSucceeded RevenueWithdrawalStateKind = "succeeded" + RevenueWithdrawalStateKindFailed RevenueWithdrawalStateKind = "failed" ) type StickerType string @@ -378,34 +263,14 @@ const ( StickerTypeCustomEmoji StickerType = "custom_emoji" ) -type StoryAreaTypeLinkType string +type StoryAreaTypeKind string const ( - StoryAreaTypeLinkTypeLink StoryAreaTypeLinkType = "link" -) - -type StoryAreaTypeLocationType string - -const ( - StoryAreaTypeLocationTypeLocation StoryAreaTypeLocationType = "location" -) - -type StoryAreaTypeSuggestedReactionType string - -const ( - StoryAreaTypeSuggestedReactionTypeSuggestedReaction StoryAreaTypeSuggestedReactionType = "suggested_reaction" -) - -type StoryAreaTypeUniqueGiftType string - -const ( - StoryAreaTypeUniqueGiftTypeUniqueGift StoryAreaTypeUniqueGiftType = "unique_gift" -) - -type StoryAreaTypeWeatherType string - -const ( - StoryAreaTypeWeatherTypeWeather StoryAreaTypeWeatherType = "weather" + StoryAreaTypeKindLocation StoryAreaTypeKind = "location" + StoryAreaTypeKindSuggestedReaction StoryAreaTypeKind = "suggested_reaction" + StoryAreaTypeKindLink StoryAreaTypeKind = "link" + StoryAreaTypeKindWeather StoryAreaTypeKind = "weather" + StoryAreaTypeKindUniqueGift StoryAreaTypeKind = "unique_gift" ) type SuggestedPostInfoState string @@ -430,34 +295,16 @@ const ( SuggestedPostRefundedReasonPaymentRefunded SuggestedPostRefundedReason = "payment_refunded" ) -type TransactionPartnerAffiliateProgramType string +type TransactionPartnerType string const ( - TransactionPartnerAffiliateProgramTypeAffiliateProgram TransactionPartnerAffiliateProgramType = "affiliate_program" -) - -type TransactionPartnerFragmentType string - -const ( - TransactionPartnerFragmentTypeFragment TransactionPartnerFragmentType = "fragment" -) - -type TransactionPartnerOtherType string - -const ( - TransactionPartnerOtherTypeOther TransactionPartnerOtherType = "other" -) - -type TransactionPartnerTelegramAdsType string - -const ( - TransactionPartnerTelegramAdsTypeTelegramAds TransactionPartnerTelegramAdsType = "telegram_ads" -) - -type TransactionPartnerTelegramApiType string - -const ( - TransactionPartnerTelegramApiTypeTelegramApi TransactionPartnerTelegramApiType = "telegram_api" + TransactionPartnerTypeUser TransactionPartnerType = "user" + TransactionPartnerTypeChat TransactionPartnerType = "chat" + TransactionPartnerTypeAffiliateProgram TransactionPartnerType = "affiliate_program" + TransactionPartnerTypeFragment TransactionPartnerType = "fragment" + TransactionPartnerTypeTelegramAds TransactionPartnerType = "telegram_ads" + TransactionPartnerTypeTelegramApi TransactionPartnerType = "telegram_api" + TransactionPartnerTypeOther TransactionPartnerType = "other" ) type TransactionPartnerUserTransactionType string diff --git a/api/marshaljson_variants_test.go b/api/marshaljson_variants_test.go index a7cb06c..434d56f 100644 --- a/api/marshaljson_variants_test.go +++ b/api/marshaljson_variants_test.go @@ -65,7 +65,7 @@ func TestMarshalJSON_RoundTrip(t *testing.T) { round, ok := out.(*ChatMemberLeft) require.True(t, ok, "expected *ChatMemberLeft, got %T", out) - require.Equal(t, ChatMemberLeftStatusLeft, round.Status) + require.Equal(t, ChatMemberStatusLeft, round.Status) require.Equal(t, orig.User.ID, round.User.ID) require.Equal(t, orig.User.FirstName, round.User.FirstName) } diff --git a/api/types.gen.go b/api/types.gen.go index f4f69d2..6f945b0 100644 --- a/api/types.gen.go +++ b/api/types.gen.go @@ -800,7 +800,7 @@ func UnmarshalMessageOrigin(data []byte) (MessageOrigin, error) { // The message was originally sent by a known user. type MessageOriginUser struct { // Type of the message origin, always “user” - Type MessageOriginUserType `json:"type"` + Type MessageOriginType `json:"type"` // Date the message was sent originally in Unix time Date int64 `json:"date"` // User that sent the message originally @@ -826,7 +826,7 @@ func (v *MessageOriginUser) MarshalJSON() ([]byte, error) { // The message was originally sent by an unknown user. type MessageOriginHiddenUser struct { // Type of the message origin, always “hidden_user” - Type MessageOriginHiddenUserType `json:"type"` + Type MessageOriginType `json:"type"` // Date the message was sent originally in Unix time Date int64 `json:"date"` // Name of the user that sent the message originally @@ -852,7 +852,7 @@ func (v *MessageOriginHiddenUser) MarshalJSON() ([]byte, error) { // The message was originally sent on behalf of a chat to a group chat. type MessageOriginChat struct { // Type of the message origin, always “chat” - Type MessageOriginChatType `json:"type"` + Type MessageOriginType `json:"type"` // Date the message was sent originally in Unix time Date int64 `json:"date"` // Chat that sent the message originally @@ -880,7 +880,7 @@ func (v *MessageOriginChat) MarshalJSON() ([]byte, error) { // The message was originally sent to a channel chat. type MessageOriginChannel struct { // Type of the message origin, always “channel” - Type MessageOriginChannelType `json:"type"` + Type MessageOriginType `json:"type"` // Date the message was sent originally in Unix time Date int64 `json:"date"` // Channel chat to which the message was originally sent @@ -1174,7 +1174,7 @@ func UnmarshalPaidMedia(data []byte) (PaidMedia, error) { // The paid media is a live photo. type PaidMediaLivePhoto struct { // Type of the paid media, always “live_photo” - Type PaidMediaLivePhotoType `json:"type"` + Type PaidMediaType `json:"type"` // The photo LivePhoto LivePhoto `json:"live_photo"` } @@ -1198,7 +1198,7 @@ func (v *PaidMediaLivePhoto) MarshalJSON() ([]byte, error) { // The paid media is a photo. type PaidMediaPhoto struct { // Type of the paid media, always “photo” - Type PaidMediaPhotoType `json:"type"` + Type PaidMediaType `json:"type"` // The photo Photo []PhotoSize `json:"photo"` } @@ -1222,7 +1222,7 @@ func (v *PaidMediaPhoto) MarshalJSON() ([]byte, error) { // The paid media isn't available before the payment. type PaidMediaPreview struct { // Type of the paid media, always “preview” - Type PaidMediaPreviewType `json:"type"` + Type PaidMediaType `json:"type"` // Optional. Media width as defined by the sender Width *int64 `json:"width,omitempty"` // Optional. Media height as defined by the sender @@ -1250,7 +1250,7 @@ func (v *PaidMediaPreview) MarshalJSON() ([]byte, error) { // The paid media is a video. type PaidMediaVideo struct { // Type of the paid media, always “video” - Type PaidMediaVideoType `json:"type"` + Type PaidMediaType `json:"type"` // The video Video Video `json:"video"` } @@ -1752,7 +1752,7 @@ func UnmarshalBackgroundFill(data []byte) (BackgroundFill, error) { // The background is filled using the selected color. type BackgroundFillSolid struct { // Type of the background fill, always “solid” - Type BackgroundFillSolidType `json:"type"` + Type BackgroundFillType `json:"type"` // The color of the background fill in the RGB24 format Color int64 `json:"color"` } @@ -1776,7 +1776,7 @@ func (v *BackgroundFillSolid) MarshalJSON() ([]byte, error) { // The background is a gradient fill. type BackgroundFillGradient struct { // Type of the background fill, always “gradient” - Type BackgroundFillGradientType `json:"type"` + Type BackgroundFillType `json:"type"` // Top color of the gradient in the RGB24 format TopColor int64 `json:"top_color"` // Bottom color of the gradient in the RGB24 format @@ -1804,7 +1804,7 @@ func (v *BackgroundFillGradient) MarshalJSON() ([]byte, error) { // The background is a freeform gradient that rotates after every message in the chat. type BackgroundFillFreeformGradient struct { // Type of the background fill, always “freeform_gradient” - Type BackgroundFillFreeformGradientType `json:"type"` + Type BackgroundFillType `json:"type"` // A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format Colors []int64 `json:"colors"` } @@ -1878,7 +1878,7 @@ func UnmarshalBackgroundType(data []byte) (BackgroundType, error) { // The background is automatically filled based on the selected colors. type BackgroundTypeFill struct { // Type of the background, always “fill” - Type BackgroundTypeFillType `json:"type"` + Type BackgroundTypeKind `json:"type"` // The background fill Fill BackgroundFill `json:"fill"` // Dimming of the background in dark themes, as a percentage; 0-100 @@ -1928,7 +1928,7 @@ func (m *BackgroundTypeFill) UnmarshalJSON(data []byte) error { // The background is a wallpaper in the JPEG format. type BackgroundTypeWallpaper struct { // Type of the background, always “wallpaper” - Type BackgroundTypeWallpaperType `json:"type"` + Type BackgroundTypeKind `json:"type"` // Document with the wallpaper Document Document `json:"document"` // Dimming of the background in dark themes, as a percentage; 0-100 @@ -1958,7 +1958,7 @@ func (v *BackgroundTypeWallpaper) MarshalJSON() ([]byte, error) { // 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 BackgroundTypePatternType `json:"type"` + Type BackgroundTypeKind `json:"type"` // Document with the pattern Document Document `json:"document"` // The background fill that is combined with the pattern @@ -2014,7 +2014,7 @@ func (m *BackgroundTypePattern) UnmarshalJSON(data []byte) error { // The background is taken directly from a built-in chat theme. type BackgroundTypeChatTheme struct { // Type of the background, always “chat_theme” - Type BackgroundTypeChatThemeType `json:"type"` + Type BackgroundTypeKind `json:"type"` // Name of the chat theme, which is usually an emoji ThemeName string `json:"theme_name"` } @@ -2808,7 +2808,7 @@ func UnmarshalChatMember(data []byte) (ChatMember, error) { // Represents a chat member that owns the chat and has all administrator privileges. type ChatMemberOwner struct { // The member's status in the chat, always “creator” - Status ChatMemberOwnerStatus `json:"status"` + Status ChatMemberStatus `json:"status"` // Information about the user User User `json:"user"` // True, if the user's presence in the chat is hidden @@ -2836,7 +2836,7 @@ func (v *ChatMemberOwner) MarshalJSON() ([]byte, error) { // Represents a chat member that has some additional privileges. type ChatMemberAdministrator struct { // The member's status in the chat, always “administrator” - Status ChatMemberAdministratorStatus `json:"status"` + Status ChatMemberStatus `json:"status"` // Information about the user User User `json:"user"` // True, if the bot is allowed to edit administrator privileges of that user @@ -2898,7 +2898,7 @@ func (v *ChatMemberAdministrator) MarshalJSON() ([]byte, error) { // Represents a chat member that has no additional privileges or restrictions. type ChatMemberMember struct { // The member's status in the chat, always “member” - Status ChatMemberMemberStatus `json:"status"` + Status ChatMemberStatus `json:"status"` // Optional. Tag of the member Tag string `json:"tag,omitempty"` // Information about the user @@ -2926,7 +2926,7 @@ func (v *ChatMemberMember) MarshalJSON() ([]byte, error) { // Represents a chat member that is under certain restrictions in the chat. Supergroups only. type ChatMemberRestricted struct { // The member's status in the chat, always “restricted” - Status ChatMemberRestrictedStatus `json:"status"` + Status ChatMemberStatus `json:"status"` // Optional. Tag of the member Tag string `json:"tag,omitempty"` // Information about the user @@ -2988,7 +2988,7 @@ func (v *ChatMemberRestricted) MarshalJSON() ([]byte, error) { // Represents a chat member that isn't currently a member of the chat, but may join it themselves. type ChatMemberLeft struct { // The member's status in the chat, always “left” - Status ChatMemberLeftStatus `json:"status"` + Status ChatMemberStatus `json:"status"` // Information about the user User User `json:"user"` } @@ -3012,7 +3012,7 @@ func (v *ChatMemberLeft) MarshalJSON() ([]byte, error) { // Represents a chat member that was banned in the chat and can't return to the chat or view chat messages. type ChatMemberBanned struct { // The member's status in the chat, always “kicked” - Status ChatMemberBannedStatus `json:"status"` + Status ChatMemberStatus `json:"status"` // Information about the user User User `json:"user"` // Date when restrictions will be lifted for this user; Unix time. If 0, then the user is banned forever @@ -3230,7 +3230,7 @@ func UnmarshalStoryAreaType(data []byte) (StoryAreaType, error) { // 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 StoryAreaTypeLocationType `json:"type"` + Type StoryAreaTypeKind `json:"type"` // Location latitude in degrees Latitude float64 `json:"latitude"` // Location longitude in degrees @@ -3258,7 +3258,7 @@ func (v *StoryAreaTypeLocation) MarshalJSON() ([]byte, error) { // 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 StoryAreaTypeSuggestedReactionType `json:"type"` + Type StoryAreaTypeKind `json:"type"` // Type of the reaction ReactionType ReactionType `json:"reaction_type"` // Optional. Pass True if the reaction area has a dark background @@ -3310,7 +3310,7 @@ func (m *StoryAreaTypeSuggestedReaction) UnmarshalJSON(data []byte) error { // 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 StoryAreaTypeLinkType `json:"type"` + Type StoryAreaTypeKind `json:"type"` // HTTP or tg:// URL to be opened when the area is clicked URL string `json:"url"` } @@ -3334,7 +3334,7 @@ func (v *StoryAreaTypeLink) MarshalJSON() ([]byte, error) { // 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 StoryAreaTypeWeatherType `json:"type"` + Type StoryAreaTypeKind `json:"type"` // Temperature, in degree Celsius Temperature float64 `json:"temperature"` // Emoji representing the weather @@ -3362,7 +3362,7 @@ func (v *StoryAreaTypeWeather) MarshalJSON() ([]byte, error) { // 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 StoryAreaTypeUniqueGiftType `json:"type"` + Type StoryAreaTypeKind `json:"type"` // Unique name of the gift Name string `json:"name"` } @@ -3470,7 +3470,7 @@ func UnmarshalReactionType(data []byte) (ReactionType, error) { // The reaction is based on an emoji. type ReactionTypeEmoji struct { // Type of the reaction, always “emoji” - Type ReactionTypeEmojiType `json:"type"` + Type ReactionTypeKind `json:"type"` // Reaction emoji. Currently, it can be one of "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" Emoji string `json:"emoji"` } @@ -3494,7 +3494,7 @@ func (v *ReactionTypeEmoji) MarshalJSON() ([]byte, error) { // The reaction is based on a custom emoji. type ReactionTypeCustomEmoji struct { // Type of the reaction, always “custom_emoji” - Type ReactionTypeCustomEmojiType `json:"type"` + Type ReactionTypeKind `json:"type"` // Custom emoji identifier CustomEmojiID string `json:"custom_emoji_id"` } @@ -3518,7 +3518,7 @@ func (v *ReactionTypeCustomEmoji) MarshalJSON() ([]byte, error) { // The reaction is paid. type ReactionTypePaid struct { // Type of the reaction, always “paid” - Type ReactionTypePaidType `json:"type"` + Type ReactionTypeKind `json:"type"` } // MarshalJSON encodes ReactionTypePaid with the discriminator field @@ -3880,7 +3880,7 @@ func UnmarshalOwnedGift(data []byte) (OwnedGift, error) { // Describes a regular gift owned by a user or a chat. type OwnedGiftRegular struct { // Type of the gift, always “regular” - Type OwnedGiftRegularType `json:"type"` + Type OwnedGiftType `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 @@ -3930,7 +3930,7 @@ func (v *OwnedGiftRegular) MarshalJSON() ([]byte, error) { // Describes a unique gift received and owned by a user or a chat. type OwnedGiftUnique struct { // Type of the gift, always “unique” - Type OwnedGiftUniqueType `json:"type"` + Type OwnedGiftType `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 @@ -4421,7 +4421,7 @@ func UnmarshalChatBoostSource(data []byte) (ChatBoostSource, error) { // The boost was obtained by subscribing to Telegram Premium or by gifting a Telegram Premium subscription to another user. type ChatBoostSourcePremium struct { // Source of the boost, always “premium” - Source ChatBoostSourcePremiumSource `json:"source"` + Source ChatBoostSourceKind `json:"source"` // User that boosted the chat User User `json:"user"` } @@ -4445,7 +4445,7 @@ func (v *ChatBoostSourcePremium) MarshalJSON() ([]byte, error) { // The boost was obtained by the creation of Telegram Premium gift codes to boost a chat. Each such code boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription. type ChatBoostSourceGiftCode struct { // Source of the boost, always “gift_code” - Source ChatBoostSourceGiftCodeSource `json:"source"` + Source ChatBoostSourceKind `json:"source"` // User for which the gift code was created User User `json:"user"` } @@ -4469,7 +4469,7 @@ func (v *ChatBoostSourceGiftCode) MarshalJSON() ([]byte, error) { // 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 ChatBoostSourceGiveawaySource `json:"source"` + Source ChatBoostSourceKind `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; for Telegram Premium giveaways only @@ -6632,7 +6632,7 @@ func UnmarshalRevenueWithdrawalState(data []byte) (RevenueWithdrawalState, error // The withdrawal is in progress. type RevenueWithdrawalStatePending struct { // Type of the state, always “pending” - Type RevenueWithdrawalStatePendingType `json:"type"` + Type RevenueWithdrawalStateKind `json:"type"` } // MarshalJSON encodes RevenueWithdrawalStatePending with the discriminator field @@ -6654,7 +6654,7 @@ func (v *RevenueWithdrawalStatePending) MarshalJSON() ([]byte, error) { // The withdrawal succeeded. type RevenueWithdrawalStateSucceeded struct { // Type of the state, always “succeeded” - Type RevenueWithdrawalStateSucceededType `json:"type"` + Type RevenueWithdrawalStateKind `json:"type"` // Date the withdrawal was completed in Unix time Date int64 `json:"date"` // An HTTPS URL that can be used to see transaction details @@ -6680,7 +6680,7 @@ func (v *RevenueWithdrawalStateSucceeded) MarshalJSON() ([]byte, error) { // The withdrawal failed and the transaction was refunded. type RevenueWithdrawalStateFailed struct { // Type of the state, always “failed” - Type RevenueWithdrawalStateFailedType `json:"type"` + Type RevenueWithdrawalStateKind `json:"type"` } // MarshalJSON encodes RevenueWithdrawalStateFailed with the discriminator field @@ -6780,7 +6780,7 @@ func UnmarshalTransactionPartner(data []byte) (TransactionPartner, error) { // Describes a transaction with a user. type TransactionPartnerUser struct { // Type of the transaction partner, always “user” - Type MessageOriginUserType `json:"type"` + Type TransactionPartnerType `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 TransactionPartnerUserTransactionType `json:"transaction_type"` // Information about the user @@ -6852,7 +6852,7 @@ func (m *TransactionPartnerUser) UnmarshalJSON(data []byte) error { // Describes a transaction with a chat. type TransactionPartnerChat struct { // Type of the transaction partner, always “chat” - Type MessageOriginChatType `json:"type"` + Type TransactionPartnerType `json:"type"` // Information about the chat Chat Chat `json:"chat"` // Optional. The gift sent to the chat by the bot @@ -6878,7 +6878,7 @@ func (v *TransactionPartnerChat) MarshalJSON() ([]byte, error) { // 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 TransactionPartnerAffiliateProgramType `json:"type"` + Type TransactionPartnerType `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 @@ -6904,7 +6904,7 @@ func (v *TransactionPartnerAffiliateProgram) MarshalJSON() ([]byte, error) { // Describes a withdrawal transaction with Fragment. type TransactionPartnerFragment struct { // Type of the transaction partner, always “fragment” - Type TransactionPartnerFragmentType `json:"type"` + Type TransactionPartnerType `json:"type"` // Optional. State of the transaction if the transaction is outgoing WithdrawalState RevenueWithdrawalState `json:"withdrawal_state,omitempty"` } @@ -6952,7 +6952,7 @@ func (m *TransactionPartnerFragment) UnmarshalJSON(data []byte) error { // Describes a withdrawal transaction to the Telegram Ads platform. type TransactionPartnerTelegramAds struct { // Type of the transaction partner, always “telegram_ads” - Type TransactionPartnerTelegramAdsType `json:"type"` + Type TransactionPartnerType `json:"type"` } // MarshalJSON encodes TransactionPartnerTelegramAds with the discriminator field @@ -6974,7 +6974,7 @@ func (v *TransactionPartnerTelegramAds) MarshalJSON() ([]byte, error) { // Describes a transaction with payment for paid broadcasting. type TransactionPartnerTelegramApi struct { // Type of the transaction partner, always “telegram_api” - Type TransactionPartnerTelegramApiType `json:"type"` + Type TransactionPartnerType `json:"type"` // The number of successful requests that exceeded regular limits and were therefore billed RequestCount int64 `json:"request_count"` } @@ -6998,7 +6998,7 @@ func (v *TransactionPartnerTelegramApi) MarshalJSON() ([]byte, error) { // Describes a transaction with an unknown source or recipient. type TransactionPartnerOther struct { // Type of the transaction partner, always “other” - Type TransactionPartnerOtherType `json:"type"` + Type TransactionPartnerType `json:"type"` } // MarshalJSON encodes TransactionPartnerOther with the discriminator field diff --git a/api/unifiedenum_test.go b/api/unifiedenum_test.go new file mode 100644 index 0000000..a00fdd4 --- /dev/null +++ b/api/unifiedenum_test.go @@ -0,0 +1,182 @@ +package api + +import ( + "reflect" + "testing" + + json "github.com/goccy/go-json" + "github.com/stretchr/testify/require" +) + +// TestUnifiedEnum_ChatMemberStatus_HasAllConstants asserts the unified +// enum exists with the full set of variant values and is a typed string. +func TestUnifiedEnum_ChatMemberStatus_HasAllConstants(t *testing.T) { + require.IsType(t, ChatMemberStatus(""), ChatMemberStatusCreator) + + values := []ChatMemberStatus{ + ChatMemberStatusCreator, + ChatMemberStatusAdministrator, + ChatMemberStatusMember, + ChatMemberStatusRestricted, + ChatMemberStatusLeft, + ChatMemberStatusKicked, + } + wantWire := []string{"creator", "administrator", "member", "restricted", "left", "kicked"} + require.Len(t, values, 6) + for i, v := range values { + require.Equal(t, wantWire[i], string(v)) + } +} + +// TestUnifiedEnum_ChatMember_VariantFieldsRetyped confirms every concrete +// variant's discriminator field is the unified enum, NOT a per-variant +// alias type. Reflection walks the struct field directly. +func TestUnifiedEnum_ChatMember_VariantFieldsRetyped(t *testing.T) { + cases := []struct { + name string + val any + }{ + {"ChatMemberOwner", &ChatMemberOwner{}}, + {"ChatMemberAdministrator", &ChatMemberAdministrator{}}, + {"ChatMemberMember", &ChatMemberMember{}}, + {"ChatMemberRestricted", &ChatMemberRestricted{}}, + {"ChatMemberLeft", &ChatMemberLeft{}}, + {"ChatMemberBanned", &ChatMemberBanned{}}, + } + wantType := reflect.TypeOf(ChatMemberStatus("")) + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + f, ok := reflect.TypeOf(tc.val).Elem().FieldByName("Status") + require.True(t, ok, "%s missing Status field", tc.name) + require.Equal(t, wantType, f.Type, "%s.Status type mismatch", tc.name) + }) + } +} + +// TestUnifiedEnum_ChatMember_DirectComparison verifies the unified enum +// lets callers compare a variant's Status directly against constants +// without conversion. +func TestUnifiedEnum_ChatMember_DirectComparison(t *testing.T) { + owner := &ChatMemberOwner{Status: ChatMemberStatusCreator} + require.True(t, owner.Status == ChatMemberStatusCreator) + require.False(t, owner.Status == ChatMemberStatusKicked) + + banned := &ChatMemberBanned{Status: ChatMemberStatusKicked} + require.True(t, banned.Status == ChatMemberStatusKicked) +} + +// TestUnifiedEnum_ChatMember_MarshalDiscriminator verifies the auto-inject +// MarshalJSON still emits the right wire discriminator after the enum +// retype — no regression from commit 370c9c0. +func TestUnifiedEnum_ChatMember_MarshalDiscriminator(t *testing.T) { + cases := []struct { + val any + wantWire string + }{ + {&ChatMemberOwner{User: User{ID: 1, FirstName: "a"}}, "creator"}, + {&ChatMemberAdministrator{User: User{ID: 2, FirstName: "b"}}, "administrator"}, + {&ChatMemberMember{User: User{ID: 3, FirstName: "c"}}, "member"}, + {&ChatMemberRestricted{User: User{ID: 4, FirstName: "d"}}, "restricted"}, + {&ChatMemberLeft{User: User{ID: 5, FirstName: "e"}}, "left"}, + {&ChatMemberBanned{User: User{ID: 6, FirstName: "f"}}, "kicked"}, + } + for _, tc := range cases { + raw, err := json.Marshal(tc.val) + require.NoError(t, err) + + var probe struct { + Status string `json:"status"` + } + require.NoError(t, json.Unmarshal(raw, &probe)) + require.Equal(t, tc.wantWire, probe.Status) + } +} + +// TestUnifiedEnum_ChatMember_RoundTrip confirms a marshal-unmarshal cycle +// preserves the unified-enum field value. +func TestUnifiedEnum_ChatMember_RoundTrip(t *testing.T) { + orig := &ChatMemberOwner{User: User{ID: 99, FirstName: "owner"}} + raw, err := json.Marshal(orig) + require.NoError(t, err) + + out, err := UnmarshalChatMember(raw) + require.NoError(t, err) + + round, ok := out.(*ChatMemberOwner) + require.True(t, ok, "expected *ChatMemberOwner, got %T", out) + require.Equal(t, ChatMemberStatusCreator, round.Status) + require.Equal(t, orig.User.ID, round.User.ID) +} + +// TestUnifiedEnum_MessageOriginType verifies a second union also unifies +// correctly — guards against a one-off implementation that only handles +// ChatMember. +func TestUnifiedEnum_MessageOriginType(t *testing.T) { + require.IsType(t, MessageOriginType(""), MessageOriginTypeUser) + + values := []MessageOriginType{ + MessageOriginTypeUser, + MessageOriginTypeHiddenUser, + MessageOriginTypeChat, + MessageOriginTypeChannel, + } + wantWire := []string{"user", "hidden_user", "chat", "channel"} + for i, v := range values { + require.Equal(t, wantWire[i], string(v)) + } + + // Variant fields use the unified type. + wantType := reflect.TypeOf(MessageOriginType("")) + for _, name := range []string{"MessageOriginUser", "MessageOriginHiddenUser", "MessageOriginChat", "MessageOriginChannel"} { + switch name { + case "MessageOriginUser": + f, ok := reflect.TypeOf(&MessageOriginUser{}).Elem().FieldByName("Type") + require.True(t, ok) + require.Equal(t, wantType, f.Type) + case "MessageOriginHiddenUser": + f, ok := reflect.TypeOf(&MessageOriginHiddenUser{}).Elem().FieldByName("Type") + require.True(t, ok) + require.Equal(t, wantType, f.Type) + case "MessageOriginChat": + f, ok := reflect.TypeOf(&MessageOriginChat{}).Elem().FieldByName("Type") + require.True(t, ok) + require.Equal(t, wantType, f.Type) + case "MessageOriginChannel": + f, ok := reflect.TypeOf(&MessageOriginChannel{}).Elem().FieldByName("Type") + require.True(t, ok) + require.Equal(t, wantType, f.Type) + } + } +} + +// TestUnifiedEnum_StutterSuffix_Kind covers the naming-collision rule: +// when the union name ends in a discriminator concept noun, the unified +// enum is suffixed with "Kind" to avoid stuttery names like +// "BackgroundTypeType". +func TestUnifiedEnum_StutterSuffix_Kind(t *testing.T) { + require.IsType(t, BackgroundTypeKind(""), BackgroundTypeKindFill) + require.IsType(t, ReactionTypeKind(""), ReactionTypeKindEmoji) + require.IsType(t, StoryAreaTypeKind(""), StoryAreaTypeKindLocation) + require.IsType(t, ChatBoostSourceKind(""), ChatBoostSourceKindPremium) + require.IsType(t, RevenueWithdrawalStateKind(""), RevenueWithdrawalStateKindPending) + + // Variant struct field types match the unified enum. + wantType := reflect.TypeOf(BackgroundTypeKind("")) + f, ok := reflect.TypeOf(&BackgroundTypeFill{}).Elem().FieldByName("Type") + require.True(t, ok) + require.Equal(t, wantType, f.Type) +} + +// TestUnifiedEnum_PerVariantTypesNotEmitted asserts the obsolete +// per-variant single-value enum types (e.g. ChatMemberOwnerStatus) are +// gone — ensures the codegen doesn't double-emit. We rely on compile-time +// behaviour: if any of these names existed, a referencing package would +// fail to build. Instead we verify the variant struct field type's name +// is the unified one. +func TestUnifiedEnum_PerVariantTypesNotEmitted(t *testing.T) { + got := reflect.TypeOf(&ChatMemberOwner{}).Elem() + statusField, ok := got.FieldByName("Status") + require.True(t, ok) + require.Equal(t, "ChatMemberStatus", statusField.Type.Name(), + "ChatMemberOwner.Status should be ChatMemberStatus, not ChatMemberOwnerStatus") +} diff --git a/cmd/genapi/enums.go b/cmd/genapi/enums.go index d706290..f1de13f 100644 --- a/cmd/genapi/enums.go +++ b/cmd/genapi/enums.go @@ -41,12 +41,25 @@ func planEnums(api *spec.API) *enumPlan { valueKey string // canonical key for value-set dedup } + // Unification pass: for each sealed-interface union, fold per-variant + // single-value enum fields that share a discriminator name into ONE + // unified enum at union level. Claimed (parent,fieldName) tuples are + // excluded from the per-field grouping below. + unifiedDecls, unifiedByField := planUnifiedUnionEnums(api) + claimed := func(parent, fieldName string) bool { + _, ok := unifiedByField[enumKey(parent, fieldName)] + return ok + } + var refs []ref collect := func(parent string, fields []spec.Field) { for _, f := range fields { if len(f.EnumValues) == 0 { continue } + if claimed(parent, f.Name) { + continue + } refs = append(refs, ref{ parent: parent, fieldName: f.Name, @@ -190,9 +203,172 @@ func planEnums(api *spec.API) *enumPlan { plan.decls[g.name] = enumDecl{Name: g.name, Values: g.values} _ = vk } + // Merge unified union enums (already named with stutter handling and + // keyed per-variant in unifiedByField). + for k, name := range unifiedByField { + plan.byField[k] = name + } + for name, d := range unifiedDecls { + plan.decls[name] = d + } return plan } +// planUnifiedUnionEnums detects sealed-interface unions whose variants +// share a single discriminator field with one enum value each, and emits +// ONE unified enum per union covering all variant values. Returns the +// declarations to emit and the per-(variant,fieldName) map to point each +// variant's field at the unified enum. +// +// A union qualifies when EVERY variant in t.OneOf: +// 1. defines a field with the same Go-name (e.g. "Status", "Type", "Source"); +// 2. that field is a required string with len(EnumValues)==1. +// +// The picked Go-name is the first one tried in this priority order: +// - knownDiscriminators[union].Field's Go-name (resolved via JSONName match); +// - "Type", "Status", "Source" (the three discriminators Telegram uses). +// +// First match wins; if none qualify, the union is skipped (variants keep +// their existing per-field treatment, which still single-emits via the +// regular grouping pass). +func planUnifiedUnionEnums(api *spec.API) (map[string]enumDecl, map[string]string) { + decls := map[string]enumDecl{} + byField := map[string]string{} + + typeByName := make(map[string]*spec.TypeDecl, len(api.Types)) + for i := range api.Types { + typeByName[api.Types[i].Name] = &api.Types[i] + } + + // Iterate unions in deterministic (declaration) order. + for ui := range api.Types { + u := &api.Types[ui] + if len(u.OneOf) == 0 { + continue + } + + // Resolve the variants. Skip unions where any variant is missing + // (defensive — shouldn't happen in a well-formed IR). + variants := make([]*spec.TypeDecl, 0, len(u.OneOf)) + for _, vName := range u.OneOf { + v, ok := typeByName[vName] + if !ok { + variants = nil + break + } + variants = append(variants, v) + } + if len(variants) == 0 { + continue + } + + // Build the candidate Go-name list. Priority order: + // 1. discriminator GoField from knownDiscriminators (resolved via JSONName); + // 2. "Type", "Status", "Source". + var candidateNames []string + seen := map[string]bool{} + add := func(name string) { + if name == "" || seen[name] { + return + } + seen[name] = true + candidateNames = append(candidateNames, name) + } + if ds, ok := knownDiscriminators[u.Name]; ok && ds.Field != "" { + // Resolve Go-name from the first variant whose field matches the JSON name. + for _, v := range variants { + for _, f := range v.Fields { + if f.JSONName == ds.Field { + add(f.Name) + break + } + } + } + } + for _, n := range []string{"Type", "Status", "Source"} { + add(n) + } + + // Find the first candidate Go-name where every variant has a + // matching single-value string-enum field. + var ( + pickedName string + pickedDocs map[string]spec.Field // variant name -> field + ) + for _, name := range candidateNames { + matches := map[string]spec.Field{} + ok := true + for _, v := range variants { + var hit *spec.Field + for fi := range v.Fields { + if v.Fields[fi].Name == name { + hit = &v.Fields[fi] + break + } + } + if hit == nil || + hit.Type.Kind != spec.KindPrimitive || + hit.Type.Name != "string" || + len(hit.EnumValues) != 1 { + ok = false + break + } + matches[v.Name] = *hit + } + if ok { + pickedName = name + pickedDocs = matches + break + } + } + if pickedName == "" { + continue + } + + // Build the unified enum name with stutter handling. + enumName := unifiedEnumName(u.Name, pickedName) + + // Collect values across variants in deterministic order, deduping. + valueOrder := make([]string, 0, len(variants)) + valueSeen := map[string]bool{} + for _, v := range u.OneOf { + f := pickedDocs[v] + val := f.EnumValues[0] + if valueSeen[val] { + continue + } + valueSeen[val] = true + valueOrder = append(valueOrder, val) + } + + decls[enumName] = enumDecl{Name: enumName, Values: valueOrder} + for _, v := range variants { + byField[enumKey(v.Name, pickedName)] = enumName + } + } + + return decls, byField +} + +// unifiedEnumName builds the union-level enum name. Falls back to a +// "Kind" suffix when the naive concatenation reads as a stutter: +// +// - union name ends in the field name verbatim (e.g. BackgroundType+Type); +// - union name ends in any "concept noun" — Type/Status/Source/State — +// so appending another such noun would duplicate the suffix +// (e.g. ChatBoostSource+Source, RevenueWithdrawalState+Type). +// +// Otherwise the natural concatenation wins (ChatMember+Status → +// ChatMemberStatus, MessageOrigin+Type → MessageOriginType). +func unifiedEnumName(unionName, fieldName string) string { + for _, suf := range []string{"Type", "Status", "Source", "State"} { + if strings.HasSuffix(unionName, suf) { + return unionName + "Kind" + } + } + return unionName + fieldName +} + // All returns the enum declarations sorted by name for deterministic emit. func (p *enumPlan) All() []enumDecl { out := make([]enumDecl, 0, len(p.decls)) diff --git a/dispatch/filters/chatmember/chatmember_test.go b/dispatch/filters/chatmember/chatmember_test.go index 1edb152..42c4520 100644 --- a/dispatch/filters/chatmember/chatmember_test.go +++ b/dispatch/filters/chatmember/chatmember_test.go @@ -12,15 +12,15 @@ func memberUpdate(status string, fromID int64) *api.ChatMemberUpdated { var newMember api.ChatMember switch status { case "member": - newMember = &api.ChatMemberMember{Status: api.ChatMemberMemberStatusMember} + newMember = &api.ChatMemberMember{Status: api.ChatMemberStatusMember} case "administrator": - newMember = &api.ChatMemberAdministrator{Status: api.ChatMemberAdministratorStatusAdministrator} + newMember = &api.ChatMemberAdministrator{Status: api.ChatMemberStatusAdministrator} case "kicked": - newMember = &api.ChatMemberBanned{Status: api.ChatMemberBannedStatusKicked} + newMember = &api.ChatMemberBanned{Status: api.ChatMemberStatusKicked} case "left": - newMember = &api.ChatMemberLeft{Status: api.ChatMemberLeftStatusLeft} + newMember = &api.ChatMemberLeft{Status: api.ChatMemberStatusLeft} default: - newMember = &api.ChatMemberMember{Status: api.ChatMemberMemberStatusMember} + newMember = &api.ChatMemberMember{Status: api.ChatMemberStatusMember} } return &api.ChatMemberUpdated{ From: api.User{ID: fromID}, @@ -70,7 +70,7 @@ func TestComposedFilters(t *testing.T) { func TestNewStatus_Owner(t *testing.T) { u := &api.ChatMemberUpdated{ From: api.User{ID: 1}, - NewChatMember: &api.ChatMemberOwner{Status: api.ChatMemberOwnerStatusCreator}, + NewChatMember: &api.ChatMemberOwner{Status: api.ChatMemberStatusCreator}, } require.True(t, cmfilter.NewStatus("creator")(u)) require.False(t, cmfilter.NewStatus("member")(u)) @@ -79,7 +79,7 @@ func TestNewStatus_Owner(t *testing.T) { func TestNewStatus_Restricted(t *testing.T) { u := &api.ChatMemberUpdated{ From: api.User{ID: 1}, - NewChatMember: &api.ChatMemberRestricted{Status: api.ChatMemberRestrictedStatusRestricted}, + NewChatMember: &api.ChatMemberRestricted{Status: api.ChatMemberStatusRestricted}, } require.True(t, cmfilter.NewStatus("restricted")(u)) require.False(t, cmfilter.NewStatus("member")(u)) diff --git a/docs/reference/api.md b/docs/reference/api.md index 4fcf67a..87cff2b 100644 --- a/docs/reference/api.md +++ b/docs/reference/api.md @@ -134,29 +134,24 @@ Package api contains the Telegram Bot API object types and method wrappers, gene - [func UnmarshalBackgroundFill\(data \[\]byte\) \(BackgroundFill, error\)](<#UnmarshalBackgroundFill>) - [type BackgroundFillFreeformGradient](<#BackgroundFillFreeformGradient>) - [func \(v \*BackgroundFillFreeformGradient\) MarshalJSON\(\) \(\[\]byte, error\)](<#BackgroundFillFreeformGradient.MarshalJSON>) -- [type BackgroundFillFreeformGradientType](<#BackgroundFillFreeformGradientType>) - [type BackgroundFillGradient](<#BackgroundFillGradient>) - [func \(v \*BackgroundFillGradient\) MarshalJSON\(\) \(\[\]byte, error\)](<#BackgroundFillGradient.MarshalJSON>) -- [type BackgroundFillGradientType](<#BackgroundFillGradientType>) - [type BackgroundFillSolid](<#BackgroundFillSolid>) - [func \(v \*BackgroundFillSolid\) MarshalJSON\(\) \(\[\]byte, error\)](<#BackgroundFillSolid.MarshalJSON>) -- [type BackgroundFillSolidType](<#BackgroundFillSolidType>) +- [type BackgroundFillType](<#BackgroundFillType>) - [type BackgroundType](<#BackgroundType>) - [func UnmarshalBackgroundType\(data \[\]byte\) \(BackgroundType, error\)](<#UnmarshalBackgroundType>) - [type BackgroundTypeChatTheme](<#BackgroundTypeChatTheme>) - [func \(v \*BackgroundTypeChatTheme\) MarshalJSON\(\) \(\[\]byte, error\)](<#BackgroundTypeChatTheme.MarshalJSON>) -- [type BackgroundTypeChatThemeType](<#BackgroundTypeChatThemeType>) - [type BackgroundTypeFill](<#BackgroundTypeFill>) - [func \(v \*BackgroundTypeFill\) MarshalJSON\(\) \(\[\]byte, error\)](<#BackgroundTypeFill.MarshalJSON>) - [func \(m \*BackgroundTypeFill\) UnmarshalJSON\(data \[\]byte\) error](<#BackgroundTypeFill.UnmarshalJSON>) -- [type BackgroundTypeFillType](<#BackgroundTypeFillType>) +- [type BackgroundTypeKind](<#BackgroundTypeKind>) - [type BackgroundTypePattern](<#BackgroundTypePattern>) - [func \(v \*BackgroundTypePattern\) MarshalJSON\(\) \(\[\]byte, error\)](<#BackgroundTypePattern.MarshalJSON>) - [func \(m \*BackgroundTypePattern\) UnmarshalJSON\(data \[\]byte\) error](<#BackgroundTypePattern.UnmarshalJSON>) -- [type BackgroundTypePatternType](<#BackgroundTypePatternType>) - [type BackgroundTypeWallpaper](<#BackgroundTypeWallpaper>) - [func \(v \*BackgroundTypeWallpaper\) MarshalJSON\(\) \(\[\]byte, error\)](<#BackgroundTypeWallpaper.MarshalJSON>) -- [type BackgroundTypeWallpaperType](<#BackgroundTypeWallpaperType>) - [type BanChatMemberParams](<#BanChatMemberParams>) - [type BanChatSenderChatParams](<#BanChatSenderChatParams>) - [type Birthdate](<#Birthdate>) @@ -210,13 +205,11 @@ Package api contains the Telegram Bot API object types and method wrappers, gene - [func UnmarshalChatBoostSource\(data \[\]byte\) \(ChatBoostSource, error\)](<#UnmarshalChatBoostSource>) - [type ChatBoostSourceGiftCode](<#ChatBoostSourceGiftCode>) - [func \(v \*ChatBoostSourceGiftCode\) MarshalJSON\(\) \(\[\]byte, error\)](<#ChatBoostSourceGiftCode.MarshalJSON>) -- [type ChatBoostSourceGiftCodeSource](<#ChatBoostSourceGiftCodeSource>) - [type ChatBoostSourceGiveaway](<#ChatBoostSourceGiveaway>) - [func \(v \*ChatBoostSourceGiveaway\) MarshalJSON\(\) \(\[\]byte, error\)](<#ChatBoostSourceGiveaway.MarshalJSON>) -- [type ChatBoostSourceGiveawaySource](<#ChatBoostSourceGiveawaySource>) +- [type ChatBoostSourceKind](<#ChatBoostSourceKind>) - [type ChatBoostSourcePremium](<#ChatBoostSourcePremium>) - [func \(v \*ChatBoostSourcePremium\) MarshalJSON\(\) \(\[\]byte, error\)](<#ChatBoostSourcePremium.MarshalJSON>) -- [type ChatBoostSourcePremiumSource](<#ChatBoostSourcePremiumSource>) - [type ChatBoostUpdated](<#ChatBoostUpdated>) - [type ChatFullInfo](<#ChatFullInfo>) - [func GetChat\(ctx context.Context, b \*client.Bot, p \*GetChatParams\) \(\*ChatFullInfo, error\)](<#GetChat>) @@ -242,22 +235,17 @@ Package api contains the Telegram Bot API object types and method wrappers, gene - [func UnmarshalChatMember\(data \[\]byte\) \(ChatMember, error\)](<#UnmarshalChatMember>) - [type ChatMemberAdministrator](<#ChatMemberAdministrator>) - [func \(v \*ChatMemberAdministrator\) MarshalJSON\(\) \(\[\]byte, error\)](<#ChatMemberAdministrator.MarshalJSON>) -- [type ChatMemberAdministratorStatus](<#ChatMemberAdministratorStatus>) - [type ChatMemberBanned](<#ChatMemberBanned>) - [func \(v \*ChatMemberBanned\) MarshalJSON\(\) \(\[\]byte, error\)](<#ChatMemberBanned.MarshalJSON>) -- [type ChatMemberBannedStatus](<#ChatMemberBannedStatus>) - [type ChatMemberLeft](<#ChatMemberLeft>) - [func \(v \*ChatMemberLeft\) MarshalJSON\(\) \(\[\]byte, error\)](<#ChatMemberLeft.MarshalJSON>) -- [type ChatMemberLeftStatus](<#ChatMemberLeftStatus>) - [type ChatMemberMember](<#ChatMemberMember>) - [func \(v \*ChatMemberMember\) MarshalJSON\(\) \(\[\]byte, error\)](<#ChatMemberMember.MarshalJSON>) -- [type ChatMemberMemberStatus](<#ChatMemberMemberStatus>) - [type ChatMemberOwner](<#ChatMemberOwner>) - [func \(v \*ChatMemberOwner\) MarshalJSON\(\) \(\[\]byte, error\)](<#ChatMemberOwner.MarshalJSON>) -- [type ChatMemberOwnerStatus](<#ChatMemberOwnerStatus>) - [type ChatMemberRestricted](<#ChatMemberRestricted>) - [func \(v \*ChatMemberRestricted\) MarshalJSON\(\) \(\[\]byte, error\)](<#ChatMemberRestricted.MarshalJSON>) -- [type ChatMemberRestrictedStatus](<#ChatMemberRestrictedStatus>) +- [type ChatMemberStatus](<#ChatMemberStatus>) - [type ChatMemberUpdated](<#ChatMemberUpdated>) - [func \(m \*ChatMemberUpdated\) UnmarshalJSON\(data \[\]byte\) error](<#ChatMemberUpdated.UnmarshalJSON>) - [type ChatOwnerChanged](<#ChatOwnerChanged>) @@ -564,16 +552,13 @@ Package api contains the Telegram Bot API object types and method wrappers, gene - [func UnmarshalMessageOrigin\(data \[\]byte\) \(MessageOrigin, error\)](<#UnmarshalMessageOrigin>) - [type MessageOriginChannel](<#MessageOriginChannel>) - [func \(v \*MessageOriginChannel\) MarshalJSON\(\) \(\[\]byte, error\)](<#MessageOriginChannel.MarshalJSON>) -- [type MessageOriginChannelType](<#MessageOriginChannelType>) - [type MessageOriginChat](<#MessageOriginChat>) - [func \(v \*MessageOriginChat\) MarshalJSON\(\) \(\[\]byte, error\)](<#MessageOriginChat.MarshalJSON>) -- [type MessageOriginChatType](<#MessageOriginChatType>) - [type MessageOriginHiddenUser](<#MessageOriginHiddenUser>) - [func \(v \*MessageOriginHiddenUser\) MarshalJSON\(\) \(\[\]byte, error\)](<#MessageOriginHiddenUser.MarshalJSON>) -- [type MessageOriginHiddenUserType](<#MessageOriginHiddenUserType>) +- [type MessageOriginType](<#MessageOriginType>) - [type MessageOriginUser](<#MessageOriginUser>) - [func \(v \*MessageOriginUser\) MarshalJSON\(\) \(\[\]byte, error\)](<#MessageOriginUser.MarshalJSON>) -- [type MessageOriginUserType](<#MessageOriginUserType>) - [type MessageReactionCountUpdated](<#MessageReactionCountUpdated>) - [type MessageReactionUpdated](<#MessageReactionUpdated>) - [func \(mru \*MessageReactionUpdated\) GetSender\(\) \*Sender](<#MessageReactionUpdated.GetSender>) @@ -583,10 +568,9 @@ Package api contains the Telegram Bot API object types and method wrappers, gene - [func UnmarshalOwnedGift\(data \[\]byte\) \(OwnedGift, error\)](<#UnmarshalOwnedGift>) - [type OwnedGiftRegular](<#OwnedGiftRegular>) - [func \(v \*OwnedGiftRegular\) MarshalJSON\(\) \(\[\]byte, error\)](<#OwnedGiftRegular.MarshalJSON>) -- [type OwnedGiftRegularType](<#OwnedGiftRegularType>) +- [type OwnedGiftType](<#OwnedGiftType>) - [type OwnedGiftUnique](<#OwnedGiftUnique>) - [func \(v \*OwnedGiftUnique\) MarshalJSON\(\) \(\[\]byte, error\)](<#OwnedGiftUnique.MarshalJSON>) -- [type OwnedGiftUniqueType](<#OwnedGiftUniqueType>) - [type OwnedGifts](<#OwnedGifts>) - [func GetBusinessAccountGifts\(ctx context.Context, b \*client.Bot, p \*GetBusinessAccountGiftsParams\) \(\*OwnedGifts, error\)](<#GetBusinessAccountGifts>) - [func GetChatGifts\(ctx context.Context, b \*client.Bot, p \*GetChatGiftsParams\) \(\*OwnedGifts, error\)](<#GetChatGifts>) @@ -598,17 +582,14 @@ Package api contains the Telegram Bot API object types and method wrappers, gene - [func \(m \*PaidMediaInfo\) UnmarshalJSON\(data \[\]byte\) error](<#PaidMediaInfo.UnmarshalJSON>) - [type PaidMediaLivePhoto](<#PaidMediaLivePhoto>) - [func \(v \*PaidMediaLivePhoto\) MarshalJSON\(\) \(\[\]byte, error\)](<#PaidMediaLivePhoto.MarshalJSON>) -- [type PaidMediaLivePhotoType](<#PaidMediaLivePhotoType>) - [type PaidMediaPhoto](<#PaidMediaPhoto>) - [func \(v \*PaidMediaPhoto\) MarshalJSON\(\) \(\[\]byte, error\)](<#PaidMediaPhoto.MarshalJSON>) -- [type PaidMediaPhotoType](<#PaidMediaPhotoType>) - [type PaidMediaPreview](<#PaidMediaPreview>) - [func \(v \*PaidMediaPreview\) MarshalJSON\(\) \(\[\]byte, error\)](<#PaidMediaPreview.MarshalJSON>) -- [type PaidMediaPreviewType](<#PaidMediaPreviewType>) - [type PaidMediaPurchased](<#PaidMediaPurchased>) +- [type PaidMediaType](<#PaidMediaType>) - [type PaidMediaVideo](<#PaidMediaVideo>) - [func \(v \*PaidMediaVideo\) MarshalJSON\(\) \(\[\]byte, error\)](<#PaidMediaVideo.MarshalJSON>) -- [type PaidMediaVideoType](<#PaidMediaVideoType>) - [type PaidMessagePriceChanged](<#PaidMessagePriceChanged>) - [type ParseMode](<#ParseMode>) - [type PassportData](<#PassportData>) @@ -664,13 +645,11 @@ Package api contains the Telegram Bot API object types and method wrappers, gene - [func UnmarshalReactionType\(data \[\]byte\) \(ReactionType, error\)](<#UnmarshalReactionType>) - [type ReactionTypeCustomEmoji](<#ReactionTypeCustomEmoji>) - [func \(v \*ReactionTypeCustomEmoji\) MarshalJSON\(\) \(\[\]byte, error\)](<#ReactionTypeCustomEmoji.MarshalJSON>) -- [type ReactionTypeCustomEmojiType](<#ReactionTypeCustomEmojiType>) - [type ReactionTypeEmoji](<#ReactionTypeEmoji>) - [func \(v \*ReactionTypeEmoji\) MarshalJSON\(\) \(\[\]byte, error\)](<#ReactionTypeEmoji.MarshalJSON>) -- [type ReactionTypeEmojiType](<#ReactionTypeEmojiType>) +- [type ReactionTypeKind](<#ReactionTypeKind>) - [type ReactionTypePaid](<#ReactionTypePaid>) - [func \(v \*ReactionTypePaid\) MarshalJSON\(\) \(\[\]byte, error\)](<#ReactionTypePaid.MarshalJSON>) -- [type ReactionTypePaidType](<#ReactionTypePaidType>) - [type ReadBusinessMessageParams](<#ReadBusinessMessageParams>) - [type RefundStarPaymentParams](<#RefundStarPaymentParams>) - [type RefundedPayment](<#RefundedPayment>) @@ -693,13 +672,11 @@ Package api contains the Telegram Bot API object types and method wrappers, gene - [func UnmarshalRevenueWithdrawalState\(data \[\]byte\) \(RevenueWithdrawalState, error\)](<#UnmarshalRevenueWithdrawalState>) - [type RevenueWithdrawalStateFailed](<#RevenueWithdrawalStateFailed>) - [func \(v \*RevenueWithdrawalStateFailed\) MarshalJSON\(\) \(\[\]byte, error\)](<#RevenueWithdrawalStateFailed.MarshalJSON>) -- [type RevenueWithdrawalStateFailedType](<#RevenueWithdrawalStateFailedType>) +- [type RevenueWithdrawalStateKind](<#RevenueWithdrawalStateKind>) - [type RevenueWithdrawalStatePending](<#RevenueWithdrawalStatePending>) - [func \(v \*RevenueWithdrawalStatePending\) MarshalJSON\(\) \(\[\]byte, error\)](<#RevenueWithdrawalStatePending.MarshalJSON>) -- [type RevenueWithdrawalStatePendingType](<#RevenueWithdrawalStatePendingType>) - [type RevenueWithdrawalStateSucceeded](<#RevenueWithdrawalStateSucceeded>) - [func \(v \*RevenueWithdrawalStateSucceeded\) MarshalJSON\(\) \(\[\]byte, error\)](<#RevenueWithdrawalStateSucceeded.MarshalJSON>) -- [type RevenueWithdrawalStateSucceededType](<#RevenueWithdrawalStateSucceededType>) - [type RevokeChatInviteLinkParams](<#RevokeChatInviteLinkParams>) - [type SavePreparedInlineMessageParams](<#SavePreparedInlineMessageParams>) - [type SavePreparedKeyboardButtonParams](<#SavePreparedKeyboardButtonParams>) @@ -836,22 +813,18 @@ Package api contains the Telegram Bot API object types and method wrappers, gene - [type StoryAreaPosition](<#StoryAreaPosition>) - [type StoryAreaType](<#StoryAreaType>) - [func UnmarshalStoryAreaType\(data \[\]byte\) \(StoryAreaType, error\)](<#UnmarshalStoryAreaType>) +- [type StoryAreaTypeKind](<#StoryAreaTypeKind>) - [type StoryAreaTypeLink](<#StoryAreaTypeLink>) - [func \(v \*StoryAreaTypeLink\) MarshalJSON\(\) \(\[\]byte, error\)](<#StoryAreaTypeLink.MarshalJSON>) -- [type StoryAreaTypeLinkType](<#StoryAreaTypeLinkType>) - [type StoryAreaTypeLocation](<#StoryAreaTypeLocation>) - [func \(v \*StoryAreaTypeLocation\) MarshalJSON\(\) \(\[\]byte, error\)](<#StoryAreaTypeLocation.MarshalJSON>) -- [type StoryAreaTypeLocationType](<#StoryAreaTypeLocationType>) - [type StoryAreaTypeSuggestedReaction](<#StoryAreaTypeSuggestedReaction>) - [func \(v \*StoryAreaTypeSuggestedReaction\) MarshalJSON\(\) \(\[\]byte, error\)](<#StoryAreaTypeSuggestedReaction.MarshalJSON>) - [func \(m \*StoryAreaTypeSuggestedReaction\) UnmarshalJSON\(data \[\]byte\) error](<#StoryAreaTypeSuggestedReaction.UnmarshalJSON>) -- [type StoryAreaTypeSuggestedReactionType](<#StoryAreaTypeSuggestedReactionType>) - [type StoryAreaTypeUniqueGift](<#StoryAreaTypeUniqueGift>) - [func \(v \*StoryAreaTypeUniqueGift\) MarshalJSON\(\) \(\[\]byte, error\)](<#StoryAreaTypeUniqueGift.MarshalJSON>) -- [type StoryAreaTypeUniqueGiftType](<#StoryAreaTypeUniqueGiftType>) - [type StoryAreaTypeWeather](<#StoryAreaTypeWeather>) - [func \(v \*StoryAreaTypeWeather\) MarshalJSON\(\) \(\[\]byte, error\)](<#StoryAreaTypeWeather.MarshalJSON>) -- [type StoryAreaTypeWeatherType](<#StoryAreaTypeWeatherType>) - [type SuccessfulPayment](<#SuccessfulPayment>) - [type SuggestedPostApprovalFailed](<#SuggestedPostApprovalFailed>) - [type SuggestedPostApproved](<#SuggestedPostApproved>) @@ -870,22 +843,18 @@ Package api contains the Telegram Bot API object types and method wrappers, gene - [func UnmarshalTransactionPartner\(data \[\]byte\) \(TransactionPartner, error\)](<#UnmarshalTransactionPartner>) - [type TransactionPartnerAffiliateProgram](<#TransactionPartnerAffiliateProgram>) - [func \(v \*TransactionPartnerAffiliateProgram\) MarshalJSON\(\) \(\[\]byte, error\)](<#TransactionPartnerAffiliateProgram.MarshalJSON>) -- [type TransactionPartnerAffiliateProgramType](<#TransactionPartnerAffiliateProgramType>) - [type TransactionPartnerChat](<#TransactionPartnerChat>) - [func \(v \*TransactionPartnerChat\) MarshalJSON\(\) \(\[\]byte, error\)](<#TransactionPartnerChat.MarshalJSON>) - [type TransactionPartnerFragment](<#TransactionPartnerFragment>) - [func \(v \*TransactionPartnerFragment\) MarshalJSON\(\) \(\[\]byte, error\)](<#TransactionPartnerFragment.MarshalJSON>) - [func \(m \*TransactionPartnerFragment\) UnmarshalJSON\(data \[\]byte\) error](<#TransactionPartnerFragment.UnmarshalJSON>) -- [type TransactionPartnerFragmentType](<#TransactionPartnerFragmentType>) - [type TransactionPartnerOther](<#TransactionPartnerOther>) - [func \(v \*TransactionPartnerOther\) MarshalJSON\(\) \(\[\]byte, error\)](<#TransactionPartnerOther.MarshalJSON>) -- [type TransactionPartnerOtherType](<#TransactionPartnerOtherType>) - [type TransactionPartnerTelegramAds](<#TransactionPartnerTelegramAds>) - [func \(v \*TransactionPartnerTelegramAds\) MarshalJSON\(\) \(\[\]byte, error\)](<#TransactionPartnerTelegramAds.MarshalJSON>) -- [type TransactionPartnerTelegramAdsType](<#TransactionPartnerTelegramAdsType>) - [type TransactionPartnerTelegramApi](<#TransactionPartnerTelegramApi>) - [func \(v \*TransactionPartnerTelegramApi\) MarshalJSON\(\) \(\[\]byte, error\)](<#TransactionPartnerTelegramApi.MarshalJSON>) -- [type TransactionPartnerTelegramApiType](<#TransactionPartnerTelegramApiType>) +- [type TransactionPartnerType](<#TransactionPartnerType>) - [type TransactionPartnerUser](<#TransactionPartnerUser>) - [func \(v \*TransactionPartnerUser\) MarshalJSON\(\) \(\[\]byte, error\)](<#TransactionPartnerUser.MarshalJSON>) - [func \(m \*TransactionPartnerUser\) UnmarshalJSON\(data \[\]byte\) error](<#TransactionPartnerUser.UnmarshalJSON>) @@ -2362,7 +2331,7 @@ The background is a freeform gradient that rotates after every message in the ch ```go type BackgroundFillFreeformGradient struct { // Type of the background fill, always “freeform_gradient” - Type BackgroundFillFreeformGradientType `json:"type"` + Type BackgroundFillType `json:"type"` // A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format Colors []int64 `json:"colors"` } @@ -2377,23 +2346,6 @@ func (v *BackgroundFillFreeformGradient) MarshalJSON() ([]byte, error) MarshalJSON encodes BackgroundFillFreeformGradient with the discriminator field "type" forced to "freeform\_gradient". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [BackgroundFillFreeformGradientType]() - - - -```go -type BackgroundFillFreeformGradientType string -``` - - - -```go -const ( - BackgroundFillFreeformGradientTypeFreeformGradient BackgroundFillFreeformGradientType = "freeform_gradient" -) -``` - ## type [BackgroundFillGradient]() @@ -2402,7 +2354,7 @@ The background is a gradient fill. ```go type BackgroundFillGradient struct { // Type of the background fill, always “gradient” - Type BackgroundFillGradientType `json:"type"` + Type BackgroundFillType `json:"type"` // Top color of the gradient in the RGB24 format TopColor int64 `json:"top_color"` // Bottom color of the gradient in the RGB24 format @@ -2421,23 +2373,6 @@ func (v *BackgroundFillGradient) MarshalJSON() ([]byte, error) MarshalJSON encodes BackgroundFillGradient with the discriminator field "type" forced to "gradient". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [BackgroundFillGradientType]() - - - -```go -type BackgroundFillGradientType string -``` - - - -```go -const ( - BackgroundFillGradientTypeGradient BackgroundFillGradientType = "gradient" -) -``` - ## type [BackgroundFillSolid]() @@ -2446,7 +2381,7 @@ The background is filled using the selected color. ```go type BackgroundFillSolid struct { // Type of the background fill, always “solid” - Type BackgroundFillSolidType `json:"type"` + Type BackgroundFillType `json:"type"` // The color of the background fill in the RGB24 format Color int64 `json:"color"` } @@ -2461,20 +2396,22 @@ func (v *BackgroundFillSolid) MarshalJSON() ([]byte, error) MarshalJSON encodes BackgroundFillSolid with the discriminator field "type" forced to "solid". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [BackgroundFillSolidType]() + +## type [BackgroundFillType]() ```go -type BackgroundFillSolidType string +type BackgroundFillType string ``` - + ```go const ( - BackgroundFillSolidTypeSolid BackgroundFillSolidType = "solid" + BackgroundFillTypeSolid BackgroundFillType = "solid" + BackgroundFillTypeGradient BackgroundFillType = "gradient" + BackgroundFillTypeFreeformGradient BackgroundFillType = "freeform_gradient" ) ``` @@ -2513,7 +2450,7 @@ The background is taken directly from a built\-in chat theme. ```go type BackgroundTypeChatTheme struct { // Type of the background, always “chat_theme” - Type BackgroundTypeChatThemeType `json:"type"` + Type BackgroundTypeKind `json:"type"` // Name of the chat theme, which is usually an emoji ThemeName string `json:"theme_name"` } @@ -2528,23 +2465,6 @@ func (v *BackgroundTypeChatTheme) MarshalJSON() ([]byte, error) MarshalJSON encodes BackgroundTypeChatTheme with the discriminator field "type" forced to "chat\_theme". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [BackgroundTypeChatThemeType]() - - - -```go -type BackgroundTypeChatThemeType string -``` - - - -```go -const ( - BackgroundTypeChatThemeTypeChatTheme BackgroundTypeChatThemeType = "chat_theme" -) -``` - ## type [BackgroundTypeFill]() @@ -2553,7 +2473,7 @@ The background is automatically filled based on the selected colors. ```go type BackgroundTypeFill struct { // Type of the background, always “fill” - Type BackgroundTypeFillType `json:"type"` + Type BackgroundTypeKind `json:"type"` // The background fill Fill BackgroundFill `json:"fill"` // Dimming of the background in dark themes, as a percentage; 0-100 @@ -2579,20 +2499,23 @@ func (m *BackgroundTypeFill) UnmarshalJSON(data []byte) error UnmarshalJSON decodes BackgroundTypeFill by dispatching union\-typed fields \(Fill\) through their concrete UnmarshalXxx helpers. - -## type [BackgroundTypeFillType]() + +## type [BackgroundTypeKind]() ```go -type BackgroundTypeFillType string +type BackgroundTypeKind string ``` - + ```go const ( - BackgroundTypeFillTypeFill BackgroundTypeFillType = "fill" + BackgroundTypeKindFill BackgroundTypeKind = "fill" + BackgroundTypeKindWallpaper BackgroundTypeKind = "wallpaper" + BackgroundTypeKindPattern BackgroundTypeKind = "pattern" + BackgroundTypeKindChatTheme BackgroundTypeKind = "chat_theme" ) ``` @@ -2604,7 +2527,7 @@ The background is a .PNG or .TGV \(gzipped subset of SVG with MIME type “appli ```go type BackgroundTypePattern struct { // Type of the background, always “pattern” - Type BackgroundTypePatternType `json:"type"` + Type BackgroundTypeKind `json:"type"` // Document with the pattern Document Document `json:"document"` // The background fill that is combined with the pattern @@ -2636,23 +2559,6 @@ func (m *BackgroundTypePattern) UnmarshalJSON(data []byte) error UnmarshalJSON decodes BackgroundTypePattern by dispatching union\-typed fields \(Fill\) through their concrete UnmarshalXxx helpers. - -## type [BackgroundTypePatternType]() - - - -```go -type BackgroundTypePatternType string -``` - - - -```go -const ( - BackgroundTypePatternTypePattern BackgroundTypePatternType = "pattern" -) -``` - ## type [BackgroundTypeWallpaper]() @@ -2661,7 +2567,7 @@ The background is a wallpaper in the JPEG format. ```go type BackgroundTypeWallpaper struct { // Type of the background, always “wallpaper” - Type BackgroundTypeWallpaperType `json:"type"` + Type BackgroundTypeKind `json:"type"` // Document with the wallpaper Document Document `json:"document"` // Dimming of the background in dark themes, as a percentage; 0-100 @@ -2682,23 +2588,6 @@ func (v *BackgroundTypeWallpaper) MarshalJSON() ([]byte, error) MarshalJSON encodes BackgroundTypeWallpaper with the discriminator field "type" forced to "wallpaper". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [BackgroundTypeWallpaperType]() - - - -```go -type BackgroundTypeWallpaperType string -``` - - - -```go -const ( - BackgroundTypeWallpaperTypeWallpaper BackgroundTypeWallpaperType = "wallpaper" -) -``` - ## type [BanChatMemberParams]() @@ -3436,7 +3325,7 @@ The boost was obtained by the creation of Telegram Premium gift codes to boost a ```go type ChatBoostSourceGiftCode struct { // Source of the boost, always “gift_code” - Source ChatBoostSourceGiftCodeSource `json:"source"` + Source ChatBoostSourceKind `json:"source"` // User for which the gift code was created User User `json:"user"` } @@ -3451,23 +3340,6 @@ func (v *ChatBoostSourceGiftCode) MarshalJSON() ([]byte, error) MarshalJSON encodes ChatBoostSourceGiftCode with the discriminator field "source" forced to "gift\_code". The hardcoded value frees callers from setting Source by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [ChatBoostSourceGiftCodeSource]() - - - -```go -type ChatBoostSourceGiftCodeSource string -``` - - - -```go -const ( - ChatBoostSourceGiftCodeSourceGiftCode ChatBoostSourceGiftCodeSource = "gift_code" -) -``` - ## type [ChatBoostSourceGiveaway]() @@ -3476,7 +3348,7 @@ The boost was obtained by the creation of a Telegram Premium or a Telegram Star ```go type ChatBoostSourceGiveaway struct { // Source of the boost, always “giveaway” - Source ChatBoostSourceGiveawaySource `json:"source"` + Source ChatBoostSourceKind `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; for Telegram Premium giveaways only @@ -3497,20 +3369,22 @@ func (v *ChatBoostSourceGiveaway) MarshalJSON() ([]byte, error) MarshalJSON encodes ChatBoostSourceGiveaway with the discriminator field "source" forced to "giveaway". The hardcoded value frees callers from setting Source by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [ChatBoostSourceGiveawaySource]() + +## type [ChatBoostSourceKind]() ```go -type ChatBoostSourceGiveawaySource string +type ChatBoostSourceKind string ``` - + ```go const ( - ChatBoostSourceGiveawaySourceGiveaway ChatBoostSourceGiveawaySource = "giveaway" + ChatBoostSourceKindPremium ChatBoostSourceKind = "premium" + ChatBoostSourceKindGiftCode ChatBoostSourceKind = "gift_code" + ChatBoostSourceKindGiveaway ChatBoostSourceKind = "giveaway" ) ``` @@ -3522,7 +3396,7 @@ The boost was obtained by subscribing to Telegram Premium or by gifting a Telegr ```go type ChatBoostSourcePremium struct { // Source of the boost, always “premium” - Source ChatBoostSourcePremiumSource `json:"source"` + Source ChatBoostSourceKind `json:"source"` // User that boosted the chat User User `json:"user"` } @@ -3537,23 +3411,6 @@ func (v *ChatBoostSourcePremium) MarshalJSON() ([]byte, error) MarshalJSON encodes ChatBoostSourcePremium with the discriminator field "source" forced to "premium". The hardcoded value frees callers from setting Source by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [ChatBoostSourcePremiumSource]() - - - -```go -type ChatBoostSourcePremiumSource string -``` - - - -```go -const ( - ChatBoostSourcePremiumSourcePremium ChatBoostSourcePremiumSource = "premium" -) -``` - ## type [ChatBoostUpdated]() @@ -3947,7 +3804,7 @@ Represents a chat member that has some additional privileges. ```go type ChatMemberAdministrator struct { // The member's status in the chat, always “administrator” - Status ChatMemberAdministratorStatus `json:"status"` + Status ChatMemberStatus `json:"status"` // Information about the user User User `json:"user"` // True, if the bot is allowed to edit administrator privileges of that user @@ -4000,23 +3857,6 @@ func (v *ChatMemberAdministrator) MarshalJSON() ([]byte, error) MarshalJSON encodes ChatMemberAdministrator with the discriminator field "status" forced to "administrator". The hardcoded value frees callers from setting Status by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [ChatMemberAdministratorStatus]() - - - -```go -type ChatMemberAdministratorStatus string -``` - - - -```go -const ( - ChatMemberAdministratorStatusAdministrator ChatMemberAdministratorStatus = "administrator" -) -``` - ## type [ChatMemberBanned]() @@ -4025,7 +3865,7 @@ Represents a chat member that was banned in the chat and can't return to the cha ```go type ChatMemberBanned struct { // The member's status in the chat, always “kicked” - Status ChatMemberBannedStatus `json:"status"` + Status ChatMemberStatus `json:"status"` // Information about the user User User `json:"user"` // Date when restrictions will be lifted for this user; Unix time. If 0, then the user is banned forever @@ -4042,23 +3882,6 @@ func (v *ChatMemberBanned) MarshalJSON() ([]byte, error) MarshalJSON encodes ChatMemberBanned with the discriminator field "status" forced to "kicked". The hardcoded value frees callers from setting Status by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [ChatMemberBannedStatus]() - - - -```go -type ChatMemberBannedStatus string -``` - - - -```go -const ( - ChatMemberBannedStatusKicked ChatMemberBannedStatus = "kicked" -) -``` - ## type [ChatMemberLeft]() @@ -4067,7 +3890,7 @@ Represents a chat member that isn't currently a member of the chat, but may join ```go type ChatMemberLeft struct { // The member's status in the chat, always “left” - Status ChatMemberLeftStatus `json:"status"` + Status ChatMemberStatus `json:"status"` // Information about the user User User `json:"user"` } @@ -4082,23 +3905,6 @@ func (v *ChatMemberLeft) MarshalJSON() ([]byte, error) MarshalJSON encodes ChatMemberLeft with the discriminator field "status" forced to "left". The hardcoded value frees callers from setting Status by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [ChatMemberLeftStatus]() - - - -```go -type ChatMemberLeftStatus string -``` - - - -```go -const ( - ChatMemberLeftStatusLeft ChatMemberLeftStatus = "left" -) -``` - ## type [ChatMemberMember]() @@ -4107,7 +3913,7 @@ Represents a chat member that has no additional privileges or restrictions. ```go type ChatMemberMember struct { // The member's status in the chat, always “member” - Status ChatMemberMemberStatus `json:"status"` + Status ChatMemberStatus `json:"status"` // Optional. Tag of the member Tag string `json:"tag,omitempty"` // Information about the user @@ -4126,23 +3932,6 @@ func (v *ChatMemberMember) MarshalJSON() ([]byte, error) MarshalJSON encodes ChatMemberMember with the discriminator field "status" forced to "member". The hardcoded value frees callers from setting Status by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [ChatMemberMemberStatus]() - - - -```go -type ChatMemberMemberStatus string -``` - - - -```go -const ( - ChatMemberMemberStatusMember ChatMemberMemberStatus = "member" -) -``` - ## type [ChatMemberOwner]() @@ -4151,7 +3940,7 @@ Represents a chat member that owns the chat and has all administrator privileges ```go type ChatMemberOwner struct { // The member's status in the chat, always “creator” - Status ChatMemberOwnerStatus `json:"status"` + Status ChatMemberStatus `json:"status"` // Information about the user User User `json:"user"` // True, if the user's presence in the chat is hidden @@ -4170,23 +3959,6 @@ func (v *ChatMemberOwner) MarshalJSON() ([]byte, error) MarshalJSON encodes ChatMemberOwner with the discriminator field "status" forced to "creator". The hardcoded value frees callers from setting Status by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [ChatMemberOwnerStatus]() - - - -```go -type ChatMemberOwnerStatus string -``` - - - -```go -const ( - ChatMemberOwnerStatusCreator ChatMemberOwnerStatus = "creator" -) -``` - ## type [ChatMemberRestricted]() @@ -4195,7 +3967,7 @@ Represents a chat member that is under certain restrictions in the chat. Supergr ```go type ChatMemberRestricted struct { // The member's status in the chat, always “restricted” - Status ChatMemberRestrictedStatus `json:"status"` + Status ChatMemberStatus `json:"status"` // Optional. Tag of the member Tag string `json:"tag,omitempty"` // Information about the user @@ -4248,20 +4020,25 @@ func (v *ChatMemberRestricted) MarshalJSON() ([]byte, error) MarshalJSON encodes ChatMemberRestricted with the discriminator field "status" forced to "restricted". The hardcoded value frees callers from setting Status by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [ChatMemberRestrictedStatus]() + +## type [ChatMemberStatus]() ```go -type ChatMemberRestrictedStatus string +type ChatMemberStatus string ``` - + ```go const ( - ChatMemberRestrictedStatusRestricted ChatMemberRestrictedStatus = "restricted" + ChatMemberStatusCreator ChatMemberStatus = "creator" + ChatMemberStatusAdministrator ChatMemberStatus = "administrator" + ChatMemberStatusMember ChatMemberStatus = "member" + ChatMemberStatusRestricted ChatMemberStatus = "restricted" + ChatMemberStatusLeft ChatMemberStatus = "left" + ChatMemberStatusKicked ChatMemberStatus = "kicked" ) ``` @@ -4405,7 +4182,7 @@ type ChatShared struct { ``` -## type [ChatType]() +## type [ChatType]() @@ -5482,7 +5259,7 @@ type EncryptedPassportElement struct { ``` -## type [EncryptedPassportElementType]() +## type [EncryptedPassportElementType]() @@ -6722,7 +6499,7 @@ type InlineQuery struct { ``` -## type [InlineQueryChatType]() +## type [InlineQueryChatType]() @@ -7245,7 +7022,7 @@ func (v *InlineQueryResultDocument) MarshalJSON() ([]byte, error) MarshalJSON encodes InlineQueryResultDocument with the discriminator field "type" forced to "document". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. -## type [InlineQueryResultDocumentMimeType]() +## type [InlineQueryResultDocumentMimeType]() @@ -7339,7 +7116,7 @@ func (v *InlineQueryResultGif) MarshalJSON() ([]byte, error) MarshalJSON encodes InlineQueryResultGif with the discriminator field "type" forced to "gif". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. -## type [InlineQueryResultGifThumbnailMimeType]() +## type [InlineQueryResultGifThumbnailMimeType]() @@ -8414,7 +8191,7 @@ type InputSticker struct { ``` -## type [InputStickerFormat]() +## type [InputStickerFormat]() @@ -8679,7 +8456,7 @@ type KeyboardButtonRequestUsers struct { ``` -## type [KeyboardButtonStyle]() +## type [KeyboardButtonStyle]() @@ -8886,7 +8663,7 @@ type MaskPosition struct { ``` -## type [MaskPositionPoint]() +## type [MaskPositionPoint]() @@ -9620,7 +9397,7 @@ type MessageEntity struct { ``` -## type [MessageEntityType]() +## type [MessageEntityType]() @@ -9833,7 +9610,7 @@ The message was originally sent to a channel chat. ```go type MessageOriginChannel struct { // Type of the message origin, always “channel” - Type MessageOriginChannelType `json:"type"` + Type MessageOriginType `json:"type"` // Date the message was sent originally in Unix time Date int64 `json:"date"` // Channel chat to which the message was originally sent @@ -9854,23 +9631,6 @@ func (v *MessageOriginChannel) MarshalJSON() ([]byte, error) MarshalJSON encodes MessageOriginChannel with the discriminator field "type" forced to "channel". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [MessageOriginChannelType]() - - - -```go -type MessageOriginChannelType string -``` - - - -```go -const ( - MessageOriginChannelTypeChannel MessageOriginChannelType = "channel" -) -``` - ## type [MessageOriginChat]() @@ -9879,7 +9639,7 @@ The message was originally sent on behalf of a chat to a group chat. ```go type MessageOriginChat struct { // Type of the message origin, always “chat” - Type MessageOriginChatType `json:"type"` + Type MessageOriginType `json:"type"` // Date the message was sent originally in Unix time Date int64 `json:"date"` // Chat that sent the message originally @@ -9898,23 +9658,6 @@ func (v *MessageOriginChat) MarshalJSON() ([]byte, error) MarshalJSON encodes MessageOriginChat with the discriminator field "type" forced to "chat". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [MessageOriginChatType]() - - - -```go -type MessageOriginChatType string -``` - - - -```go -const ( - MessageOriginChatTypeChat MessageOriginChatType = "chat" -) -``` - ## type [MessageOriginHiddenUser]() @@ -9923,7 +9666,7 @@ The message was originally sent by an unknown user. ```go type MessageOriginHiddenUser struct { // Type of the message origin, always “hidden_user” - Type MessageOriginHiddenUserType `json:"type"` + Type MessageOriginType `json:"type"` // Date the message was sent originally in Unix time Date int64 `json:"date"` // Name of the user that sent the message originally @@ -9940,20 +9683,23 @@ func (v *MessageOriginHiddenUser) MarshalJSON() ([]byte, error) MarshalJSON encodes MessageOriginHiddenUser with the discriminator field "type" forced to "hidden\_user". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [MessageOriginHiddenUserType]() + +## type [MessageOriginType]() ```go -type MessageOriginHiddenUserType string +type MessageOriginType string ``` - + ```go const ( - MessageOriginHiddenUserTypeHiddenUser MessageOriginHiddenUserType = "hidden_user" + MessageOriginTypeUser MessageOriginType = "user" + MessageOriginTypeHiddenUser MessageOriginType = "hidden_user" + MessageOriginTypeChat MessageOriginType = "chat" + MessageOriginTypeChannel MessageOriginType = "channel" ) ``` @@ -9965,7 +9711,7 @@ The message was originally sent by a known user. ```go type MessageOriginUser struct { // Type of the message origin, always “user” - Type MessageOriginUserType `json:"type"` + Type MessageOriginType `json:"type"` // Date the message was sent originally in Unix time Date int64 `json:"date"` // User that sent the message originally @@ -9982,23 +9728,6 @@ func (v *MessageOriginUser) MarshalJSON() ([]byte, error) MarshalJSON encodes MessageOriginUser with the discriminator field "type" forced to "user". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [MessageOriginUserType]() - - - -```go -type MessageOriginUserType string -``` - - - -```go -const ( - MessageOriginUserTypeUser MessageOriginUserType = "user" -) -``` - ## type [MessageReactionCountUpdated]() @@ -10110,7 +9839,7 @@ Describes a regular gift owned by a user or a chat. ```go type OwnedGiftRegular struct { // Type of the gift, always “regular” - Type OwnedGiftRegularType `json:"type"` + Type OwnedGiftType `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 @@ -10151,20 +9880,21 @@ func (v *OwnedGiftRegular) MarshalJSON() ([]byte, error) MarshalJSON encodes OwnedGiftRegular with the discriminator field "type" forced to "regular". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [OwnedGiftRegularType]() + +## type [OwnedGiftType]() ```go -type OwnedGiftRegularType string +type OwnedGiftType string ``` - + ```go const ( - OwnedGiftRegularTypeRegular OwnedGiftRegularType = "regular" + OwnedGiftTypeRegular OwnedGiftType = "regular" + OwnedGiftTypeUnique OwnedGiftType = "unique" ) ``` @@ -10176,7 +9906,7 @@ Describes a unique gift received and owned by a user or a chat. ```go type OwnedGiftUnique struct { // Type of the gift, always “unique” - Type OwnedGiftUniqueType `json:"type"` + Type OwnedGiftType `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 @@ -10205,23 +9935,6 @@ func (v *OwnedGiftUnique) MarshalJSON() ([]byte, error) MarshalJSON encodes OwnedGiftUnique with the discriminator field "type" forced to "unique". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [OwnedGiftUniqueType]() - - - -```go -type OwnedGiftUniqueType string -``` - - - -```go -const ( - OwnedGiftUniqueTypeUnique OwnedGiftUniqueType = "unique" -) -``` - ## type [OwnedGifts]() @@ -10338,7 +10051,7 @@ The paid media is a live photo. ```go type PaidMediaLivePhoto struct { // Type of the paid media, always “live_photo” - Type PaidMediaLivePhotoType `json:"type"` + Type PaidMediaType `json:"type"` // The photo LivePhoto LivePhoto `json:"live_photo"` } @@ -10353,23 +10066,6 @@ func (v *PaidMediaLivePhoto) MarshalJSON() ([]byte, error) MarshalJSON encodes PaidMediaLivePhoto with the discriminator field "type" forced to "live\_photo". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [PaidMediaLivePhotoType]() - - - -```go -type PaidMediaLivePhotoType string -``` - - - -```go -const ( - PaidMediaLivePhotoTypeLivePhoto PaidMediaLivePhotoType = "live_photo" -) -``` - ## type [PaidMediaPhoto]() @@ -10378,7 +10074,7 @@ The paid media is a photo. ```go type PaidMediaPhoto struct { // Type of the paid media, always “photo” - Type PaidMediaPhotoType `json:"type"` + Type PaidMediaType `json:"type"` // The photo Photo []PhotoSize `json:"photo"` } @@ -10393,23 +10089,6 @@ func (v *PaidMediaPhoto) MarshalJSON() ([]byte, error) MarshalJSON encodes PaidMediaPhoto with the discriminator field "type" forced to "photo". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [PaidMediaPhotoType]() - - - -```go -type PaidMediaPhotoType string -``` - - - -```go -const ( - PaidMediaPhotoTypePhoto PaidMediaPhotoType = "photo" -) -``` - ## type [PaidMediaPreview]() @@ -10418,7 +10097,7 @@ The paid media isn't available before the payment. ```go type PaidMediaPreview struct { // Type of the paid media, always “preview” - Type PaidMediaPreviewType `json:"type"` + Type PaidMediaType `json:"type"` // Optional. Media width as defined by the sender Width *int64 `json:"width,omitempty"` // Optional. Media height as defined by the sender @@ -10437,23 +10116,6 @@ func (v *PaidMediaPreview) MarshalJSON() ([]byte, error) MarshalJSON encodes PaidMediaPreview with the discriminator field "type" forced to "preview". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [PaidMediaPreviewType]() - - - -```go -type PaidMediaPreviewType string -``` - - - -```go -const ( - PaidMediaPreviewTypePreview PaidMediaPreviewType = "preview" -) -``` - ## type [PaidMediaPurchased]() @@ -10468,6 +10130,26 @@ type PaidMediaPurchased struct { } ``` + +## type [PaidMediaType]() + + + +```go +type PaidMediaType string +``` + + + +```go +const ( + PaidMediaTypeLivePhoto PaidMediaType = "live_photo" + PaidMediaTypePhoto PaidMediaType = "photo" + PaidMediaTypePreview PaidMediaType = "preview" + PaidMediaTypeVideo PaidMediaType = "video" +) +``` + ## type [PaidMediaVideo]() @@ -10476,7 +10158,7 @@ The paid media is a video. ```go type PaidMediaVideo struct { // Type of the paid media, always “video” - Type PaidMediaVideoType `json:"type"` + Type PaidMediaType `json:"type"` // The video Video Video `json:"video"` } @@ -10491,23 +10173,6 @@ func (v *PaidMediaVideo) MarshalJSON() ([]byte, error) MarshalJSON encodes PaidMediaVideo with the discriminator field "type" forced to "video". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [PaidMediaVideoType]() - - - -```go -type PaidMediaVideoType string -``` - - - -```go -const ( - PaidMediaVideoTypeVideo PaidMediaVideoType = "video" -) -``` - ## type [PaidMessagePriceChanged]() @@ -10521,7 +10186,7 @@ type PaidMessagePriceChanged struct { ``` -## type [ParseMode]() +## type [ParseMode]() @@ -10606,7 +10271,7 @@ func (v *PassportElementErrorDataField) MarshalJSON() ([]byte, error) MarshalJSON encodes PassportElementErrorDataField with the discriminator field "source" forced to "data". The hardcoded value frees callers from setting Source by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. -## type [PassportElementErrorDataFieldType]() +## type [PassportElementErrorDataFieldType]() @@ -10655,7 +10320,7 @@ func (v *PassportElementErrorFile) MarshalJSON() ([]byte, error) MarshalJSON encodes PassportElementErrorFile with the discriminator field "source" forced to "file". The hardcoded value frees callers from setting Source by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. -## type [PassportElementErrorFileType]() +## type [PassportElementErrorFileType]() @@ -10757,7 +10422,7 @@ func (v *PassportElementErrorReverseSide) MarshalJSON() ([]byte, error) MarshalJSON encodes PassportElementErrorReverseSide with the discriminator field "source" forced to "reverse\_side". The hardcoded value frees callers from setting Source by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. -## type [PassportElementErrorReverseSideType]() +## type [PassportElementErrorReverseSideType]() @@ -10802,7 +10467,7 @@ func (v *PassportElementErrorSelfie) MarshalJSON() ([]byte, error) MarshalJSON encodes PassportElementErrorSelfie with the discriminator field "source" forced to "selfie". The hardcoded value frees callers from setting Source by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. -## type [PassportElementErrorSelfieType]() +## type [PassportElementErrorSelfieType]() @@ -10849,7 +10514,7 @@ func (v *PassportElementErrorTranslationFile) MarshalJSON() ([]byte, error) MarshalJSON encodes PassportElementErrorTranslationFile with the discriminator field "source" forced to "translation\_file". The hardcoded value frees callers from setting Source by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. -## type [PassportElementErrorTranslationFileType]() +## type [PassportElementErrorTranslationFileType]() @@ -11186,7 +10851,7 @@ func (m *PollOptionDeleted) UnmarshalJSON(data []byte) error UnmarshalJSON decodes PollOptionDeleted by dispatching union\-typed fields \(PollMessage\) through their concrete UnmarshalXxx helpers. -## type [PollType]() +## type [PollType]() @@ -11428,7 +11093,7 @@ The reaction is based on a custom emoji. ```go type ReactionTypeCustomEmoji struct { // Type of the reaction, always “custom_emoji” - Type ReactionTypeCustomEmojiType `json:"type"` + Type ReactionTypeKind `json:"type"` // Custom emoji identifier CustomEmojiID string `json:"custom_emoji_id"` } @@ -11443,23 +11108,6 @@ func (v *ReactionTypeCustomEmoji) MarshalJSON() ([]byte, error) MarshalJSON encodes ReactionTypeCustomEmoji with the discriminator field "type" forced to "custom\_emoji". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [ReactionTypeCustomEmojiType]() - - - -```go -type ReactionTypeCustomEmojiType string -``` - - - -```go -const ( - ReactionTypeCustomEmojiTypeCustomEmoji ReactionTypeCustomEmojiType = "custom_emoji" -) -``` - ## type [ReactionTypeEmoji]() @@ -11468,7 +11116,7 @@ The reaction is based on an emoji. ```go type ReactionTypeEmoji struct { // Type of the reaction, always “emoji” - Type ReactionTypeEmojiType `json:"type"` + Type ReactionTypeKind `json:"type"` // Reaction emoji. Currently, it can be one of "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" Emoji string `json:"emoji"` } @@ -11483,20 +11131,22 @@ func (v *ReactionTypeEmoji) MarshalJSON() ([]byte, error) MarshalJSON encodes ReactionTypeEmoji with the discriminator field "type" forced to "emoji". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [ReactionTypeEmojiType]() + +## type [ReactionTypeKind]() ```go -type ReactionTypeEmojiType string +type ReactionTypeKind string ``` - + ```go const ( - ReactionTypeEmojiTypeEmoji ReactionTypeEmojiType = "emoji" + ReactionTypeKindEmoji ReactionTypeKind = "emoji" + ReactionTypeKindCustomEmoji ReactionTypeKind = "custom_emoji" + ReactionTypeKindPaid ReactionTypeKind = "paid" ) ``` @@ -11508,7 +11158,7 @@ The reaction is paid. ```go type ReactionTypePaid struct { // Type of the reaction, always “paid” - Type ReactionTypePaidType `json:"type"` + Type ReactionTypeKind `json:"type"` } ``` @@ -11521,23 +11171,6 @@ func (v *ReactionTypePaid) MarshalJSON() ([]byte, error) MarshalJSON encodes ReactionTypePaid with the discriminator field "type" forced to "paid". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [ReactionTypePaidType]() - - - -```go -type ReactionTypePaidType string -``` - - - -```go -const ( - ReactionTypePaidTypePaid ReactionTypePaidType = "paid" -) -``` - ## type [ReadBusinessMessageParams]() @@ -11593,7 +11226,7 @@ type RefundedPayment struct { ``` -## type [RefundedPaymentCurrency]() +## type [RefundedPaymentCurrency]() @@ -11887,7 +11520,7 @@ The withdrawal failed and the transaction was refunded. ```go type RevenueWithdrawalStateFailed struct { // Type of the state, always “failed” - Type RevenueWithdrawalStateFailedType `json:"type"` + Type RevenueWithdrawalStateKind `json:"type"` } ``` @@ -11900,20 +11533,22 @@ func (v *RevenueWithdrawalStateFailed) MarshalJSON() ([]byte, error) MarshalJSON encodes RevenueWithdrawalStateFailed with the discriminator field "type" forced to "failed". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [RevenueWithdrawalStateFailedType]() + +## type [RevenueWithdrawalStateKind]() ```go -type RevenueWithdrawalStateFailedType string +type RevenueWithdrawalStateKind string ``` - + ```go const ( - RevenueWithdrawalStateFailedTypeFailed RevenueWithdrawalStateFailedType = "failed" + RevenueWithdrawalStateKindPending RevenueWithdrawalStateKind = "pending" + RevenueWithdrawalStateKindSucceeded RevenueWithdrawalStateKind = "succeeded" + RevenueWithdrawalStateKindFailed RevenueWithdrawalStateKind = "failed" ) ``` @@ -11925,7 +11560,7 @@ The withdrawal is in progress. ```go type RevenueWithdrawalStatePending struct { // Type of the state, always “pending” - Type RevenueWithdrawalStatePendingType `json:"type"` + Type RevenueWithdrawalStateKind `json:"type"` } ``` @@ -11938,23 +11573,6 @@ func (v *RevenueWithdrawalStatePending) MarshalJSON() ([]byte, error) MarshalJSON encodes RevenueWithdrawalStatePending with the discriminator field "type" forced to "pending". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [RevenueWithdrawalStatePendingType]() - - - -```go -type RevenueWithdrawalStatePendingType string -``` - - - -```go -const ( - RevenueWithdrawalStatePendingTypePending RevenueWithdrawalStatePendingType = "pending" -) -``` - ## type [RevenueWithdrawalStateSucceeded]() @@ -11963,7 +11581,7 @@ The withdrawal succeeded. ```go type RevenueWithdrawalStateSucceeded struct { // Type of the state, always “succeeded” - Type RevenueWithdrawalStateSucceededType `json:"type"` + Type RevenueWithdrawalStateKind `json:"type"` // Date the withdrawal was completed in Unix time Date int64 `json:"date"` // An HTTPS URL that can be used to see transaction details @@ -11980,23 +11598,6 @@ func (v *RevenueWithdrawalStateSucceeded) MarshalJSON() ([]byte, error) MarshalJSON encodes RevenueWithdrawalStateSucceeded with the discriminator field "type" forced to "succeeded". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [RevenueWithdrawalStateSucceededType]() - - - -```go -type RevenueWithdrawalStateSucceededType string -``` - - - -```go -const ( - RevenueWithdrawalStateSucceededTypeSucceeded RevenueWithdrawalStateSucceededType = "succeeded" -) -``` - ## type [RevokeChatInviteLinkParams]() @@ -14351,7 +13952,7 @@ GetStickerSet calls the getStickerSet Telegram Bot API method. Use this method to get a sticker set. On success, a StickerSet object is returned. -## type [StickerType]() +## type [StickerType]() @@ -14531,6 +14132,27 @@ func UnmarshalStoryAreaType(data []byte) (StoryAreaType, error) UnmarshalStoryAreaType decodes a StoryAreaType from JSON by inspecting the "type" field and dispatching to the correct concrete type. + +## type [StoryAreaTypeKind]() + + + +```go +type StoryAreaTypeKind string +``` + + + +```go +const ( + StoryAreaTypeKindLocation StoryAreaTypeKind = "location" + StoryAreaTypeKindSuggestedReaction StoryAreaTypeKind = "suggested_reaction" + StoryAreaTypeKindLink StoryAreaTypeKind = "link" + StoryAreaTypeKindWeather StoryAreaTypeKind = "weather" + StoryAreaTypeKindUniqueGift StoryAreaTypeKind = "unique_gift" +) +``` + ## type [StoryAreaTypeLink]() @@ -14539,7 +14161,7 @@ Describes a story area pointing to an HTTP or tg:// link. Currently, a story can ```go type StoryAreaTypeLink struct { // Type of the area, always “link” - Type StoryAreaTypeLinkType `json:"type"` + Type StoryAreaTypeKind `json:"type"` // HTTP or tg:// URL to be opened when the area is clicked URL string `json:"url"` } @@ -14554,23 +14176,6 @@ func (v *StoryAreaTypeLink) MarshalJSON() ([]byte, error) MarshalJSON encodes StoryAreaTypeLink with the discriminator field "type" forced to "link". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [StoryAreaTypeLinkType]() - - - -```go -type StoryAreaTypeLinkType string -``` - - - -```go -const ( - StoryAreaTypeLinkTypeLink StoryAreaTypeLinkType = "link" -) -``` - ## type [StoryAreaTypeLocation]() @@ -14579,7 +14184,7 @@ Describes a story area pointing to a location. Currently, a story can have up to ```go type StoryAreaTypeLocation struct { // Type of the area, always “location” - Type StoryAreaTypeLocationType `json:"type"` + Type StoryAreaTypeKind `json:"type"` // Location latitude in degrees Latitude float64 `json:"latitude"` // Location longitude in degrees @@ -14598,23 +14203,6 @@ func (v *StoryAreaTypeLocation) MarshalJSON() ([]byte, error) MarshalJSON encodes StoryAreaTypeLocation with the discriminator field "type" forced to "location". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [StoryAreaTypeLocationType]() - - - -```go -type StoryAreaTypeLocationType string -``` - - - -```go -const ( - StoryAreaTypeLocationTypeLocation StoryAreaTypeLocationType = "location" -) -``` - ## type [StoryAreaTypeSuggestedReaction]() @@ -14623,7 +14211,7 @@ Describes a story area pointing to a suggested reaction. Currently, a story can ```go type StoryAreaTypeSuggestedReaction struct { // Type of the area, always “suggested_reaction” - Type StoryAreaTypeSuggestedReactionType `json:"type"` + Type StoryAreaTypeKind `json:"type"` // Type of the reaction ReactionType ReactionType `json:"reaction_type"` // Optional. Pass True if the reaction area has a dark background @@ -14651,23 +14239,6 @@ func (m *StoryAreaTypeSuggestedReaction) UnmarshalJSON(data []byte) error UnmarshalJSON decodes StoryAreaTypeSuggestedReaction by dispatching union\-typed fields \(ReactionType\) through their concrete UnmarshalXxx helpers. - -## type [StoryAreaTypeSuggestedReactionType]() - - - -```go -type StoryAreaTypeSuggestedReactionType string -``` - - - -```go -const ( - StoryAreaTypeSuggestedReactionTypeSuggestedReaction StoryAreaTypeSuggestedReactionType = "suggested_reaction" -) -``` - ## type [StoryAreaTypeUniqueGift]() @@ -14676,7 +14247,7 @@ Describes a story area pointing to a unique gift. Currently, a story can have at ```go type StoryAreaTypeUniqueGift struct { // Type of the area, always “unique_gift” - Type StoryAreaTypeUniqueGiftType `json:"type"` + Type StoryAreaTypeKind `json:"type"` // Unique name of the gift Name string `json:"name"` } @@ -14691,23 +14262,6 @@ func (v *StoryAreaTypeUniqueGift) MarshalJSON() ([]byte, error) MarshalJSON encodes StoryAreaTypeUniqueGift with the discriminator field "type" forced to "unique\_gift". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [StoryAreaTypeUniqueGiftType]() - - - -```go -type StoryAreaTypeUniqueGiftType string -``` - - - -```go -const ( - StoryAreaTypeUniqueGiftTypeUniqueGift StoryAreaTypeUniqueGiftType = "unique_gift" -) -``` - ## type [StoryAreaTypeWeather]() @@ -14716,7 +14270,7 @@ Describes a story area containing weather information. Currently, a story can ha ```go type StoryAreaTypeWeather struct { // Type of the area, always “weather” - Type StoryAreaTypeWeatherType `json:"type"` + Type StoryAreaTypeKind `json:"type"` // Temperature, in degree Celsius Temperature float64 `json:"temperature"` // Emoji representing the weather @@ -14735,23 +14289,6 @@ func (v *StoryAreaTypeWeather) MarshalJSON() ([]byte, error) MarshalJSON encodes StoryAreaTypeWeather with the discriminator field "type" forced to "weather". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [StoryAreaTypeWeatherType]() - - - -```go -type StoryAreaTypeWeatherType string -``` - - - -```go -const ( - StoryAreaTypeWeatherTypeWeather StoryAreaTypeWeatherType = "weather" -) -``` - ## type [SuccessfulPayment]() @@ -14843,7 +14380,7 @@ type SuggestedPostInfo struct { ``` -## type [SuggestedPostInfoState]() +## type [SuggestedPostInfoState]() @@ -14880,7 +14417,7 @@ type SuggestedPostPaid struct { ``` -## type [SuggestedPostPaidCurrency]() +## type [SuggestedPostPaidCurrency]() @@ -14940,7 +14477,7 @@ type SuggestedPostRefunded struct { ``` -## type [SuggestedPostRefundedReason]() +## type [SuggestedPostRefundedReason]() @@ -15033,7 +14570,7 @@ Describes the affiliate program that issued the affiliate commission received vi ```go type TransactionPartnerAffiliateProgram struct { // Type of the transaction partner, always “affiliate_program” - Type TransactionPartnerAffiliateProgramType `json:"type"` + Type TransactionPartnerType `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 @@ -15050,23 +14587,6 @@ func (v *TransactionPartnerAffiliateProgram) MarshalJSON() ([]byte, error) MarshalJSON encodes TransactionPartnerAffiliateProgram with the discriminator field "type" forced to "affiliate\_program". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [TransactionPartnerAffiliateProgramType]() - - - -```go -type TransactionPartnerAffiliateProgramType string -``` - - - -```go -const ( - TransactionPartnerAffiliateProgramTypeAffiliateProgram TransactionPartnerAffiliateProgramType = "affiliate_program" -) -``` - ## type [TransactionPartnerChat]() @@ -15075,7 +14595,7 @@ Describes a transaction with a chat. ```go type TransactionPartnerChat struct { // Type of the transaction partner, always “chat” - Type MessageOriginChatType `json:"type"` + Type TransactionPartnerType `json:"type"` // Information about the chat Chat Chat `json:"chat"` // Optional. The gift sent to the chat by the bot @@ -15100,7 +14620,7 @@ Describes a withdrawal transaction with Fragment. ```go type TransactionPartnerFragment struct { // Type of the transaction partner, always “fragment” - Type TransactionPartnerFragmentType `json:"type"` + Type TransactionPartnerType `json:"type"` // Optional. State of the transaction if the transaction is outgoing WithdrawalState RevenueWithdrawalState `json:"withdrawal_state,omitempty"` } @@ -15124,23 +14644,6 @@ func (m *TransactionPartnerFragment) UnmarshalJSON(data []byte) error UnmarshalJSON decodes TransactionPartnerFragment by dispatching union\-typed fields \(WithdrawalState\) through their concrete UnmarshalXxx helpers. - -## type [TransactionPartnerFragmentType]() - - - -```go -type TransactionPartnerFragmentType string -``` - - - -```go -const ( - TransactionPartnerFragmentTypeFragment TransactionPartnerFragmentType = "fragment" -) -``` - ## type [TransactionPartnerOther]() @@ -15149,7 +14652,7 @@ Describes a transaction with an unknown source or recipient. ```go type TransactionPartnerOther struct { // Type of the transaction partner, always “other” - Type TransactionPartnerOtherType `json:"type"` + Type TransactionPartnerType `json:"type"` } ``` @@ -15162,23 +14665,6 @@ func (v *TransactionPartnerOther) MarshalJSON() ([]byte, error) MarshalJSON encodes TransactionPartnerOther with the discriminator field "type" forced to "other". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [TransactionPartnerOtherType]() - - - -```go -type TransactionPartnerOtherType string -``` - - - -```go -const ( - TransactionPartnerOtherTypeOther TransactionPartnerOtherType = "other" -) -``` - ## type [TransactionPartnerTelegramAds]() @@ -15187,7 +14673,7 @@ Describes a withdrawal transaction to the Telegram Ads platform. ```go type TransactionPartnerTelegramAds struct { // Type of the transaction partner, always “telegram_ads” - Type TransactionPartnerTelegramAdsType `json:"type"` + Type TransactionPartnerType `json:"type"` } ``` @@ -15200,23 +14686,6 @@ func (v *TransactionPartnerTelegramAds) MarshalJSON() ([]byte, error) MarshalJSON encodes TransactionPartnerTelegramAds with the discriminator field "type" forced to "telegram\_ads". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [TransactionPartnerTelegramAdsType]() - - - -```go -type TransactionPartnerTelegramAdsType string -``` - - - -```go -const ( - TransactionPartnerTelegramAdsTypeTelegramAds TransactionPartnerTelegramAdsType = "telegram_ads" -) -``` - ## type [TransactionPartnerTelegramApi]() @@ -15225,7 +14694,7 @@ Describes a transaction with payment for paid broadcasting. ```go type TransactionPartnerTelegramApi struct { // Type of the transaction partner, always “telegram_api” - Type TransactionPartnerTelegramApiType `json:"type"` + Type TransactionPartnerType `json:"type"` // The number of successful requests that exceeded regular limits and were therefore billed RequestCount int64 `json:"request_count"` } @@ -15240,20 +14709,26 @@ func (v *TransactionPartnerTelegramApi) MarshalJSON() ([]byte, error) MarshalJSON encodes TransactionPartnerTelegramApi with the discriminator field "type" forced to "telegram\_api". The hardcoded value frees callers from setting Type by hand — any user\-supplied value on the struct literal is overridden so a typo can't slip through to Telegram. - -## type [TransactionPartnerTelegramApiType]() + +## type [TransactionPartnerType]() ```go -type TransactionPartnerTelegramApiType string +type TransactionPartnerType string ``` - + ```go const ( - TransactionPartnerTelegramApiTypeTelegramApi TransactionPartnerTelegramApiType = "telegram_api" + TransactionPartnerTypeUser TransactionPartnerType = "user" + TransactionPartnerTypeChat TransactionPartnerType = "chat" + TransactionPartnerTypeAffiliateProgram TransactionPartnerType = "affiliate_program" + TransactionPartnerTypeFragment TransactionPartnerType = "fragment" + TransactionPartnerTypeTelegramAds TransactionPartnerType = "telegram_ads" + TransactionPartnerTypeTelegramApi TransactionPartnerType = "telegram_api" + TransactionPartnerTypeOther TransactionPartnerType = "other" ) ``` @@ -15265,7 +14740,7 @@ Describes a transaction with a user. ```go type TransactionPartnerUser struct { // Type of the transaction partner, always “user” - Type MessageOriginUserType `json:"type"` + Type TransactionPartnerType `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 TransactionPartnerUserTransactionType `json:"transaction_type"` // Information about the user @@ -15306,7 +14781,7 @@ func (m *TransactionPartnerUser) UnmarshalJSON(data []byte) error UnmarshalJSON decodes TransactionPartnerUser by dispatching union\-typed fields \(PaidMedia\) through their concrete UnmarshalXxx helpers. -## type [TransactionPartnerUserTransactionType]() +## type [TransactionPartnerUserTransactionType]() @@ -15525,7 +15000,7 @@ type UniqueGiftInfo struct { ``` -## type [UniqueGiftInfoOrigin]() +## type [UniqueGiftInfoOrigin]() @@ -15564,7 +15039,7 @@ type UniqueGiftModel struct { ``` -## type [UniqueGiftModelRarity]() +## type [UniqueGiftModelRarity]()