mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
commit
12846a68b9
@ -1,5 +1,10 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 9.1.1
|
||||
|
||||
* `Core`:
|
||||
* Potential fix of incorrect parsing in `RawMessageEntity`
|
||||
|
||||
## 9.1.0
|
||||
|
||||
**This update contains adding of [Telegram Bot API 6.8](https://core.telegram.org/bots/api-changelog#august-18-2023) support**
|
||||
|
@ -6,4 +6,4 @@ kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=9.1.0
|
||||
library_version=9.1.1
|
||||
|
@ -18,6 +18,30 @@ internal data class RawMessageEntity(
|
||||
internal val range by lazy {
|
||||
offset until (offset + length)
|
||||
}
|
||||
|
||||
val priority by lazy {
|
||||
when (type) {
|
||||
// Types with potential subsources should have priority
|
||||
"mention" -> 0
|
||||
"hashtag" -> 0
|
||||
"cashtag" -> 0
|
||||
"email" -> 0
|
||||
"phone_number" -> 0
|
||||
"bold" -> 0
|
||||
"italic" -> 0
|
||||
"text_mention" -> 0
|
||||
"strikethrough" -> 0
|
||||
"underline" -> 0
|
||||
"spoiler" -> 0
|
||||
"custom_emoji" -> 0
|
||||
"bot_command" -> 1
|
||||
"url" -> 1
|
||||
"code" -> 1
|
||||
"pre" -> 1
|
||||
"text_link" -> 1
|
||||
else -> 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun RawMessageEntity.asTextSource(
|
||||
@ -85,7 +109,10 @@ private fun createTextSources(
|
||||
originalFullString: String,
|
||||
entities: RawMessageEntities
|
||||
): List<Pair<Int, TextSource>> {
|
||||
val mutableEntities = entities.toMutableList().apply { sortBy { it.offset } }
|
||||
val mutableEntities = entities.toMutableList().apply {
|
||||
sortBy { it.priority } // sorting to fix potential issues in source sorting of entities
|
||||
sortBy { it.offset }
|
||||
}
|
||||
val resultList = mutableListOf<Pair<Int, TextSource>>()
|
||||
|
||||
while (mutableEntities.isNotEmpty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user