1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 08:13:47 +00:00

texts and captions utils

This commit is contained in:
InsanusMokrassar 2020-04-24 18:44:04 +06:00
parent 808746e12d
commit fee5d8f925
2 changed files with 31 additions and 12 deletions

View File

@ -24,6 +24,13 @@
* Sealed class `DiceAnimationType` was added
* Field `Dice#animationType` was added as `emoji` API representation
* `SendDice` now receive `animationType` as second parameter
* For `List<TextPart>` and `List<TextSource>` was added several extensions:
* `toMarkdownCaptions`
* `toMarkdownTexts`
* `toMarkdownV2Captions`
* `toMarkdownV2Texts`
* `toHtmlCaptions`
* `toHtmlTexts`
## 0.26.0

View File

@ -53,15 +53,19 @@ fun createMarkdownText(
partLength: Int = 4096
): List<String> = createFormattedText(entities, partLength, MarkdownParseMode)
fun CaptionedInput.toMarkdownCaptions(): List<String> = createMarkdownText(
fullEntitiesList(),
fun List<TextSource>.toMarkdownCaptions(): List<String> = createMarkdownText(
this,
captionLength.last + 1
)
fun List<TextPart>.toMarkdownCaptions(): List<String> = justTextSources().toMarkdownCaptions()
fun CaptionedInput.toMarkdownCaptions(): List<String> = fullEntitiesList().toMarkdownCaptions()
fun TextContent.toMarkdownTexts(): List<String> = createMarkdownText(
fullEntitiesList(),
fun List<TextSource>.toMarkdownTexts(): List<String> = createMarkdownText(
this,
textLength.last + 1
)
fun List<TextPart>.toMarkdownTexts(): List<String> = justTextSources().toMarkdownTexts()
fun TextContent.toMarkdownTexts(): List<String> = fullEntitiesList().toMarkdownTexts()
fun createMarkdownV2Text(
@ -69,15 +73,19 @@ fun createMarkdownV2Text(
partLength: Int = 4096
): List<String> = createFormattedText(entities, partLength, MarkdownV2ParseMode)
fun CaptionedInput.toMarkdownV2Captions(): List<String> = createMarkdownV2Text(
fullEntitiesList(),
fun List<TextSource>.toMarkdownV2Captions(): List<String> = createMarkdownV2Text(
this,
captionLength.last + 1
)
fun List<TextPart>.toMarkdownV2Captions(): List<String> = justTextSources().toMarkdownV2Captions()
fun CaptionedInput.toMarkdownV2Captions(): List<String> = fullEntitiesList().toMarkdownV2Captions()
fun TextContent.toMarkdownV2Texts(): List<String> = createMarkdownV2Text(
fullEntitiesList(),
fun List<TextSource>.toMarkdownV2Texts(): List<String> = createMarkdownV2Text(
this,
textLength.last + 1
)
fun List<TextPart>.toMarkdownV2Texts(): List<String> = justTextSources().toMarkdownV2Texts()
fun TextContent.toMarkdownV2Texts(): List<String> = fullEntitiesList().toMarkdownV2Texts()
fun createHtmlText(
@ -85,14 +93,18 @@ fun createHtmlText(
partLength: Int = 4096
): List<String> = createFormattedText(entities, partLength, HTMLParseMode)
fun CaptionedInput.toHtmlCaptions(): List<String> = createHtmlText(
fullEntitiesList(),
fun List<TextSource>.toHtmlCaptions(): List<String> = createHtmlText(
this,
captionLength.last + 1
)
fun List<TextPart>.toHtmlCaptions(): List<String> = justTextSources().toHtmlCaptions()
fun CaptionedInput.toHtmlCaptions(): List<String> = fullEntitiesList().toHtmlCaptions()
fun TextContent.toHtmlTexts(): List<String> = createHtmlText(
fullEntitiesList(),
fun List<TextSource>.toHtmlTexts(): List<String> = createHtmlText(
this,
textLength.last + 1
)
fun List<TextPart>.toHtmlTexts(): List<String> = justTextSources().toHtmlTexts()
fun TextContent.toHtmlTexts(): List<String> = fullEntitiesList().toHtmlTexts()