46 lines
1.9 KiB
Kotlin
46 lines
1.9 KiB
Kotlin
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
|
|
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.DisableWebPagePreview
|
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
|
import kotlinx.serialization.*
|
|
|
|
@Serializable
|
|
data class SendMessage(
|
|
@SerialName(chatIdField)
|
|
override val chatId: ChatIdentifier,
|
|
@SerialName(textField)
|
|
override val text: String,
|
|
@SerialName(parseModeField)
|
|
override val parseMode: ParseMode? = null,
|
|
@SerialName(disableWebPagePreviewField)
|
|
override val disableWebPagePreview: Boolean? = null,
|
|
@SerialName(disableNotificationField)
|
|
override val disableNotification: Boolean = false,
|
|
@SerialName(replyToMessageIdField)
|
|
override val replyToMessageId: MessageIdentifier? = null,
|
|
@SerialName(replyMarkupField)
|
|
override val replyMarkup: KeyboardMarkup? = null
|
|
) : SendMessageRequest<Message>,
|
|
ReplyingMarkupSendMessageRequest<Message>,
|
|
TextableSendMessageRequest<Message>,
|
|
DisableWebPagePreview
|
|
{
|
|
init {
|
|
if (text.length !in textLength) {
|
|
throw IllegalArgumentException("Text must be in $textLength range")
|
|
}
|
|
}
|
|
|
|
override fun method(): String = "sendMessage"
|
|
override val resultDeserializer: DeserializationStrategy<Message>
|
|
get() = TelegramBotAPIMessageDeserializationStrategy
|
|
override val requestSerializer: SerializationStrategy<*>
|
|
get() = serializer()
|
|
}
|