Td Api Text Entity - OTR/Kotlin-Telegram-Client GitHub Wiki

Class TdApi.TextEntity

Description

Represents a part of the text that needs to be formatted in some unusual way. Entities are contained in the text. Entities can be nested, but must not mutually intersect with each other. Pre, Code and PreCode entities can't contain other entities. Bold, Italic, Underline and Strikethrough entities can contain and to be contained in all other entities. All other entities can't contain each other.

Properties

  • length : Int - Length of the entity, in UTF-16 code units.
  • offset : Int - Offset of the entity in UTF-16 code units.
  • type : TdApi.TextEntityType - Type of the entity.

Example

/**
 * Entities contained in the text.
 * Entities can be nested, but must not mutually intersect with each other.
 * Pre, Code and PreCode entities can't contain other entities.
 * Bold, Italic, Underline and Strikethrough entities can contain
 * and to be contained in all other entities.
 * All other entities can't contain each other.
 */
fun someFunThatGetsFormattedText(formattedText: TdApi.FormattedText) {
    val entities: Array<TdApi.TextEntity> = formattedText.entities

    for (entity in entities) {
        // Length of the entity, in UTF-16 code units.
        val entityLength: Int = entity.length
        // Offset of the entity in UTF-16 code units.
        val entityOffset: Int = entity.offset
        // Type of the entity.
        val entityType: TdApi.TextEntityType = entity.type
    }
}

Reference

Generated docs for TdApi.TextEntity

Generated docs for TdApi.TextEntityType