1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-06-03 00:15:27 +00:00
tgbotapi/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt

45 lines
1.7 KiB
Kotlin
Raw Normal View History

2020-10-04 11:06:30 +00:00
package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent
import dev.inmo.tgbotapi.CommonAbstracts.*
2020-10-04 11:06:30 +00:00
import dev.inmo.tgbotapi.CommonAbstracts.types.DisableWebPagePreview
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
2020-10-04 11:06:30 +00:00
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* Represents the [InputMessageContent] of a text message to be sent as the result of an inline query.
*/
fun InputTextMessageContent(
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null
) = InputTextMessageContent(text, parseMode, null, disableWebPagePreview)
/**
* Represents the [InputMessageContent] of a text message to be sent as the result of an inline query.
*/
fun InputTextMessageContent(
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
disableWebPagePreview: Boolean? = null
) = InputTextMessageContent(entities.makeString(), null, entities.toRawMessageEntities(), disableWebPagePreview)
2020-10-04 11:06:30 +00:00
@Serializable
data class InputTextMessageContent internal constructor(
2020-10-04 11:06:30 +00:00
@SerialName(messageTextField)
override val text: String,
2020-10-04 11:06:30 +00:00
@SerialName(parseModeField)
override val parseMode: ParseMode? = null,
@SerialName(entitiesField)
private val rawEntities: List<RawMessageEntity>? = null,
2020-10-04 11:06:30 +00:00
@SerialName(disableWebPagePreviewField)
override val disableWebPagePreview: Boolean? = null
2021-01-09 12:25:11 +00:00
) : TextedOutput, DisableWebPagePreview, InputMessageContent {
2021-04-29 05:52:38 +00:00
override val textSources: List<TextSource>? by lazy {
2021-04-28 13:54:57 +00:00
rawEntities ?.asTextSources(text)
}
}