diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e2397b5b6..7f51a07e9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` and `List` was added several extensions: + * `toMarkdownCaptions` + * `toMarkdownTexts` + * `toMarkdownV2Captions` + * `toMarkdownV2Texts` + * `toHtmlCaptions` + * `toHtmlTexts` ## 0.26.0 diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/CaptionAndTextSourcesToText.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/CaptionAndTextSourcesToText.kt index 7705a6c832..73b722fc62 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/CaptionAndTextSourcesToText.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/CaptionAndTextSourcesToText.kt @@ -53,15 +53,19 @@ fun createMarkdownText( partLength: Int = 4096 ): List = createFormattedText(entities, partLength, MarkdownParseMode) -fun CaptionedInput.toMarkdownCaptions(): List = createMarkdownText( - fullEntitiesList(), +fun List.toMarkdownCaptions(): List = createMarkdownText( + this, captionLength.last + 1 ) +fun List.toMarkdownCaptions(): List = justTextSources().toMarkdownCaptions() +fun CaptionedInput.toMarkdownCaptions(): List = fullEntitiesList().toMarkdownCaptions() -fun TextContent.toMarkdownTexts(): List = createMarkdownText( - fullEntitiesList(), +fun List.toMarkdownTexts(): List = createMarkdownText( + this, textLength.last + 1 ) +fun List.toMarkdownTexts(): List = justTextSources().toMarkdownTexts() +fun TextContent.toMarkdownTexts(): List = fullEntitiesList().toMarkdownTexts() fun createMarkdownV2Text( @@ -69,15 +73,19 @@ fun createMarkdownV2Text( partLength: Int = 4096 ): List = createFormattedText(entities, partLength, MarkdownV2ParseMode) -fun CaptionedInput.toMarkdownV2Captions(): List = createMarkdownV2Text( - fullEntitiesList(), +fun List.toMarkdownV2Captions(): List = createMarkdownV2Text( + this, captionLength.last + 1 ) +fun List.toMarkdownV2Captions(): List = justTextSources().toMarkdownV2Captions() +fun CaptionedInput.toMarkdownV2Captions(): List = fullEntitiesList().toMarkdownV2Captions() -fun TextContent.toMarkdownV2Texts(): List = createMarkdownV2Text( - fullEntitiesList(), +fun List.toMarkdownV2Texts(): List = createMarkdownV2Text( + this, textLength.last + 1 ) +fun List.toMarkdownV2Texts(): List = justTextSources().toMarkdownV2Texts() +fun TextContent.toMarkdownV2Texts(): List = fullEntitiesList().toMarkdownV2Texts() fun createHtmlText( @@ -85,14 +93,18 @@ fun createHtmlText( partLength: Int = 4096 ): List = createFormattedText(entities, partLength, HTMLParseMode) -fun CaptionedInput.toHtmlCaptions(): List = createHtmlText( - fullEntitiesList(), +fun List.toHtmlCaptions(): List = createHtmlText( + this, captionLength.last + 1 ) +fun List.toHtmlCaptions(): List = justTextSources().toHtmlCaptions() +fun CaptionedInput.toHtmlCaptions(): List = fullEntitiesList().toHtmlCaptions() -fun TextContent.toHtmlTexts(): List = createHtmlText( - fullEntitiesList(), +fun List.toHtmlTexts(): List = createHtmlText( + this, textLength.last + 1 ) +fun List.toHtmlTexts(): List = justTextSources().toHtmlTexts() +fun TextContent.toHtmlTexts(): List = fullEntitiesList().toHtmlTexts()