TextEntity

data class TextEntity(val type: TextEntityType, val offset: Int, val length: Int, val url: String? = null, val language: String? = null)

A MessageText flattened the way the Bot API wants it: plain text plus ranges over it.

Here rather than in a transport because the arithmetic is the risky part and it is the same arithmetic for everyone. :telegram sends these almost verbatim; :ktg does not need them, because ktgbotapi flattens its own TextSource list — but the offsets can be tested in :core, on the JVM and on native, without either client library present.

Offsets are in UTF-16 code units, which is what Telegram counts and what Kotlin's String already indexes in. An emoji outside the BMP is two units, and a length taken in characters would put every entity after it in the wrong place — a bug that only shows up in messages that contain one.

Constructors

Link copied to clipboard
constructor(type: TextEntityType, offset: Int, length: Int, url: String? = null, language: String? = null)

Properties

Link copied to clipboard

Set for TextEntityType.Pre when the block named a language.

Link copied to clipboard
val length: Int
Link copied to clipboard
val offset: Int
Link copied to clipboard
Link copied to clipboard
val url: String?

Set for TextEntityType.TextLink and nothing else.