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

48 lines
1.9 KiB
Kotlin
Raw Normal View History

2020-10-04 11:06:30 +00:00
package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent
2021-05-29 09:34:14 +00:00
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
2020-10-04 11:06:30 +00:00
import dev.inmo.tgbotapi.CommonAbstracts.types.DisableWebPagePreview
import dev.inmo.tgbotapi.types.*
2022-05-01 14:36:07 +00:00
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
2020-10-04 11:06:30 +00:00
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
2022-05-01 14:36:07 +00:00
import dev.inmo.tgbotapi.types.message.*
import dev.inmo.tgbotapi.types.message.RawMessageEntity
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
2021-08-08 12:00:42 +00:00
import dev.inmo.tgbotapi.utils.extensions.makeString
2020-10-04 11:06:30 +00:00
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(
2021-05-29 09:34:14 +00:00
entities: TextSourcesList,
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-05-29 09:34:14 +00:00
override val textSources: TextSourcesList? by lazy {
2021-04-28 13:54:57 +00:00
rawEntities ?.asTextSources(text)
}
}