1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-09-07 09:09:49 +00:00

add tools for work with html captions and texts

This commit is contained in:
2019-03-27 09:43:36 +08:00
parent 609a474874
commit 4679dc118d
4 changed files with 117 additions and 77 deletions

View File

@@ -0,0 +1,23 @@
package com.github.insanusmokrassar.TelegramBotAPI.utils
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.captionLength
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent
import com.github.insanusmokrassar.TelegramBotAPI.types.textLength
fun createHtmlText(
entities: List<MessageEntity>,
partLength: Int = 4096
): List<String> = createFormattedText(entities, partLength, HTMLParseMode)
fun CaptionedMediaContent.toHtmlCaptions(): List<String> = createHtmlText(
fullEntitiesList(),
captionLength.endInclusive + 1
)
fun TextContent.toHtmlTexts(): List<String> = createHtmlText(
fullEntitiesList(),
textLength.endInclusive + 1
)