2020-10-04 11:06:30 +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-10-04 11:06:30 +00:00
|
|
|
|
|
|
|
interface Captioned {
|
|
|
|
val caption: String?
|
|
|
|
}
|
|
|
|
|
|
|
|
interface CaptionedOutput : Captioned {
|
|
|
|
val parseMode: ParseMode?
|
|
|
|
}
|
|
|
|
|
|
|
|
interface CaptionedInput : Captioned {
|
|
|
|
/**
|
|
|
|
* Not full list of entities. This list WILL NOT contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
|
|
|
* @see [CaptionedInput.fullEntitiesList]
|
|
|
|
*/
|
|
|
|
val captionEntities: List<TextPart>
|
|
|
|
}
|
|
|
|
|
2020-11-06 13:13:59 +00:00
|
|
|
/**
|
|
|
|
* @see CaptionedInput.captionEntities
|
|
|
|
* @see justTextSources
|
|
|
|
*/
|
|
|
|
val CaptionedInput.textSources
|
|
|
|
get() = captionEntities.justTextSources()
|
|
|
|
|
2020-10-04 11:06:30 +00:00
|
|
|
/**
|
|
|
|
* Convert its [CaptionedInput.captionEntities] 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 CaptionedInput.fullEntitiesList(): TextSourcesList = caption ?.fullListOfSubSource(captionEntities) ?.map { it.source } ?: emptyList()
|