From eb923a633802273b7317b79ae48702fec88a2135 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 28 Apr 2021 23:22:13 +0600 Subject: [PATCH] fixes --- .../inmo/tgbotapi/types/MessageEntity/RawMessageEntity.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/RawMessageEntity.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/RawMessageEntity.kt index 67e388ca72..4234bdd191 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/RawMessageEntity.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/RawMessageEntity.kt @@ -162,9 +162,9 @@ internal fun TextSource.toRawMessageEntities(offset: Int = 0): List.toRawMessageEntities(preOffset: Int = 0): List { var i = preOffset - return flatMap { - it.toRawMessageEntities(i).also { - i += it.maxByOrNull { it.length }!!.length + 1 + return flatMap { textSource -> + textSource.toRawMessageEntities(i).also { + i += it.maxByOrNull { it.length } ?.length ?: textSource.source.length } } }