3 Commits

Author SHA1 Message Date
lukaszraczylo 60eb0a89b5 refactor(api): typed enums for emoji-list fields (DiceEmoji, ReactionEmoji)
Two API fields carry restricted emoji-value sets that the scraper's
curly-quote regex strips during IR extraction (multi-byte boundary
issue): ReactionTypeEmoji.Emoji and sendDice.Emoji. They previously
typed as plain string with no compile-time guarantee on values.

Add hand-curated typed-string enums in api/enums.go (the manual file,
not enums.gen.go):

  - DiceEmoji: 6 constants (Dice, Dart, Basketball, Football, Bowling,
    SlotMachine) covering Telegram's full set for sendDice.
  - ReactionEmoji: 73 constants covering the canonical reaction set
    from https://core.telegram.org/bots/api#reactiontypeemoji. Names
    follow Unicode CLDR short names where one exists, otherwise stable
    common-English labels (e.g. ThumbsUp, Heart, Clown, ManTechnologist).

Wire the field-type override via cmd/genapi/emitter.go:

  - fieldTypeOverrides map keyed "<TypeOrParamsName>.<FieldName>".
  - goField/multipartFieldEntry consult the override after the enum-plan
    lookup; falls through to the default goType when nothing matches.
  - methods.tmpl gains goFieldP/multipartFieldEntryP helpers that pass
    the params type name as override-parent (the params struct doesn't
    share a Go type with the field, so the existing parent="" enum-key
    convention is preserved).

Regenerated api/types.gen.go and api/methods.gen.go now type the two
fields as ReactionEmoji and DiceEmoji respectively. No other Emoji
field is affected (override is scoped per parent type). regen-from-
fixture is byte-deterministic across runs.

Add api/emoji_enums_test.go covering const wire values, reflection
checks on field types, and a marshal/unmarshal round-trip for
ReactionTypeEmoji.
2026-05-09 20:47:16 +01:00
lukaszraczylo fecef22f48 refactor(scrape): detect prose-style "must be X" discriminator values on variants
Sealed-interface union variants whose Type/Source field is declared as
bare prose (e.g. "Type of the result, must be article" or "Scope type,
must be all_private_chats") were skipped by extractEnumValues because
the existing patterns require curly-quoted values. The genapi emitter
already extracted these values via discBareRE for marshal-side
discriminator injection; lifting the same detection into the scraper
populates Field.EnumValues so planUnifiedUnionEnums folds them into
shared union-level enums automatically.

Unions newly unified (10): BotCommandScope, MenuButton, InputMedia,
InputPaidMedia, InputPollMedia, InputPollOptionMedia, InputProfilePhoto,
InputStoryContent, InlineQueryResult, PassportElementError.

InputMessageContent stays excluded — its variants dispatch
structurally on field presence and have no Type/Source field, so
planUnifiedUnionEnums correctly skips it.

Constants added: 60 typed enum constants across the 10 unions; the
corresponding variant struct fields are retyped from string to the
shared enum.

Internal call-site cleanups: 0 — no internal package referenced these
discriminator values via magic strings.

False positives the prose detector explicitly rejects: terminal
prose-word continuations like "must be sent", "must be shown above",
"must be specified", "must be paid", "must be active", "must be one
of 3, 6, or 12", "must be between 5 and 100000", "must be a Pay
button", "must be repainted". Guarded via terminal-position regex
anchor + closed-list isProseWord filter.

Determinism verified across two consecutive make regen-from-fixture
runs. go test -race ./..., go vet ./..., staticcheck ./... all clean.
2026-05-09 20:37:07 +01:00
lukaszraczylo 5523ed2b06 refactor(api): unify per-variant single-value enums into shared union-level enums
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.
2026-05-09 20:26:08 +01:00
16 changed files with 2078 additions and 1148 deletions
+239
View File
@@ -0,0 +1,239 @@
package api
import (
"reflect"
"testing"
json "github.com/goccy/go-json"
"github.com/stretchr/testify/require"
)
// TestUnifiedEnum_BotCommandScopeType_Constants confirms the prose-form
// discriminator detection promoted BotCommandScope's per-variant Type
// fields into one shared enum.
func TestUnifiedEnum_BotCommandScopeType_Constants(t *testing.T) {
require.IsType(t, BotCommandScopeType(""), BotCommandScopeTypeDefault)
got := []BotCommandScopeType{
BotCommandScopeTypeDefault,
BotCommandScopeTypeAllPrivateChats,
BotCommandScopeTypeAllGroupChats,
BotCommandScopeTypeAllChatAdministrators,
BotCommandScopeTypeChat,
BotCommandScopeTypeChatAdministrators,
BotCommandScopeTypeChatMember,
}
want := []string{
"default", "all_private_chats", "all_group_chats",
"all_chat_administrators", "chat", "chat_administrators", "chat_member",
}
require.Len(t, got, len(want))
for i, v := range got {
require.Equal(t, want[i], string(v))
}
}
// TestUnifiedEnum_InlineQueryResultType_VariantFields walks the variants
// and asserts each one's Type field is the unified enum.
func TestUnifiedEnum_InlineQueryResultType_VariantFields(t *testing.T) {
require.IsType(t, InlineQueryResultType(""), InlineQueryResultTypeArticle)
wantType := reflect.TypeOf(InlineQueryResultType(""))
cases := []any{
&InlineQueryResultArticle{},
&InlineQueryResultPhoto{},
&InlineQueryResultGif{},
&InlineQueryResultMpeg4Gif{},
&InlineQueryResultVideo{},
&InlineQueryResultAudio{},
&InlineQueryResultVoice{},
&InlineQueryResultDocument{},
&InlineQueryResultLocation{},
&InlineQueryResultVenue{},
&InlineQueryResultContact{},
&InlineQueryResultGame{},
}
for _, c := range cases {
rt := reflect.TypeOf(c).Elem()
f, ok := rt.FieldByName("Type")
require.True(t, ok, "%s missing Type field", rt.Name())
require.Equal(t, wantType, f.Type, "%s.Type type mismatch", rt.Name())
}
}
// TestUnifiedEnum_PassportElementErrorSource_VariantFields asserts the
// retype landed on every variant of the PassportElementError union.
func TestUnifiedEnum_PassportElementErrorSource_VariantFields(t *testing.T) {
require.IsType(t, PassportElementErrorSource(""), PassportElementErrorSourceData)
wantType := reflect.TypeOf(PassportElementErrorSource(""))
cases := []any{
&PassportElementErrorDataField{},
&PassportElementErrorFrontSide{},
&PassportElementErrorReverseSide{},
&PassportElementErrorSelfie{},
&PassportElementErrorFile{},
&PassportElementErrorFiles{},
&PassportElementErrorTranslationFile{},
&PassportElementErrorTranslationFiles{},
&PassportElementErrorUnspecified{},
}
for _, c := range cases {
rt := reflect.TypeOf(c).Elem()
f, ok := rt.FieldByName("Source")
require.True(t, ok, "%s missing Source field", rt.Name())
require.Equal(t, wantType, f.Type, "%s.Source type mismatch", rt.Name())
}
}
// TestUnifiedEnum_InputMediaType_Constants covers a media-shaped union
// where the discriminator value is the wire identifier "animation",
// "photo", etc.
func TestUnifiedEnum_InputMediaType_Constants(t *testing.T) {
require.IsType(t, InputMediaType(""), InputMediaTypePhoto)
wantType := reflect.TypeOf(InputMediaType(""))
for _, c := range []any{
&InputMediaAnimation{},
&InputMediaAudio{},
&InputMediaDocument{},
&InputMediaPhoto{},
&InputMediaVideo{},
} {
rt := reflect.TypeOf(c).Elem()
f, ok := rt.FieldByName("Type")
require.True(t, ok, "%s missing Type field", rt.Name())
require.Equal(t, wantType, f.Type, "%s.Type type mismatch", rt.Name())
}
}
// TestUnifiedEnum_MenuButtonType_Constants covers the third single-Type
// union pulled in by the prose detector.
func TestUnifiedEnum_MenuButtonType_Constants(t *testing.T) {
require.IsType(t, MenuButtonType(""), MenuButtonTypeCommands)
wantType := reflect.TypeOf(MenuButtonType(""))
for _, c := range []any{
&MenuButtonCommands{},
&MenuButtonWebApp{},
&MenuButtonDefault{},
} {
rt := reflect.TypeOf(c).Elem()
f, ok := rt.FieldByName("Type")
require.True(t, ok, "%s missing Type field", rt.Name())
require.Equal(t, wantType, f.Type, "%s.Type type mismatch", rt.Name())
}
}
// TestUnifiedEnum_InlineQueryResultArticle_RoundTrip confirms the
// auto-injected discriminator survives a marshal-unmarshal cycle on the
// concrete variant and lands as the typed enum constant. There's no
// generated UnmarshalInlineQueryResult — the union has no entry in
// knownDiscriminators — so the round-trip targets the variant directly.
func TestUnifiedEnum_InlineQueryResultArticle_RoundTrip(t *testing.T) {
orig := &InlineQueryResultArticle{
ID: "x1",
Title: "test",
}
raw, err := json.Marshal(orig)
require.NoError(t, err)
var probe struct {
Type string `json:"type"`
}
require.NoError(t, json.Unmarshal(raw, &probe))
require.Equal(t, "article", probe.Type)
// Strip InputMessageContent before re-decoding: it's a sealed
// interface and the variant has no UnmarshalJSON helper to dispatch
// it. The discriminator round-trip is the property under test, not
// nested-union deserialisation.
var round struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
Title string `json:"title"`
}
require.NoError(t, json.Unmarshal(raw, &round))
require.Equal(t, InlineQueryResultTypeArticle, round.Type)
require.Equal(t, orig.ID, round.ID)
require.Equal(t, orig.Title, round.Title)
}
// TestUnifiedEnum_PassportElementErrorDataField_RoundTrip mirrors the
// above for the Source-discriminated union.
func TestUnifiedEnum_PassportElementErrorDataField_RoundTrip(t *testing.T) {
orig := &PassportElementErrorDataField{
Type: "personal_details",
FieldName: "first_name",
DataHash: "abc",
Message: "boom",
}
raw, err := json.Marshal(orig)
require.NoError(t, err)
var probe struct {
Source string `json:"source"`
}
require.NoError(t, json.Unmarshal(raw, &probe))
require.Equal(t, "data", probe.Source)
var round PassportElementErrorDataField
require.NoError(t, json.Unmarshal(raw, &round))
require.Equal(t, PassportElementErrorSourceData, round.Source)
require.Equal(t, orig.FieldName, round.FieldName)
}
// TestUnifiedEnum_BotCommandScopeChat_RoundTrip covers a bot-command
// scope variant with a non-trivial extra field (ChatID).
func TestUnifiedEnum_BotCommandScopeChat_RoundTrip(t *testing.T) {
orig := &BotCommandScopeChat{ChatID: ChatIDFromInt(42)}
raw, err := json.Marshal(orig)
require.NoError(t, err)
var probe struct {
Type string `json:"type"`
}
require.NoError(t, json.Unmarshal(raw, &probe))
require.Equal(t, "chat", probe.Type)
var round BotCommandScopeChat
require.NoError(t, json.Unmarshal(raw, &round))
require.Equal(t, BotCommandScopeTypeChat, round.Type)
}
// TestUnifiedEnum_InputMessageContent_NoEnumEmitted confirms the IMC
// union — which dispatches structurally on field presence rather than a
// shared discriminator — does NOT get a unified enum, since none of its
// variants declare a single-value discriminator field.
func TestUnifiedEnum_InputMessageContent_NoEnumEmitted(t *testing.T) {
for _, name := range []string{
"InputTextMessageContent",
"InputLocationMessageContent",
"InputVenueMessageContent",
"InputContactMessageContent",
"InputInvoiceMessageContent",
} {
switch name {
case "InputTextMessageContent":
rt := reflect.TypeOf(&InputTextMessageContent{}).Elem()
_, ok := rt.FieldByName("Type")
require.False(t, ok, "%s unexpectedly grew a Type field", name)
case "InputLocationMessageContent":
rt := reflect.TypeOf(&InputLocationMessageContent{}).Elem()
_, ok := rt.FieldByName("Type")
require.False(t, ok, "%s unexpectedly grew a Type field", name)
case "InputVenueMessageContent":
rt := reflect.TypeOf(&InputVenueMessageContent{}).Elem()
_, ok := rt.FieldByName("Type")
require.False(t, ok, "%s unexpectedly grew a Type field", name)
case "InputContactMessageContent":
rt := reflect.TypeOf(&InputContactMessageContent{}).Elem()
_, ok := rt.FieldByName("Type")
require.False(t, ok, "%s unexpectedly grew a Type field", name)
case "InputInvoiceMessageContent":
rt := reflect.TypeOf(&InputInvoiceMessageContent{}).Elem()
_, ok := rt.FieldByName("Type")
require.False(t, ok, "%s unexpectedly grew a Type field", name)
}
}
}
+96
View File
@@ -0,0 +1,96 @@
package api
import (
"reflect"
"testing"
"github.com/goccy/go-json"
"github.com/stretchr/testify/require"
)
// TestDiceEmoji_Constants pins the canonical six dice-emoji values so a
// regen, refactor, or accidental rename can't silently break the wire
// contract.
func TestDiceEmoji_Constants(t *testing.T) {
cases := []struct {
name string
got DiceEmoji
want string
}{
{"Dice", DiceEmojiDice, "🎲"},
{"Dart", DiceEmojiDart, "🎯"},
{"Basketball", DiceEmojiBasketball, "🏀"},
{"Football", DiceEmojiFootball, "⚽"},
{"Bowling", DiceEmojiBowling, "🎳"},
{"SlotMachine", DiceEmojiSlotMachine, "🎰"},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
require.Equal(t, c.want, string(c.got))
})
}
}
// TestSendDiceParams_EmojiFieldType asserts the codegen override wired
// SendDiceParams.Emoji to the typed enum (not plain string). Reflection
// catches a regression even if the file compiles via implicit string
// conversion of an untyped literal.
func TestSendDiceParams_EmojiFieldType(t *testing.T) {
rt := reflect.TypeOf(SendDiceParams{})
f, ok := rt.FieldByName("Emoji")
require.True(t, ok, "SendDiceParams.Emoji not present")
require.Equal(t, "DiceEmoji", f.Type.Name())
}
// TestSendDiceParams_MarshalJSON exercises the marshalled wire form to
// prove the typed enum still serialises as a JSON string holding the
// raw emoji bytes — i.e. the type override doesn't accidentally
// double-encode.
func TestSendDiceParams_MarshalJSON(t *testing.T) {
p := &SendDiceParams{
ChatID: ChatIDFromInt(1),
Emoji: DiceEmojiBasketball,
}
data, err := json.Marshal(p)
require.NoError(t, err)
require.Contains(t, string(data), `"emoji":"🏀"`)
}
// TestReactionEmoji_Constants spot-checks a representative slice of the
// 73-value enum. A full enumeration would be redundant — the test is
// here to lock the wire form, not to retest the const-block.
func TestReactionEmoji_Constants(t *testing.T) {
require.Equal(t, "👍", string(ReactionEmojiThumbsUp))
require.Equal(t, "👎", string(ReactionEmojiThumbsDown))
require.Equal(t, "❤", string(ReactionEmojiHeart))
require.Equal(t, "🔥", string(ReactionEmojiFire))
require.Equal(t, "💯", string(ReactionEmojiHundredPoints))
require.Equal(t, "🤡", string(ReactionEmojiClown))
}
// TestReactionTypeEmoji_FieldType asserts the codegen override wired
// ReactionTypeEmoji.Emoji to the typed enum.
func TestReactionTypeEmoji_FieldType(t *testing.T) {
rt := reflect.TypeOf(ReactionTypeEmoji{})
f, ok := rt.FieldByName("Emoji")
require.True(t, ok, "ReactionTypeEmoji.Emoji not present")
require.Equal(t, "ReactionEmoji", f.Type.Name())
}
// TestReactionTypeEmoji_RoundTrip proves a typed-enum value survives
// JSON marshal → unmarshal cycle without losing fidelity. The
// discriminator MarshalJSON on ReactionTypeEmoji forces type="emoji",
// so we set it explicitly here for symmetry with the unmarshal path.
func TestReactionTypeEmoji_RoundTrip(t *testing.T) {
in := &ReactionTypeEmoji{
Type: ReactionTypeKindEmoji,
Emoji: ReactionEmojiThumbsUp,
}
data, err := json.Marshal(in)
require.NoError(t, err)
require.Contains(t, string(data), `"emoji":"👍"`)
var out ReactionTypeEmoji
require.NoError(t, json.Unmarshal(data, &out))
require.Equal(t, ReactionEmojiThumbsUp, out.Emoji)
}
+161 -204
View File
@@ -4,100 +4,52 @@
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 BotCommandScopeType string
const (
BackgroundFillSolidTypeSolid BackgroundFillSolidType = "solid"
BotCommandScopeTypeDefault BotCommandScopeType = "default"
BotCommandScopeTypeAllPrivateChats BotCommandScopeType = "all_private_chats"
BotCommandScopeTypeAllGroupChats BotCommandScopeType = "all_group_chats"
BotCommandScopeTypeAllChatAdministrators BotCommandScopeType = "all_chat_administrators"
BotCommandScopeTypeChat BotCommandScopeType = "chat"
BotCommandScopeTypeChatAdministrators BotCommandScopeType = "chat_administrators"
BotCommandScopeTypeChatMember BotCommandScopeType = "chat_member"
)
type BackgroundTypeChatThemeType string
type ChatBoostSourceKind string
const (
BackgroundTypeChatThemeTypeChatTheme BackgroundTypeChatThemeType = "chat_theme"
ChatBoostSourceKindPremium ChatBoostSourceKind = "premium"
ChatBoostSourceKindGiftCode ChatBoostSourceKind = "gift_code"
ChatBoostSourceKindGiveaway ChatBoostSourceKind = "giveaway"
)
type BackgroundTypeFillType string
type ChatMemberStatus 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
@@ -152,6 +104,75 @@ const (
InlineQueryResultGifThumbnailMimeTypeVideoOfMp4 InlineQueryResultGifThumbnailMimeType = "video/mp4"
)
type InlineQueryResultType string
const (
InlineQueryResultTypeAudio InlineQueryResultType = "audio"
InlineQueryResultTypeDocument InlineQueryResultType = "document"
InlineQueryResultTypeGif InlineQueryResultType = "gif"
InlineQueryResultTypeMpeg4Gif InlineQueryResultType = "mpeg4_gif"
InlineQueryResultTypePhoto InlineQueryResultType = "photo"
InlineQueryResultTypeSticker InlineQueryResultType = "sticker"
InlineQueryResultTypeVideo InlineQueryResultType = "video"
InlineQueryResultTypeVoice InlineQueryResultType = "voice"
InlineQueryResultTypeArticle InlineQueryResultType = "article"
InlineQueryResultTypeContact InlineQueryResultType = "contact"
InlineQueryResultTypeGame InlineQueryResultType = "game"
InlineQueryResultTypeLocation InlineQueryResultType = "location"
InlineQueryResultTypeVenue InlineQueryResultType = "venue"
)
type InputMediaType string
const (
InputMediaTypeAnimation InputMediaType = "animation"
InputMediaTypeAudio InputMediaType = "audio"
InputMediaTypeDocument InputMediaType = "document"
InputMediaTypeLivePhoto InputMediaType = "live_photo"
InputMediaTypePhoto InputMediaType = "photo"
InputMediaTypeVideo InputMediaType = "video"
)
type InputPaidMediaType string
const (
InputPaidMediaTypeLivePhoto InputPaidMediaType = "live_photo"
InputPaidMediaTypePhoto InputPaidMediaType = "photo"
InputPaidMediaTypeVideo InputPaidMediaType = "video"
)
type InputPollMediaType string
const (
InputPollMediaTypeAnimation InputPollMediaType = "animation"
InputPollMediaTypeAudio InputPollMediaType = "audio"
InputPollMediaTypeDocument InputPollMediaType = "document"
InputPollMediaTypeLivePhoto InputPollMediaType = "live_photo"
InputPollMediaTypeLocation InputPollMediaType = "location"
InputPollMediaTypePhoto InputPollMediaType = "photo"
InputPollMediaTypeVenue InputPollMediaType = "venue"
InputPollMediaTypeVideo InputPollMediaType = "video"
)
type InputPollOptionMediaType string
const (
InputPollOptionMediaTypeAnimation InputPollOptionMediaType = "animation"
InputPollOptionMediaTypeLivePhoto InputPollOptionMediaType = "live_photo"
InputPollOptionMediaTypeLocation InputPollOptionMediaType = "location"
InputPollOptionMediaTypePhoto InputPollOptionMediaType = "photo"
InputPollOptionMediaTypeSticker InputPollOptionMediaType = "sticker"
InputPollOptionMediaTypeVenue InputPollOptionMediaType = "venue"
InputPollOptionMediaTypeVideo InputPollOptionMediaType = "video"
)
type InputProfilePhotoType string
const (
InputProfilePhotoTypeStatic InputProfilePhotoType = "static"
InputProfilePhotoTypeAnimated InputProfilePhotoType = "animated"
)
type InputStickerFormat string
const (
@@ -160,6 +181,13 @@ const (
InputStickerFormatVideo InputStickerFormat = "video"
)
type InputStoryContentType string
const (
InputStoryContentTypePhoto InputStoryContentType = "photo"
InputStoryContentTypeVideo InputStoryContentType = "video"
)
type KeyboardButtonStyle string
const (
@@ -177,6 +205,14 @@ const (
MaskPositionPointChin MaskPositionPoint = "chin"
)
type MenuButtonType string
const (
MenuButtonTypeCommands MenuButtonType = "commands"
MenuButtonTypeWebApp MenuButtonType = "web_app"
MenuButtonTypeDefault MenuButtonType = "default"
)
type MessageEntityType string
const (
@@ -202,64 +238,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
@@ -307,6 +308,20 @@ const (
PassportElementErrorSelfieTypeInternalPassport PassportElementErrorSelfieType = "internal_passport"
)
type PassportElementErrorSource string
const (
PassportElementErrorSourceData PassportElementErrorSource = "data"
PassportElementErrorSourceFrontSide PassportElementErrorSource = "front_side"
PassportElementErrorSourceReverseSide PassportElementErrorSource = "reverse_side"
PassportElementErrorSourceSelfie PassportElementErrorSource = "selfie"
PassportElementErrorSourceFile PassportElementErrorSource = "file"
PassportElementErrorSourceFiles PassportElementErrorSource = "files"
PassportElementErrorSourceTranslationFile PassportElementErrorSource = "translation_file"
PassportElementErrorSourceTranslationFiles PassportElementErrorSource = "translation_files"
PassportElementErrorSourceUnspecified PassportElementErrorSource = "unspecified"
)
type PassportElementErrorTranslationFileType string
const (
@@ -328,22 +343,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 +357,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 +373,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 +405,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
+104
View File
@@ -32,3 +32,107 @@ const (
UpdateChatBoost UpdateType = "chat_boost"
UpdateRemovedChatBoost UpdateType = "removed_chat_boost"
)
// DiceEmoji is the set of emoji values accepted by sendDice. Telegram's
// canonical list is "🎲", "🎯", "🏀", "⚽", "🎳", "🎰". The codegen
// scraper drops these values during regex extraction (multi-byte
// boundary issues with curly-quoted emoji), so this enum is hand-
// curated and wired into SendDiceParams.Emoji via the per-field type
// override in cmd/genapi/emitter.go.
type DiceEmoji string
const (
DiceEmojiDice DiceEmoji = "🎲"
DiceEmojiDart DiceEmoji = "🎯"
DiceEmojiBasketball DiceEmoji = "🏀"
DiceEmojiFootball DiceEmoji = "⚽"
DiceEmojiBowling DiceEmoji = "🎳"
DiceEmojiSlotMachine DiceEmoji = "🎰"
)
// ReactionEmoji is the set of emoji Telegram allows in a
// ReactionTypeEmoji.Emoji value. Hand-curated from
// https://core.telegram.org/bots/api#reactiontypeemoji because the
// scraper's curly-quote regex strips the emoji literals (byte-boundary
// issue on multi-byte sequences). Names mirror the Unicode CLDR short
// name where one exists; otherwise a stable common-English label.
// Telegram occasionally extends this set — passers of unrecognised
// strings still type-check (ReactionEmoji is a string alias) so this
// list need not block runtime use of newer values.
type ReactionEmoji string
const (
ReactionEmojiHeart ReactionEmoji = "❤"
ReactionEmojiThumbsUp ReactionEmoji = "👍"
ReactionEmojiThumbsDown ReactionEmoji = "👎"
ReactionEmojiFire ReactionEmoji = "🔥"
ReactionEmojiSmilingFaceWithHearts ReactionEmoji = "🥰"
ReactionEmojiClappingHands ReactionEmoji = "👏"
ReactionEmojiBeamingFace ReactionEmoji = "😁"
ReactionEmojiThinkingFace ReactionEmoji = "🤔"
ReactionEmojiExplodingHead ReactionEmoji = "🤯"
ReactionEmojiScreamingFace ReactionEmoji = "😱"
ReactionEmojiCursingFace ReactionEmoji = "🤬"
ReactionEmojiCryingFace ReactionEmoji = "😢"
ReactionEmojiPartyPopper ReactionEmoji = "🎉"
ReactionEmojiStarStruck ReactionEmoji = "🤩"
ReactionEmojiVomiting ReactionEmoji = "🤮"
ReactionEmojiPileOfPoo ReactionEmoji = "💩"
ReactionEmojiFoldedHands ReactionEmoji = "🙏"
ReactionEmojiOKHand ReactionEmoji = "👌"
ReactionEmojiDove ReactionEmoji = "🕊"
ReactionEmojiClown ReactionEmoji = "🤡"
ReactionEmojiYawning ReactionEmoji = "🥱"
ReactionEmojiWoozyFace ReactionEmoji = "🥴"
ReactionEmojiHeartEyes ReactionEmoji = "😍"
ReactionEmojiWhale ReactionEmoji = "🐳"
ReactionEmojiHeartOnFire ReactionEmoji = "❤‍🔥"
ReactionEmojiNewMoonFace ReactionEmoji = "🌚"
ReactionEmojiHotDog ReactionEmoji = "🌭"
ReactionEmojiHundredPoints ReactionEmoji = "💯"
ReactionEmojiRollingOnFloor ReactionEmoji = "🤣"
ReactionEmojiLightning ReactionEmoji = "⚡"
ReactionEmojiBanana ReactionEmoji = "🍌"
ReactionEmojiTrophy ReactionEmoji = "🏆"
ReactionEmojiBrokenHeart ReactionEmoji = "💔"
ReactionEmojiRaisedEyebrow ReactionEmoji = "🤨"
ReactionEmojiNeutralFace ReactionEmoji = "😐"
ReactionEmojiStrawberry ReactionEmoji = "🍓"
ReactionEmojiChampagne ReactionEmoji = "🍾"
ReactionEmojiKissMark ReactionEmoji = "💋"
ReactionEmojiMiddleFinger ReactionEmoji = "🖕"
ReactionEmojiDevil ReactionEmoji = "😈"
ReactionEmojiSleeping ReactionEmoji = "😴"
ReactionEmojiLoudlyCrying ReactionEmoji = "😭"
ReactionEmojiNerd ReactionEmoji = "🤓"
ReactionEmojiGhost ReactionEmoji = "👻"
ReactionEmojiManTechnologist ReactionEmoji = "👨‍💻"
ReactionEmojiEyes ReactionEmoji = "👀"
ReactionEmojiJackOLantern ReactionEmoji = "🎃"
ReactionEmojiSeeNoEvil ReactionEmoji = "🙈"
ReactionEmojiHalo ReactionEmoji = "😇"
ReactionEmojiFearful ReactionEmoji = "😨"
ReactionEmojiHandshake ReactionEmoji = "🤝"
ReactionEmojiWriting ReactionEmoji = "✍"
ReactionEmojiHugging ReactionEmoji = "🤗"
ReactionEmojiSaluting ReactionEmoji = "🫡"
ReactionEmojiSantaClaus ReactionEmoji = "🎅"
ReactionEmojiChristmasTree ReactionEmoji = "🎄"
ReactionEmojiSnowman ReactionEmoji = "☃"
ReactionEmojiNailPolish ReactionEmoji = "💅"
ReactionEmojiZanyFace ReactionEmoji = "🤪"
ReactionEmojiMoai ReactionEmoji = "🗿"
ReactionEmojiCool ReactionEmoji = "🆒"
ReactionEmojiHeartWithArrow ReactionEmoji = "💘"
ReactionEmojiHearNoEvil ReactionEmoji = "🙉"
ReactionEmojiUnicorn ReactionEmoji = "🦄"
ReactionEmojiKissingFace ReactionEmoji = "😘"
ReactionEmojiPill ReactionEmoji = "💊"
ReactionEmojiSpeakNoEvil ReactionEmoji = "🙊"
ReactionEmojiSmilingFaceWithSunglasses ReactionEmoji = "😎"
ReactionEmojiAlienMonster ReactionEmoji = "👾"
ReactionEmojiManShrugging ReactionEmoji = "🤷‍♂"
ReactionEmojiPersonShrugging ReactionEmoji = "🤷"
ReactionEmojiWomanShrugging ReactionEmoji = "🤷‍♀"
ReactionEmojiPoutingFace ReactionEmoji = "😡"
)
+1 -1
View File
@@ -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)
}
+1 -1
View File
@@ -1953,7 +1953,7 @@ type SendDiceParams struct {
// Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat
DirectMessagesTopicID *int64 `json:"direct_messages_topic_id,omitempty"`
// Emoji on which the dice throw animation is based. Currently, must be one of “”, “”, “”, “”, “”, or “”. Dice can have values 1-6 for “”, “” and “”, values 1-5 for “” and “”, and values 1-64 for “”. Defaults to “”
Emoji string `json:"emoji,omitempty"`
Emoji DiceEmoji `json:"emoji,omitempty"`
// Sends the message silently. Users will receive a notification with no sound.
DisableNotification *bool `json:"disable_notification,omitempty"`
// Protects the contents of the sent message from forwarding
+100 -100
View File
@@ -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,9 +3470,9 @@ 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"`
Emoji ReactionEmoji `json:"emoji"`
}
// MarshalJSON encodes ReactionTypeEmoji with the discriminator field
@@ -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
@@ -4082,7 +4082,7 @@ func (*BotCommandScopeChatMember) isBotCommandScope() {}
// Represents the default scope of bot commands. Default commands are used if no commands with a narrower scope are specified for the user.
type BotCommandScopeDefault struct {
// Scope type, must be default
Type string `json:"type"`
Type BotCommandScopeType `json:"type"`
}
// MarshalJSON encodes BotCommandScopeDefault with the discriminator field
@@ -4104,7 +4104,7 @@ func (v *BotCommandScopeDefault) MarshalJSON() ([]byte, error) {
// Represents the scope of bot commands, covering all private chats.
type BotCommandScopeAllPrivateChats struct {
// Scope type, must be all_private_chats
Type string `json:"type"`
Type BotCommandScopeType `json:"type"`
}
// MarshalJSON encodes BotCommandScopeAllPrivateChats with the discriminator field
@@ -4126,7 +4126,7 @@ func (v *BotCommandScopeAllPrivateChats) MarshalJSON() ([]byte, error) {
// Represents the scope of bot commands, covering all group and supergroup chats.
type BotCommandScopeAllGroupChats struct {
// Scope type, must be all_group_chats
Type string `json:"type"`
Type BotCommandScopeType `json:"type"`
}
// MarshalJSON encodes BotCommandScopeAllGroupChats with the discriminator field
@@ -4148,7 +4148,7 @@ func (v *BotCommandScopeAllGroupChats) MarshalJSON() ([]byte, error) {
// Represents the scope of bot commands, covering all group and supergroup chat administrators.
type BotCommandScopeAllChatAdministrators struct {
// Scope type, must be all_chat_administrators
Type string `json:"type"`
Type BotCommandScopeType `json:"type"`
}
// MarshalJSON encodes BotCommandScopeAllChatAdministrators with the discriminator field
@@ -4170,7 +4170,7 @@ func (v *BotCommandScopeAllChatAdministrators) MarshalJSON() ([]byte, error) {
// Represents the scope of bot commands, covering a specific chat.
type BotCommandScopeChat struct {
// Scope type, must be chat
Type string `json:"type"`
Type BotCommandScopeType `json:"type"`
// Unique identifier for the target chat or username of the target supergroup in the format @username. Channel direct messages chats and channel chats aren't supported.
ChatID ChatID `json:"chat_id"`
}
@@ -4194,7 +4194,7 @@ func (v *BotCommandScopeChat) MarshalJSON() ([]byte, error) {
// Represents the scope of bot commands, covering all administrators of a specific group or supergroup chat.
type BotCommandScopeChatAdministrators struct {
// Scope type, must be chat_administrators
Type string `json:"type"`
Type BotCommandScopeType `json:"type"`
// Unique identifier for the target chat or username of the target supergroup in the format @username. Channel direct messages chats and channel chats aren't supported.
ChatID ChatID `json:"chat_id"`
}
@@ -4218,7 +4218,7 @@ func (v *BotCommandScopeChatAdministrators) MarshalJSON() ([]byte, error) {
// Represents the scope of bot commands, covering a specific member of a group or supergroup chat.
type BotCommandScopeChatMember struct {
// Scope type, must be chat_member
Type string `json:"type"`
Type BotCommandScopeType `json:"type"`
// Unique identifier for the target chat or username of the target supergroup in the format @username. Channel direct messages chats and channel chats aren't supported.
ChatID ChatID `json:"chat_id"`
// Unique identifier of the target user
@@ -4307,7 +4307,7 @@ func UnmarshalMenuButton(data []byte) (MenuButton, error) {
// Represents a menu button, which opens the bot's list of commands.
type MenuButtonCommands struct {
// Type of the button, must be commands
Type string `json:"type"`
Type MenuButtonType `json:"type"`
}
// MarshalJSON encodes MenuButtonCommands with the discriminator field
@@ -4329,7 +4329,7 @@ func (v *MenuButtonCommands) MarshalJSON() ([]byte, error) {
// Represents a menu button, which launches a Web App.
type MenuButtonWebApp struct {
// Type of the button, must be web_app
Type string `json:"type"`
Type MenuButtonType `json:"type"`
// Text on the button
Text string `json:"text"`
// Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Alternatively, a t.me link to a Web App of the bot can be specified in the object instead of the Web App's URL, in which case the Web App will be opened as if the user pressed the link.
@@ -4355,7 +4355,7 @@ func (v *MenuButtonWebApp) MarshalJSON() ([]byte, error) {
// Describes that no specific value for the menu button was set.
type MenuButtonDefault struct {
// Type of the button, must be default
Type string `json:"type"`
Type MenuButtonType `json:"type"`
}
// MarshalJSON encodes MenuButtonDefault with the discriminator field
@@ -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
@@ -4711,7 +4711,7 @@ func (*InputMediaVideo) isInputMedia() {}
// Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent.
type InputMediaAnimation struct {
// Type of the result, must be animation
Type string `json:"type"`
Type InputMediaType `json:"type"`
// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files »
Media string `json:"media"`
// Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »
@@ -4753,7 +4753,7 @@ func (v *InputMediaAnimation) MarshalJSON() ([]byte, error) {
// Represents an audio file to be treated as music to be sent.
type InputMediaAudio struct {
// Type of the result, must be audio
Type string `json:"type"`
Type InputMediaType `json:"type"`
// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files »
Media string `json:"media"`
// Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »
@@ -4791,7 +4791,7 @@ func (v *InputMediaAudio) MarshalJSON() ([]byte, error) {
// Represents a general file to be sent.
type InputMediaDocument struct {
// Type of the result, must be document
Type string `json:"type"`
Type InputMediaType `json:"type"`
// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files »
Media string `json:"media"`
// Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »
@@ -4825,7 +4825,7 @@ func (v *InputMediaDocument) MarshalJSON() ([]byte, error) {
// Represents a live photo to be sent.
type InputMediaLivePhoto struct {
// Type of the result, must be live_photo
Type string `json:"type"`
Type InputMediaType `json:"type"`
// Video of the live photo to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files ». Sending live photos by a URL is currently unsupported.
Media string `json:"media"`
// The static photo to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files ». Sending live photos by a URL is currently unsupported.
@@ -4861,7 +4861,7 @@ func (v *InputMediaLivePhoto) MarshalJSON() ([]byte, error) {
// Represents a location to be sent.
type InputMediaLocation struct {
// Type of the result, must be location
Type string `json:"type"`
Type InputPollOptionMediaType `json:"type"`
// Latitude of the location
Latitude float64 `json:"latitude"`
// Longitude of the location
@@ -4889,7 +4889,7 @@ func (v *InputMediaLocation) MarshalJSON() ([]byte, error) {
// Represents a photo to be sent.
type InputMediaPhoto struct {
// Type of the result, must be photo
Type string `json:"type"`
Type InputMediaType `json:"type"`
// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files »
Media string `json:"media"`
// Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing
@@ -4923,7 +4923,7 @@ func (v *InputMediaPhoto) MarshalJSON() ([]byte, error) {
// Represents a sticker file to be sent.
type InputMediaSticker struct {
// Type of the result, must be sticker
Type string `json:"type"`
Type InputPollOptionMediaType `json:"type"`
// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a .WEBP sticker from the Internet, or pass “attach://<file_attach_name>” to upload a new .WEBP, .TGS, or .WEBM sticker using multipart/form-data under <file_attach_name> name. More information on Sending Files »
Media string `json:"media"`
// Optional. Emoji associated with the sticker; only for just uploaded stickers
@@ -4949,7 +4949,7 @@ func (v *InputMediaSticker) MarshalJSON() ([]byte, error) {
// Represents a venue to be sent.
type InputMediaVenue struct {
// Type of the result, must be venue
Type string `json:"type"`
Type InputPollOptionMediaType `json:"type"`
// Latitude of the location
Latitude float64 `json:"latitude"`
// Longitude of the location
@@ -4987,7 +4987,7 @@ func (v *InputMediaVenue) MarshalJSON() ([]byte, error) {
// Represents a video to be sent.
type InputMediaVideo struct {
// Type of the result, must be video
Type string `json:"type"`
Type InputMediaType `json:"type"`
// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files »
Media string `json:"media"`
// Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »
@@ -5053,7 +5053,7 @@ func (*InputPaidMediaVideo) isInputPaidMedia() {}
// The paid media to send is a live photo.
type InputPaidMediaLivePhoto struct {
// Type of the media, must be live_photo
Type string `json:"type"`
Type InputPaidMediaType `json:"type"`
// Video of the live photo to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files ». Sending live photos by a URL is currently unsupported.
Media string `json:"media"`
// The static photo to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files ». Sending live photos by a URL is currently unsupported.
@@ -5079,7 +5079,7 @@ func (v *InputPaidMediaLivePhoto) MarshalJSON() ([]byte, error) {
// The paid media to send is a photo.
type InputPaidMediaPhoto struct {
// Type of the media, must be photo
Type string `json:"type"`
Type InputPaidMediaType `json:"type"`
// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files »
Media string `json:"media"`
}
@@ -5103,7 +5103,7 @@ func (v *InputPaidMediaPhoto) MarshalJSON() ([]byte, error) {
// The paid media to send is a video.
type InputPaidMediaVideo struct {
// Type of the media, must be video
Type string `json:"type"`
Type InputPaidMediaType `json:"type"`
// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files »
Media string `json:"media"`
// Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »
@@ -5155,7 +5155,7 @@ func (*InputProfilePhotoAnimated) isInputProfilePhoto() {}
// A static profile photo in the .JPG format.
type InputProfilePhotoStatic struct {
// Type of the profile photo, must be static
Type string `json:"type"`
Type InputProfilePhotoType `json:"type"`
// The static profile photo. Profile photos can't be reused and can only be uploaded as a new file, so you can pass “attach://<file_attach_name>” if the photo was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »
Photo string `json:"photo"`
}
@@ -5179,7 +5179,7 @@ func (v *InputProfilePhotoStatic) MarshalJSON() ([]byte, error) {
// An animated profile photo in the MPEG4 format.
type InputProfilePhotoAnimated struct {
// Type of the profile photo, must be animated
Type string `json:"type"`
Type InputProfilePhotoType `json:"type"`
// The animated profile photo. Profile photos can't be reused and can only be uploaded as a new file, so you can pass “attach://<file_attach_name>” if the photo was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »
Animation string `json:"animation"`
// Optional. Timestamp in seconds of the frame that will be used as the static profile photo. Defaults to 0.0.
@@ -5219,7 +5219,7 @@ func (*InputStoryContentVideo) isInputStoryContent() {}
// Describes a photo to post as a story.
type InputStoryContentPhoto struct {
// Type of the content, must be photo
Type string `json:"type"`
Type InputStoryContentType `json:"type"`
// The photo to post as a story. The photo must be of the size 1080x1920 and must not exceed 10 MB. The photo can't be reused and can only be uploaded as a new file, so you can pass “attach://<file_attach_name>” if the photo was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »
Photo string `json:"photo"`
}
@@ -5243,7 +5243,7 @@ func (v *InputStoryContentPhoto) MarshalJSON() ([]byte, error) {
// Describes a video to post as a story.
type InputStoryContentVideo struct {
// Type of the content, must be video
Type string `json:"type"`
Type InputStoryContentType `json:"type"`
// The video to post as a story. The video must be of the size 720x1280, streamable, encoded with H.265 codec, with key frames added each second in the MPEG4 format, and must not exceed 30 MB. The video can't be reused and can only be uploaded as a new file, so you can pass “attach://<file_attach_name>” if the video was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »
Video string `json:"video"`
// Optional. Precise duration of the video in seconds; 0-60
@@ -5460,7 +5460,7 @@ func (*InlineQueryResultVoice) isInlineQueryResult() {}
// Represents a link to an article or web page.
type InlineQueryResultArticle struct {
// Type of the result, must be article
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 Bytes
ID string `json:"id"`
// Title of the result
@@ -5500,7 +5500,7 @@ func (v *InlineQueryResultArticle) MarshalJSON() ([]byte, error) {
// Represents a link to a photo. By default, this photo will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo.
type InlineQueryResultPhoto struct {
// Type of the result, must be photo
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid URL of the photo. Photo must be in JPEG format. Photo size must not exceed 5MB
@@ -5548,7 +5548,7 @@ func (v *InlineQueryResultPhoto) MarshalJSON() ([]byte, error) {
// Represents a link to an animated GIF file. By default, this animated GIF file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.
type InlineQueryResultGif struct {
// Type of the result, must be gif
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid URL for the GIF file
@@ -5598,7 +5598,7 @@ func (v *InlineQueryResultGif) MarshalJSON() ([]byte, error) {
// Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default, this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.
type InlineQueryResultMpeg4Gif struct {
// Type of the result, must be mpeg4_gif
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid URL for the MPEG4 file
@@ -5649,7 +5649,7 @@ func (v *InlineQueryResultMpeg4Gif) MarshalJSON() ([]byte, error) {
// If an InlineQueryResultVideo message contains an embedded video (e.g., YouTube), you must replace its content using input_message_content.
type InlineQueryResultVideo struct {
// Type of the result, must be video
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid URL for the embedded video player or video file
@@ -5701,7 +5701,7 @@ func (v *InlineQueryResultVideo) MarshalJSON() ([]byte, error) {
// Represents a link to an MP3 audio file. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio.
type InlineQueryResultAudio struct {
// Type of the result, must be audio
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid URL for the audio file
@@ -5743,7 +5743,7 @@ func (v *InlineQueryResultAudio) MarshalJSON() ([]byte, error) {
// Represents a link to a voice recording in an .OGG container encoded with OPUS. By default, this voice recording will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the the voice message.
type InlineQueryResultVoice struct {
// Type of the result, must be voice
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid URL for the voice recording
@@ -5783,7 +5783,7 @@ func (v *InlineQueryResultVoice) MarshalJSON() ([]byte, error) {
// Represents a link to a file. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. Currently, only .PDF and .ZIP files can be sent using this method.
type InlineQueryResultDocument struct {
// Type of the result, must be document
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// Title for the result
@@ -5831,7 +5831,7 @@ func (v *InlineQueryResultDocument) MarshalJSON() ([]byte, error) {
// Represents a location on a map. By default, the location will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the location.
type InlineQueryResultLocation struct {
// Type of the result, must be location
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 Bytes
ID string `json:"id"`
// Location latitude in degrees
@@ -5879,7 +5879,7 @@ func (v *InlineQueryResultLocation) MarshalJSON() ([]byte, error) {
// Represents a venue. By default, the venue will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the venue.
type InlineQueryResultVenue struct {
// Type of the result, must be venue
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 Bytes
ID string `json:"id"`
// Latitude of the venue location in degrees
@@ -5929,7 +5929,7 @@ func (v *InlineQueryResultVenue) MarshalJSON() ([]byte, error) {
// Represents a contact with a phone number. By default, this contact will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the contact.
type InlineQueryResultContact struct {
// Type of the result, must be contact
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 Bytes
ID string `json:"id"`
// Contact's phone number
@@ -5971,7 +5971,7 @@ func (v *InlineQueryResultContact) MarshalJSON() ([]byte, error) {
// Represents a Game.
type InlineQueryResultGame struct {
// Type of the result, must be game
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// Short name of the game
@@ -5999,7 +5999,7 @@ func (v *InlineQueryResultGame) MarshalJSON() ([]byte, error) {
// Represents a link to a photo stored on the Telegram servers. By default, this photo will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo.
type InlineQueryResultCachedPhoto struct {
// Type of the result, must be photo
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid file identifier of the photo
@@ -6041,7 +6041,7 @@ func (v *InlineQueryResultCachedPhoto) MarshalJSON() ([]byte, error) {
// Represents a link to an animated GIF file stored on the Telegram servers. By default, this animated GIF file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with specified content instead of the animation.
type InlineQueryResultCachedGif struct {
// Type of the result, must be gif
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid file identifier for the GIF file
@@ -6081,7 +6081,7 @@ func (v *InlineQueryResultCachedGif) MarshalJSON() ([]byte, error) {
// Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers. By default, this animated MPEG-4 file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.
type InlineQueryResultCachedMpeg4Gif struct {
// Type of the result, must be mpeg4_gif
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid file identifier for the MPEG4 file
@@ -6121,7 +6121,7 @@ func (v *InlineQueryResultCachedMpeg4Gif) MarshalJSON() ([]byte, error) {
// Represents a link to a sticker stored on the Telegram servers. By default, this sticker will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the sticker.
type InlineQueryResultCachedSticker struct {
// Type of the result, must be sticker
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid file identifier of the sticker
@@ -6151,7 +6151,7 @@ func (v *InlineQueryResultCachedSticker) MarshalJSON() ([]byte, error) {
// Represents a link to a file stored on the Telegram servers. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file.
type InlineQueryResultCachedDocument struct {
// Type of the result, must be document
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// Title for the result
@@ -6191,7 +6191,7 @@ func (v *InlineQueryResultCachedDocument) MarshalJSON() ([]byte, error) {
// Represents a link to a video file stored on the Telegram servers. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video.
type InlineQueryResultCachedVideo struct {
// Type of the result, must be video
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid file identifier for the video file
@@ -6233,7 +6233,7 @@ func (v *InlineQueryResultCachedVideo) MarshalJSON() ([]byte, error) {
// Represents a link to a voice message stored on the Telegram servers. By default, this voice message will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the voice message.
type InlineQueryResultCachedVoice struct {
// Type of the result, must be voice
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid file identifier for the voice message
@@ -6271,7 +6271,7 @@ func (v *InlineQueryResultCachedVoice) MarshalJSON() ([]byte, error) {
// Represents a link to an MP3 audio file stored on the Telegram servers. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio.
type InlineQueryResultCachedAudio struct {
// Type of the result, must be audio
Type string `json:"type"`
Type InlineQueryResultType `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid file identifier for the audio file
@@ -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
@@ -7172,7 +7172,7 @@ func (*PassportElementErrorUnspecified) isPassportElementError() {}
// Represents an issue in one of the data fields that was provided by the user. The error is considered resolved when the field's value changes.
type PassportElementErrorDataField struct {
// Error source, must be data
Source string `json:"source"`
Source PassportElementErrorSource `json:"source"`
// The section of the user's Telegram Passport which has the error, one of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address”
Type PassportElementErrorDataFieldType `json:"type"`
// Name of the data field which has the error
@@ -7202,7 +7202,7 @@ func (v *PassportElementErrorDataField) MarshalJSON() ([]byte, error) {
// Represents an issue with the front side of a document. The error is considered resolved when the file with the front side of the document changes.
type PassportElementErrorFrontSide struct {
// Error source, must be front_side
Source string `json:"source"`
Source PassportElementErrorSource `json:"source"`
// The section of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”
Type PassportElementErrorSelfieType `json:"type"`
// Base64-encoded hash of the file with the front side of the document
@@ -7230,7 +7230,7 @@ func (v *PassportElementErrorFrontSide) MarshalJSON() ([]byte, error) {
// Represents an issue with the reverse side of a document. The error is considered resolved when the file with reverse side of the document changes.
type PassportElementErrorReverseSide struct {
// Error source, must be reverse_side
Source string `json:"source"`
Source PassportElementErrorSource `json:"source"`
// The section of the user's Telegram Passport which has the issue, one of “driver_license”, “identity_card”
Type PassportElementErrorReverseSideType `json:"type"`
// Base64-encoded hash of the file with the reverse side of the document
@@ -7258,7 +7258,7 @@ func (v *PassportElementErrorReverseSide) MarshalJSON() ([]byte, error) {
// Represents an issue with the selfie with a document. The error is considered resolved when the file with the selfie changes.
type PassportElementErrorSelfie struct {
// Error source, must be selfie
Source string `json:"source"`
Source PassportElementErrorSource `json:"source"`
// The section of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”
Type PassportElementErrorSelfieType `json:"type"`
// Base64-encoded hash of the file with the selfie
@@ -7286,7 +7286,7 @@ func (v *PassportElementErrorSelfie) MarshalJSON() ([]byte, error) {
// Represents an issue with a document scan. The error is considered resolved when the file with the document scan changes.
type PassportElementErrorFile struct {
// Error source, must be file
Source string `json:"source"`
Source PassportElementErrorSource `json:"source"`
// The section of the user's Telegram Passport which has the issue, one of “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”
Type PassportElementErrorFileType `json:"type"`
// Base64-encoded file hash
@@ -7314,7 +7314,7 @@ func (v *PassportElementErrorFile) MarshalJSON() ([]byte, error) {
// Represents an issue with a list of scans. The error is considered resolved when the list of files containing the scans changes.
type PassportElementErrorFiles struct {
// Error source, must be files
Source string `json:"source"`
Source PassportElementErrorSource `json:"source"`
// The section of the user's Telegram Passport which has the issue, one of “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”
Type PassportElementErrorFileType `json:"type"`
// List of base64-encoded file hashes
@@ -7342,7 +7342,7 @@ func (v *PassportElementErrorFiles) MarshalJSON() ([]byte, error) {
// Represents an issue with one of the files that constitute the translation of a document. The error is considered resolved when the file changes.
type PassportElementErrorTranslationFile struct {
// Error source, must be translation_file
Source string `json:"source"`
Source PassportElementErrorSource `json:"source"`
// Type of element of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”
Type PassportElementErrorTranslationFileType `json:"type"`
// Base64-encoded file hash
@@ -7370,7 +7370,7 @@ func (v *PassportElementErrorTranslationFile) MarshalJSON() ([]byte, error) {
// Represents an issue with the translated version of a document. The error is considered resolved when a file with the document translation change.
type PassportElementErrorTranslationFiles struct {
// Error source, must be translation_files
Source string `json:"source"`
Source PassportElementErrorSource `json:"source"`
// Type of element of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”
Type PassportElementErrorTranslationFileType `json:"type"`
// List of base64-encoded file hashes
@@ -7398,7 +7398,7 @@ func (v *PassportElementErrorTranslationFiles) MarshalJSON() ([]byte, error) {
// Represents an issue in an unspecified place. The error is considered resolved when new data is added.
type PassportElementErrorUnspecified struct {
// Error source, must be unspecified
Source string `json:"source"`
Source PassportElementErrorSource `json:"source"`
// Type of element of the user's Telegram Passport which has the issue
Type string `json:"type"`
// Base64-encoded element hash
+182
View File
@@ -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")
}
+57 -3
View File
@@ -46,6 +46,30 @@ var runtimeTypes = map[string]bool{
"MessageOrBool": true,
}
// fieldTypeOverrides maps "<TypeOrParamsName>.<FieldName>" → Go type expression.
// Used for fields whose values are restricted but whose enum the scraper
// can't detect (Telegram's curly-quoted emoji literals are routinely
// stripped by the scraper's regex due to byte-boundary issues with
// multi-byte sequences). The hand-curated typed-string enum lives in
// api/enums.go (manual file); this override just retypes the field so
// callers get IDE completion and compile-time checks. Generated fields
// stay typed even after `make regen`.
var fieldTypeOverrides = map[string]string{
"ReactionTypeEmoji.Emoji": "ReactionEmoji",
"SendDiceParams.Emoji": "DiceEmoji",
}
// fieldTypeOverride returns the override type for a (parent, fieldName)
// pair, or "" if none. parent is the Go type name owning the field —
// either a struct type (e.g. "ReactionTypeEmoji") or a method-params
// type (e.g. "SendDiceParams").
func fieldTypeOverride(parent, fieldName string) string {
if parent == "" {
return ""
}
return fieldTypeOverrides[parent+"."+fieldName]
}
// discriminatorSpec describes how to decode a sealed-interface union by
// peeking at a single JSON field.
type discriminatorSpec struct {
@@ -395,6 +419,9 @@ func funcs(plan *enumPlan) template.FuncMap {
"goField": func(parent string, f spec.Field) string {
return goField(plan, parent, f)
},
"goFieldP": func(methodName string, f spec.Field) string {
return goFieldX(plan, "", title(methodName)+"Params", f)
},
"docComment": docComment,
"isOptional": func(f spec.Field) bool { return !f.Required },
"not": func(b bool) bool { return !b },
@@ -404,6 +431,9 @@ func funcs(plan *enumPlan) template.FuncMap {
"multipartFieldEntry": func(parent string, f spec.Field) string {
return multipartFieldEntry(plan, parent, f)
},
"multipartFieldEntryP": func(methodName string, f spec.Field) string {
return multipartFieldEntryX(plan, "", title(methodName)+"Params", f)
},
"multipartFileEntry": multipartFileEntry,
"returnGoType": returnGoType,
// enum helpers
@@ -503,7 +533,17 @@ func multipartFileEntry(f spec.Field) string {
// when non-zero/non-empty. Typed-string enum fields are cast to string
// before assignment because the multipart map is map[string]string.
func multipartFieldEntry(plan *enumPlan, parent string, f spec.Field) string {
enumName := plan.FieldEnum(parent, f.Name)
return multipartFieldEntryX(plan, parent, parent, f)
}
// multipartFieldEntryX mirrors goFieldX: enumParent keys the enum plan,
// overrideParent keys fieldTypeOverrides. They differ only for method
// params.
func multipartFieldEntryX(plan *enumPlan, enumParent, overrideParent string, f spec.Field) string {
enumName := plan.FieldEnum(enumParent, f.Name)
if enumName == "" {
enumName = fieldTypeOverride(overrideParent, f.Name)
}
switch f.Type.Kind {
case spec.KindPrimitive:
switch f.Type.Name {
@@ -775,10 +815,24 @@ func matchesVariants(got []string, want ...string) bool {
// has a planned enum name for (parent, field), the field's Go type is
// the enum identifier. Typed-string enums use the zero string ""
// behaviour for omitempty, so we do not pointer-wrap optional enum
// fields. Parent is "" for method parameters.
// fields. Parent is "" for method parameters; pass the params type
// name (e.g. "SendDiceParams") via overrideParent when calling from
// the methods template so fieldTypeOverrides can resolve.
func goField(plan *enumPlan, parent string, f spec.Field) string {
return goFieldX(plan, parent, parent, f)
}
// goFieldX is the underlying field-emitter. enumParent is used for the
// enum-plan lookup (which keys method params under ""); overrideParent
// is used for fieldTypeOverrides (which keys method params under the
// params type name). For struct types both are the same; for method
// params they differ.
func goFieldX(plan *enumPlan, enumParent, overrideParent string, f spec.Field) string {
tag := fmt.Sprintf("`json:%q`", f.JSONName+omitempty(f))
if name := plan.FieldEnum(parent, f.Name); name != "" {
if name := plan.FieldEnum(enumParent, f.Name); name != "" {
return fmt.Sprintf("%s %s %s", f.Name, name, tag)
}
if name := fieldTypeOverride(overrideParent, f.Name); name != "" {
return fmt.Sprintf("%s %s %s", f.Name, name, tag)
}
return fmt.Sprintf("%s %s %s", f.Name, goType(f.Type, !f.Required), tag)
+176
View File
@@ -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))
+3 -3
View File
@@ -15,12 +15,12 @@ import (
var _ = strconv.Itoa // keep import for multipart helpers
var _ = json.Marshal // keep import for complex multipart fields
{{range .Methods}}
{{range .Methods}}{{$methodName := .Name}}
// {{title .Name}}Params is the parameter set for {{title .Name}}.
//
{{docComment .Doc -}}
type {{title .Name}}Params struct {
{{range .Params}}{{docComment .Doc}} {{goField "" .}}
{{range .Params}}{{docComment .Doc}} {{goFieldP $methodName .}}
{{end}}}
{{if .HasFiles}}
// HasFile reports whether a multipart upload is required.
@@ -31,7 +31,7 @@ func (p *{{title .Name}}Params) HasFile() bool {
// MultipartFields returns the non-file fields used in the multipart body.
func (p *{{title .Name}}Params) MultipartFields() map[string]string {
out := map[string]string{}
{{range .Params}}{{if not (isFileField .)}}{{multipartFieldEntry "" .}}{{end}}{{end}} return out
{{range .Params}}{{if not (isFileField .)}}{{multipartFieldEntryP $methodName .}}{{end}}{{end}} return out
}
// MultipartFiles returns the file parts.
+87 -1
View File
@@ -27,6 +27,33 @@ import (
// emits the canonical Markdown / MarkdownV2 / HTML triple.
//
// Returns nil when the description does not look like an enum.
// extractEnumValues inspects a field-description string and returns the
// list of wire-level string values when the description matches one of
// the enum-like patterns Telegram uses in its docs. Order follows doc
// order; duplicates are removed but order of first occurrence is kept.
//
// Handled patterns (curly quotes “…” are required to avoid false
// positives on free-text quoting):
//
// - "Type of the chat, can be either “private”, “group”, … or “channel”"
// - "Currently, can be “mention”, “hashtag”, …"
// - "Currently, one of “XTR” … or “TON” …"
// - "Currently, must be one of “XTR” …"
// - "Currently, it can be one of “pending”, “approved”, “declined”."
// - "Must be one of “danger” …, “success” …"
// - "Must be one of “image/jpeg”, “image/gif”, or “video/mp4”"
// - "Format … must be one of “static” …, “animated” …, “video” …"
// - "Currently, either “upgrade” …, “transfer” …, “resale” …"
// - "..., always “creator”"
// - parse_mode parameter special case ("Mode for parsing entities …")
// emits the canonical Markdown / MarkdownV2 / HTML triple.
// - bare prose discriminator at end of description, e.g.
// "Type of the result, must be article" or
// "Scope type, must be all_private_chats". Used by sealed-interface
// union variants whose Type/Source field carries a single literal
// value declared without curly quotes.
//
// Returns nil when the description does not look like an enum.
func extractEnumValues(jsonName, desc string) []string {
if values := parseModeEnumValues(jsonName, desc); values != nil {
return values
@@ -34,12 +61,15 @@ func extractEnumValues(jsonName, desc string) []string {
trigger, triggerEnd, isAlways := findEnumTrigger(desc)
if trigger < 0 {
return nil
return extractProseDiscriminator(desc)
}
tail := desc[trigger:]
values := collectQuotedValues(tail)
if len(values) == 0 {
if v := extractProseDiscriminator(desc); v != nil {
return v
}
return nil
}
// First quoted value must sit close to the trigger phrase (e.g.
@@ -203,3 +233,59 @@ func dedupeStrings(in []string) []string {
}
return out
}
// proseDiscRE matches a terminal "must be <ident>" clause: the
// discriminator value sits at the END of the description (optionally
// followed by trailing punctuation/whitespace) so multi-clause prose
// like "must be shown above the message" is not picked up.
//
// The identifier is a snake_case wire literal: lowercase letters, digits,
// and underscores, starting with a letter. Numeric-only and prose words
// are filtered separately by isProseWord.
var proseDiscRE = regexp.MustCompile(`(?i)\bmust be\s+([a-z][a-z0-9_]*)\s*[.,]?\s*$`)
// extractProseDiscriminator detects unambiguous single-value
// discriminator declarations of the form "..., must be <ident>" used by
// sealed-interface union variants (e.g. "Type of the result, must be
// article" or "Scope type, must be all_private_chats"). Returns the
// extracted value as a one-element slice or nil when no match is found.
//
// The terminal-position anchor is what protects against prose like
// "must be shown above" or "must be one of 3, 6, or 12" — the candidate
// must close the description.
func extractProseDiscriminator(desc string) []string {
desc = strings.TrimSpace(desc)
if desc == "" {
return nil
}
m := proseDiscRE.FindStringSubmatch(desc)
if m == nil {
return nil
}
v := m[1]
if isProseWord(v) {
return nil
}
return []string{v}
}
// isProseWord rejects bare-prose continuations that pass the regex but
// are clearly English filler ("must be sent", "must be available"). The
// list is the closed set of words that empirically appear in the IR's
// "must be …" tails outside the variant-discriminator pattern. Wire
// identifiers are always single tokens with no English meaning, so any
// match here is a free-text false positive.
func isProseWord(s string) bool {
switch s {
case "a", "an", "the",
"sent", "shown", "set", "used", "passed", "specified", "available",
"applied", "supported", "assumed", "active", "paid", "between",
"of", "on", "in", "at", "by", "to", "from", "for", "with",
"and", "or", "no", "non",
"positive", "negative",
"administrator", "repainted",
"one", "exactly":
return true
}
return false
}
+53
View File
@@ -83,3 +83,56 @@ func TestExtractEnumValues_DedupeRepeatedValues(t *testing.T) {
got := extractEnumValues("currency", desc)
require.Equal(t, []string{"XTR"}, got)
}
func TestExtractEnumValues_ProseDiscriminator(t *testing.T) {
cases := []struct {
name string
desc string
want []string
}{
{"InlineQueryResultArticle", "Type of the result, must be article", []string{"article"}},
{"InlineQueryResultPhoto", "Type of the result, must be photo", []string{"photo"}},
{"InlineQueryResultMpeg4Gif", "Type of the result, must be mpeg4_gif", []string{"mpeg4_gif"}},
{"BotCommandScopeAllPrivateChats", "Scope type, must be all_private_chats", []string{"all_private_chats"}},
{"BotCommandScopeChat", "Scope type, must be chat", []string{"chat"}},
{"PassportElementErrorData", "Error source, must be data", []string{"data"}},
{"MenuButtonWebApp", "Type of the button, must be web_app", []string{"web_app"}},
{"InputProfilePhotoAnimated", "Type of the profile photo, must be animated", []string{"animated"}},
{"InputStoryContentVideo", "Type of the content, must be video", []string{"video"}},
{"InputPaidMediaPhoto", "Type of the media, must be photo", []string{"photo"}},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
require.Equal(t, tc.want, extractEnumValues("type", tc.desc))
})
}
}
func TestExtractEnumValues_ProseFalsePositives(t *testing.T) {
cases := []struct {
name string
desc string
}{
{"available_only_for", "Optional. Bot-specified invoice payload. Can be available only for “invoice_payment” transactions."},
{"must_be_sent", "If True, the message must be sent immediately."},
{"must_be_shown_above", "Optional. True, if the link preview must be shown above the message text"},
{"must_be_specified", "The identifiers must be specified in a strictly increasing order."},
{"must_be_paid", "The number of Telegram Stars that must be paid to send the sticker"},
{"must_be_one_of_numbers", "Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12"},
{"must_be_between", "Currently, price in Telegram Stars must be between 5 and 100000"},
{"must_be_a_pay_button", "If not empty, the first button must be a Pay button."},
{"must_be_repainted", "True, if the sticker must be repainted to a text color in messages"},
{"must_be_active", "the subscription must be active up to the end of the current subscription period"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
require.Nil(t, extractEnumValues("type", tc.desc))
})
}
}
func TestExtractEnumValues_CanonicalMustBeOneOfStillWorks(t *testing.T) {
desc := "Currently, must be one of “Markdown”, “MarkdownV2”, “HTML”"
got := extractEnumValues("parse_mode_kind", desc)
require.Equal(t, []string{"Markdown", "MarkdownV2", "HTML"}, got)
}
@@ -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))
+591 -773
View File
File diff suppressed because it is too large Load Diff
+220 -55
View File
@@ -10529,7 +10529,10 @@
"name": "string"
},
"required": true,
"doc": "Scope type, must be default"
"doc": "Scope type, must be default",
"enum_values": [
"default"
]
}
]
},
@@ -10545,7 +10548,10 @@
"name": "string"
},
"required": true,
"doc": "Scope type, must be all_private_chats"
"doc": "Scope type, must be all_private_chats",
"enum_values": [
"all_private_chats"
]
}
]
},
@@ -10561,7 +10567,10 @@
"name": "string"
},
"required": true,
"doc": "Scope type, must be all_group_chats"
"doc": "Scope type, must be all_group_chats",
"enum_values": [
"all_group_chats"
]
}
]
},
@@ -10577,7 +10586,10 @@
"name": "string"
},
"required": true,
"doc": "Scope type, must be all_chat_administrators"
"doc": "Scope type, must be all_chat_administrators",
"enum_values": [
"all_chat_administrators"
]
}
]
},
@@ -10593,7 +10605,10 @@
"name": "string"
},
"required": true,
"doc": "Scope type, must be chat"
"doc": "Scope type, must be chat",
"enum_values": [
"chat"
]
},
{
"name": "ChatID",
@@ -10622,7 +10637,10 @@
"name": "string"
},
"required": true,
"doc": "Scope type, must be chat_administrators"
"doc": "Scope type, must be chat_administrators",
"enum_values": [
"chat_administrators"
]
},
{
"name": "ChatID",
@@ -10651,7 +10669,10 @@
"name": "string"
},
"required": true,
"doc": "Scope type, must be chat_member"
"doc": "Scope type, must be chat_member",
"enum_values": [
"chat_member"
]
},
{
"name": "ChatID",
@@ -10747,7 +10768,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the button, must be commands"
"doc": "Type of the button, must be commands",
"enum_values": [
"commands"
]
}
]
},
@@ -10763,7 +10787,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the button, must be web_app"
"doc": "Type of the button, must be web_app",
"enum_values": [
"web_app"
]
},
{
"name": "Text",
@@ -10799,7 +10826,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the button, must be default"
"doc": "Type of the button, must be default",
"enum_values": [
"default"
]
}
]
},
@@ -11451,7 +11481,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be animation"
"doc": "Type of the result, must be animation",
"enum_values": [
"animation"
]
},
{
"name": "Media",
@@ -11566,7 +11599,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be audio"
"doc": "Type of the result, must be audio",
"enum_values": [
"audio"
]
},
{
"name": "Media",
@@ -11663,7 +11699,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be document"
"doc": "Type of the result, must be document",
"enum_values": [
"document"
]
},
{
"name": "Media",
@@ -11742,7 +11781,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be live_photo"
"doc": "Type of the result, must be live_photo",
"enum_values": [
"live_photo"
]
},
{
"name": "Media",
@@ -11831,7 +11873,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be location"
"doc": "Type of the result, must be location",
"enum_values": [
"location"
]
},
{
"name": "Latitude",
@@ -11876,7 +11921,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be photo"
"doc": "Type of the result, must be photo",
"enum_values": [
"photo"
]
},
{
"name": "Media",
@@ -11955,7 +12003,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be sticker"
"doc": "Type of the result, must be sticker",
"enum_values": [
"sticker"
]
},
{
"name": "Media",
@@ -11990,7 +12041,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be venue"
"doc": "Type of the result, must be venue",
"enum_values": [
"venue"
]
},
{
"name": "Latitude",
@@ -12082,7 +12136,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be video"
"doc": "Type of the result, must be video",
"enum_values": [
"video"
]
},
{
"name": "Media",
@@ -12237,7 +12294,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the media, must be live_photo"
"doc": "Type of the media, must be live_photo",
"enum_values": [
"live_photo"
]
},
{
"name": "Media",
@@ -12273,7 +12333,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the media, must be photo"
"doc": "Type of the media, must be photo",
"enum_values": [
"photo"
]
},
{
"name": "Media",
@@ -12299,7 +12362,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the media, must be video"
"doc": "Type of the media, must be video",
"enum_values": [
"video"
]
},
{
"name": "Media",
@@ -12396,7 +12462,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the profile photo, must be static"
"doc": "Type of the profile photo, must be static",
"enum_values": [
"static"
]
},
{
"name": "Photo",
@@ -12422,7 +12491,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the profile photo, must be animated"
"doc": "Type of the profile photo, must be animated",
"enum_values": [
"animated"
]
},
{
"name": "Animation",
@@ -12465,7 +12537,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the content, must be photo"
"doc": "Type of the content, must be photo",
"enum_values": [
"photo"
]
},
{
"name": "Photo",
@@ -12491,7 +12566,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the content, must be video"
"doc": "Type of the content, must be video",
"enum_values": [
"video"
]
},
{
"name": "Video",
@@ -13008,7 +13086,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be article"
"doc": "Type of the result, must be article",
"enum_values": [
"article"
]
},
{
"name": "ID",
@@ -13108,7 +13189,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be photo"
"doc": "Type of the result, must be photo",
"enum_values": [
"photo"
]
},
{
"name": "ID",
@@ -13252,7 +13336,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be gif"
"doc": "Type of the result, must be gif",
"enum_values": [
"gif"
]
},
{
"name": "ID",
@@ -13410,7 +13497,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be mpeg4_gif"
"doc": "Type of the result, must be mpeg4_gif",
"enum_values": [
"mpeg4_gif"
]
},
{
"name": "ID",
@@ -13568,7 +13658,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be video"
"doc": "Type of the result, must be video",
"enum_values": [
"video"
]
},
{
"name": "ID",
@@ -13732,7 +13825,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be audio"
"doc": "Type of the result, must be audio",
"enum_values": [
"audio"
]
},
{
"name": "ID",
@@ -13849,7 +13945,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be voice"
"doc": "Type of the result, must be voice",
"enum_values": [
"voice"
]
},
{
"name": "ID",
@@ -13957,7 +14056,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be document"
"doc": "Type of the result, must be document",
"enum_values": [
"document"
]
},
{
"name": "ID",
@@ -14106,7 +14208,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be location"
"doc": "Type of the result, must be location",
"enum_values": [
"location"
]
},
{
"name": "ID",
@@ -14243,7 +14348,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be venue"
"doc": "Type of the result, must be venue",
"enum_values": [
"venue"
]
},
{
"name": "ID",
@@ -14390,7 +14498,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be contact"
"doc": "Type of the result, must be contact",
"enum_values": [
"contact"
]
},
{
"name": "ID",
@@ -14499,7 +14610,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be game"
"doc": "Type of the result, must be game",
"enum_values": [
"game"
]
},
{
"name": "ID",
@@ -14544,7 +14658,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be photo"
"doc": "Type of the result, must be photo",
"enum_values": [
"photo"
]
},
{
"name": "ID",
@@ -14660,7 +14777,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be gif"
"doc": "Type of the result, must be gif",
"enum_values": [
"gif"
]
},
{
"name": "ID",
@@ -14767,7 +14887,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be mpeg4_gif"
"doc": "Type of the result, must be mpeg4_gif",
"enum_values": [
"mpeg4_gif"
]
},
{
"name": "ID",
@@ -14874,7 +14997,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be sticker"
"doc": "Type of the result, must be sticker",
"enum_values": [
"sticker"
]
},
{
"name": "ID",
@@ -14928,7 +15054,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be document"
"doc": "Type of the result, must be document",
"enum_values": [
"document"
]
},
{
"name": "ID",
@@ -15036,7 +15165,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be video"
"doc": "Type of the result, must be video",
"enum_values": [
"video"
]
},
{
"name": "ID",
@@ -15153,7 +15285,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be voice"
"doc": "Type of the result, must be voice",
"enum_values": [
"voice"
]
},
{
"name": "ID",
@@ -15252,7 +15387,10 @@
"name": "string"
},
"required": true,
"doc": "Type of the result, must be audio"
"doc": "Type of the result, must be audio",
"enum_values": [
"audio"
]
},
{
"name": "ID",
@@ -17138,7 +17276,10 @@
"name": "string"
},
"required": true,
"doc": "Error source, must be data"
"doc": "Error source, must be data",
"enum_values": [
"data"
]
},
{
"name": "Type",
@@ -17202,7 +17343,10 @@
"name": "string"
},
"required": true,
"doc": "Error source, must be front_side"
"doc": "Error source, must be front_side",
"enum_values": [
"front_side"
]
},
{
"name": "Type",
@@ -17254,7 +17398,10 @@
"name": "string"
},
"required": true,
"doc": "Error source, must be reverse_side"
"doc": "Error source, must be reverse_side",
"enum_values": [
"reverse_side"
]
},
{
"name": "Type",
@@ -17304,7 +17451,10 @@
"name": "string"
},
"required": true,
"doc": "Error source, must be selfie"
"doc": "Error source, must be selfie",
"enum_values": [
"selfie"
]
},
{
"name": "Type",
@@ -17356,7 +17506,10 @@
"name": "string"
},
"required": true,
"doc": "Error source, must be file"
"doc": "Error source, must be file",
"enum_values": [
"file"
]
},
{
"name": "Type",
@@ -17409,7 +17562,10 @@
"name": "string"
},
"required": true,
"doc": "Error source, must be files"
"doc": "Error source, must be files",
"enum_values": [
"files"
]
},
{
"name": "Type",
@@ -17465,7 +17621,10 @@
"name": "string"
},
"required": true,
"doc": "Error source, must be translation_file"
"doc": "Error source, must be translation_file",
"enum_values": [
"translation_file"
]
},
{
"name": "Type",
@@ -17522,7 +17681,10 @@
"name": "string"
},
"required": true,
"doc": "Error source, must be translation_files"
"doc": "Error source, must be translation_files",
"enum_values": [
"translation_files"
]
},
{
"name": "Type",
@@ -17582,7 +17744,10 @@
"name": "string"
},
"required": true,
"doc": "Error source, must be unspecified"
"doc": "Error source, must be unspecified",
"enum_values": [
"unspecified"
]
},
{
"name": "Type",