From 41db785696f5d816ed5b4c78fb0f12070345825c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 23 Jan 2020 17:07:28 +0600 Subject: [PATCH] "language" field im RawMessageEntity --- CHANGELOG.md | 1 + .../TelegramBotAPI/types/MessageEntity/RawMessageEntity.kt | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44772d7c52..cc56d45bbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * `SendPoll` was rewritten as sealed class * `SendRegularPoll` was created and represent `sendPoll` method with type `regular` * `SendQuizPoll` was created and represent `sendPoll` method with type `quiz` +* `language` field in PreTextSource now correctly passed from telegram MessageEntities ## 0.22.0 diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/RawMessageEntity.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/RawMessageEntity.kt index bf161e2192..c7023471e4 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/RawMessageEntity.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/RawMessageEntity.kt @@ -13,7 +13,8 @@ internal data class RawMessageEntity( val offset: Int, val length: Int, val url: String? = null, - val user: User? = null + val user: User? = null, + val language: String? = null ) internal fun RawMessageEntity.asTextParts(source: String, subParts: List): List { @@ -31,7 +32,7 @@ internal fun RawMessageEntity.asTextParts(source: String, subParts: List BoldTextSource(sourceSubstring, shiftedSubParts) "italic" -> ItalicTextSource(sourceSubstring, shiftedSubParts) "code" -> CodeTextSource(sourceSubstring) - "pre" -> PreTextSource(sourceSubstring) + "pre" -> PreTextSource(sourceSubstring, language) "text_link" -> TextLinkTextSource(sourceSubstring, url ?: throw IllegalStateException("URL must not be null for text link")) "text_mention" -> TextMentionTextSource(sourceSubstring, user ?: throw IllegalStateException("User must not be null for text mention"), shiftedSubParts) "underline" -> UnderlineTextSource(sourceSubstring, shiftedSubParts)