mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-06-03 00:15:27 +00:00
31 lines
760 B
Kotlin
31 lines
760 B
Kotlin
package dev.inmo.tgbotapi.utils.extensions
|
|
|
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
|
import dev.inmo.tgbotapi.types.message.*
|
|
|
|
inline fun TextSourcesList.makeString(
|
|
parseMode: ParseMode? = null
|
|
) = when (parseMode) {
|
|
MarkdownParseMode -> makeMarkdownString()
|
|
MarkdownV2ParseMode -> makeMarkdownV2String()
|
|
HTMLParseMode -> makeHtmlString()
|
|
null -> makeSourceString()
|
|
}
|
|
|
|
|
|
inline fun TextSourcesList.makeSourceString() = joinToString("") {
|
|
it.source
|
|
}
|
|
|
|
inline fun TextSourcesList.makeHtmlString() = joinToString("") {
|
|
it.html
|
|
}
|
|
|
|
inline fun TextSourcesList.makeMarkdownV2String() = joinToString("") {
|
|
it.markdownV2
|
|
}
|
|
|
|
inline fun TextSourcesList.makeMarkdownString() = joinToString("") {
|
|
it.markdown
|
|
}
|