Skip to content

Implement Bot API 10.2#94

Closed
ForNeVeR wants to merge 2 commits into
Dolfik1:masterfrom
ForNeVeR:feature/92.bot-api-10.2
Closed

Implement Bot API 10.2#94
ForNeVeR wants to merge 2 commits into
Dolfik1:masterfrom
ForNeVeR:feature/92.bot-api-10.2

Conversation

@ForNeVeR

@ForNeVeR ForNeVeR commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Note: this incorporates #93.

Closes #92.

Szer and others added 2 commits July 15, 2026 17:27
DiscriminatedUnionConverter picked union cases by field-shape overlap,
ignoring the discriminator value Telegram actually uses. Shape matching
cannot be correct for ChatMember: ChatMemberLeft and ChatMemberMember are
shape-identical on the wire, and the first shape-superset won, so
{"status":"member"} parsed as Owner, {"status":"left"} as Owner, and
{"status":"kicked"} as Member. Re-serializing a misdiscriminated value
also invented fields that were never on the wire (is_anonymous).

Fix:
- New Funogram.Types.TelegramTagAttribute(field, value) marks a generated
  record as a tag-discriminated union payload (the Bot API documents the
  fixed value as `always "X"` on the field).
- The converter captures top-level string property values while shape-
  reading and selects the case whose tag matches the JSON value; unions
  without tags (and unknown future tag values) fall back to the previous
  shape-based resolution, so behavior is strictly corrected, never
  narrowed.
- The generator parses `always "X"` from required string field
  descriptions and emits the attribute; the checked-in generated Types.fs
  is updated accordingly (91 subtypes across ChatMember, MessageOrigin,
  ReactionType, PaidMedia, ChatBoostSource, BackgroundType/Fill,
  StoryAreaType, OwnedGift, RichText, PageBlock, ...).

Tests: all six ChatMember statuses now parse to the right case (three
failed before), round-trip no longer invents fields, unknown future
statuses still parse (forward compat), and MessageOrigin/ReactionType
keep working.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RrGX1qGPj7jLo1jgotgLKU
@ForNeVeR
ForNeVeR force-pushed the feature/92.bot-api-10.2 branch from 29acf6f to b321741 Compare July 15, 2026 21:33
@Dolfik1

Dolfik1 commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Bot API was updated in #92

@Dolfik1 Dolfik1 closed this Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10.2 API

3 participants