MessageText

data class MessageText(val pieces: List<TextPiece>)

A message body as a document, not as a string a server parses.

The distinction is the whole point. Telegram accepts either a string plus a parse_mode — where markup is characters inside the text — or plain text plus entities, which are offsets pointing at ranges of it. With the first, any foreign text the bot did not write (a name somebody typed, a product title) can open markup that never closes, and Telegram rejects the whole message; from the outside that is a button that does nothing. Escaping is the only defence, it belongs at every call site, and it is silently wrong the day the parse mode changes.

With a document there is nothing to escape, because nothing in the text is parsed. The defect class is gone by construction rather than by vigilance, and every format Telegram has becomes expressible at once instead of the six that legacy Markdown allows.

This type is in :core for the same reason Input is: it describes Telegram's own model, not a client library's. Each transport maps it to whatever its library takes — :ktg to ktgbotapi's TextSource, :telegram to (text, entities) — and neither mapping is visible here.

Build one with message; read it back with plain.

Constructors

Link copied to clipboard
constructor(pieces: List<TextPiece>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

The text without any markup — exactly what Telegram is sent alongside the entities, and what a person sees if their client renders nothing.

Functions

Link copied to clipboard

The entities for this message, in the order their ranges open.