Replace the RichText.source extension property (a when over every subtype)
with a rawText member declared on RichText and implemented directly by each
inheritor: RichTextPlain.rawText = text, the wrapping entities delegate to
text.rawText, and custom emoji / mathematical expression / anchor fall back
to their own representation. Update the RichBlockPreformatted and media
markdown builders and the formatting tests accordingly.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
For every RichText and RichBlock type the markdown and html rendering now
lives in companion-object functions taking the relevant fields, and the
property overrides are plain value initializers that reuse those functions
(e.g. RichTextEmailAddress.markdown(text, emailAddress)). Class-specific
render helpers (list, table, map, block quotation, details open attribute)
move into the matching companions; helpers shared across several types
(credit cite, media and media container rendering) stay internal top-level
functions.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add markdown and html as members of the RichText and RichBlock sealed
interfaces and override them in every inheritor (RichTextPlain,
RichTextGroup and all 21 RichBlock subtypes), mirroring the existing
RichTextEntity implementation. The former RichText/RichBlock.markdown
and .html extension properties (which dispatched via a when over each
subtype) are removed; the shared RichBlock render helpers become
internal so the overrides can reuse them.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a type-safe Kotlin DSL for building rich messages:
* buildRichText { } - RichTextBuilder with plain() plus a function for every
RichTextEntity (String and nested RichTextBuilder overloads where text-bearing);
* buildRichBlocks { } / buildRichTextInfo { } - RichBlocksBuilder with the
text-bearing and container blocks (paragraph, heading, list, blockQuotation,
details, ...), nesting RichText or further blocks per block kind;
* RichBlockListBuilder for list items.
Container blocks expose nested block/text builders; file/cell-heavy blocks (media,
table, collage, slideshow, map) are appended via add() / unary plus. A
@DslMarker (RichTextDsl) keeps the nested scopes from leaking receivers.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add List<RichBlock>.toRichMarkdown() / toRichHtml() (and per-block RichBlock
.markdown / .html plus RichTextInfo.markdown / .html convenience) that render the
Rich Markdown style and Rich HTML style source strings for a whole rich message,
ready to feed into InputRichMessageMarkdown / InputRichMessageHTML.
All 21 block types are covered, including lists (bullet/ordered/task), tables,
block/pull quotations, details, collages, slideshows, maps and media. Media
blocks use the Telegram file_id as the source (documented), since Telegram only
accepts HTTP(S) URLs for rich media and the parsed model carries no public URL.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add Rich Markdown style and Rich HTML style serialization for every
RichTextEntity subtype, following the Bot API rich formatting spec
(https://core.telegram.org/bots/api#rich-markdown-style and #rich-html-style).
New RichTextFormatting.kt provides:
* String.escapeRichMarkdown() escaping the rich-markdown special characters;
* RichText.source - plain unformatted text of any RichText;
* RichText.markdown / RichText.html - recursive dispatch over RichTextPlain,
RichTextGroup and RichTextEntity so inner texts render correctly.
Each of the 25 entity types now overrides markdown and html. Auto-detected
entities (mention, hashtag, cashtag, bank card, bot command) emit their visible
text; the rest wrap inner text in the corresponding markers/tags.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The Telegram type backing rich-formatted message info is RichMessage, but the
class name collided conceptually with the in-progress rich-message builders.
Rename the data class (and its file) to RichTextInfo and update all references
(RawMessage, RichMessageContent, serialization test) plus the API dump.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Approve/Decline/Queue are now data object
- each inheritor (and Unknown) annotated with the shared
ChatJoinRequestQueryResult.Companion serializer
- companion PrimitiveSerialDescriptor serial name is "ChatJoinRequestQueryResult"
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- ChatJoinRequestQueryResult: enum -> sealed interface (Approve/Decline/
Queue objects + Unknown) with a companion KSerializer using a
PrimitiveKind.STRING descriptor (encodeString/decodeString), not
String.serializer()
- EditChatMessageText: text is now nullable per API; add EditChatMessageRichText
factory for rich edits; widen EditTextChatMessage.text to String?
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds the full Rich Messages type system and methods:
- RichText hierarchy: RichTextPlain, RichTextGroup, RichTextEntity and all
24 RichText* entity types, with a recursive serializer handling plain
strings, arrays and typed objects
- RichBlock hierarchy: all 21 RichBlock* types plus RichBlockCaption,
RichBlockTableCell and RichBlockListItem (JsonContentPolymorphic by type)
- RichMessage type and RichMessageContent message content; rich_message
parsed in RawMessage; RichMessageContentMessage typealias
- InputRichMessage (internal constructor + InputRichMessageHTML /
InputRichMessageMarkdown factories) and InputRichMessageContent usable as
InputMessageContent
- SendRichMessage and SendRichMessageDraft requests with API bindings
- richMessage parameter on EditChatMessageText
- Serialization round-trip test for RichMessage/RichText/RichBlock
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds:
- ChatJoinRequestQueryId value class and ChatJoinRequest.queryId field
- ExtendedBot.supportsJoinRequestQueries (User.supports_join_request_queries)
- ExtendedChat.guardBot (ChatFullInfo.guard_bot), parsed for public chats
- AnswerChatJoinRequestQuery request + ChatJoinRequestQueryResult enum
- SendChatJoinRequestWebApp request
- answerChatJoinRequestQuery / sendChatJoinRequestWebApp TelegramBot extensions
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds the Link type implementing PollMedia (the url attached to a poll
option), parses the new `link` field in PollMedia, and adds
TelegramMediaLink (InputMediaLink) usable as InputPollOptionMedia.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>