1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-06-26 03:28:10 +00:00
tgbotapi/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/HashTagTextSource.kt

27 lines
913 B
Kotlin
Raw Normal View History

package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources
2020-01-05 13:51:32 +00:00
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.MultilevelTextSource
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextPart
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
private val String.withoutSharp
get() = if (startsWith("#")){
substring(1)
} else {
this
}
class HashTagTextSource(
source: String,
textParts: List<TextPart>
) : MultilevelTextSource {
2020-01-05 14:07:51 +00:00
override val textParts: List<TextPart> by lazy {
source.withoutSharp.fullListOfSubSource(
textParts.shiftSourcesToTheLeft(1)
)
}
override val asMarkdownSource: String by lazy { source.hashTagMarkdown() }
override val asMarkdownV2Source: String by lazy { hashTagMarkdownV2() }
override val asHtmlSource: String by lazy { hashTagHTML() }
}