2020-11-05 10:53:26 +00:00
|
|
|
package dev.inmo.tgbotapi.CommonAbstracts
|
|
|
|
|
|
|
|
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
2020-11-07 07:42:10 +00:00
|
|
|
import dev.inmo.tgbotapi.utils.internal.fullListOfSubSource
|
2020-11-05 10:53:26 +00:00
|
|
|
|
|
|
|
interface Texted {
|
|
|
|
val text: String?
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ParsableOutput : Texted {
|
|
|
|
val parseMode: ParseMode?
|
|
|
|
}
|
|
|
|
|
|
|
|
interface EntitiesOutput : Texted {
|
|
|
|
val entities: List<TextSource>?
|
|
|
|
}
|
|
|
|
|
|
|
|
interface TextedOutput : ParsableOutput, EntitiesOutput
|
|
|
|
|
|
|
|
interface TextedInput : Texted {
|
|
|
|
/**
|
2021-01-06 17:06:48 +00:00
|
|
|
* Here must be full list of entities. This list must contains [TextPart]s with
|
|
|
|
* [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] in case if source text contains parts of
|
|
|
|
* regular text
|
2020-11-05 10:53:26 +00:00
|
|
|
* @see [CaptionedInput.fullEntitiesList]
|
|
|
|
*/
|
|
|
|
val textEntities: List<TextPart>
|
|
|
|
}
|
|
|
|
|
2020-11-06 13:13:59 +00:00
|
|
|
/**
|
2021-01-06 17:06:48 +00:00
|
|
|
* Full list of [TextSource] built from source[TextedInput.textEntities]
|
|
|
|
*
|
2020-11-06 13:13:59 +00:00
|
|
|
* @see TextedInput.textEntities
|
|
|
|
* @see justTextSources
|
|
|
|
*/
|
|
|
|
val TextedInput.textSources
|
|
|
|
get() = textEntities.justTextSources()
|
|
|
|
|
2020-11-05 10:53:26 +00:00
|
|
|
/**
|
|
|
|
* Convert its [TextedInput.textEntities] to list of [dev.inmo.tgbotapi.CommonAbstracts.TextSource]
|
|
|
|
* with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
|
|
|
*/
|
2021-01-09 12:25:11 +00:00
|
|
|
internal fun TextedInput.fullEntitiesList(): TextSourcesList = text ?.fullListOfSubSource(textEntities) ?.map { it.source } ?: emptyList()
|