2018-12-26 08:07:24 +00:00
|
|
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content
|
|
|
|
|
2019-01-17 02:40:37 +00:00
|
|
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
|
|
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendMessage
|
|
|
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
2018-12-26 08:07:24 +00:00
|
|
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
2019-01-17 02:40:37 +00:00
|
|
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
2019-03-30 12:12:00 +00:00
|
|
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.*
|
2019-01-17 02:40:37 +00:00
|
|
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
|
|
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
2018-12-26 08:07:24 +00:00
|
|
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
2019-03-30 12:12:00 +00:00
|
|
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlTexts
|
2019-01-29 02:22:09 +00:00
|
|
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownTexts
|
2018-12-26 08:07:24 +00:00
|
|
|
|
|
|
|
data class TextContent(
|
|
|
|
val text: String,
|
|
|
|
val entities: List<MessageEntity> = emptyList()
|
2019-01-17 02:40:37 +00:00
|
|
|
) : MessageContent {
|
|
|
|
override fun createResend(
|
|
|
|
chatId: ChatIdentifier,
|
|
|
|
disableNotification: Boolean,
|
|
|
|
replyToMessageId: MessageIdentifier?,
|
|
|
|
replyMarkup: KeyboardMarkup?
|
|
|
|
): Request<RawMessage> = SendMessage(
|
|
|
|
chatId,
|
2019-03-30 12:12:00 +00:00
|
|
|
toHtmlTexts().first(),
|
|
|
|
HTMLParseMode,
|
2019-01-17 02:40:37 +00:00
|
|
|
false,
|
|
|
|
disableNotification,
|
|
|
|
replyToMessageId,
|
|
|
|
replyMarkup
|
|
|
|
)
|
2019-01-29 02:22:09 +00:00
|
|
|
|
|
|
|
override fun createResends(
|
|
|
|
chatId: ChatIdentifier,
|
|
|
|
disableNotification: Boolean,
|
|
|
|
replyToMessageId: MessageIdentifier?,
|
|
|
|
replyMarkup: KeyboardMarkup?
|
2019-03-30 12:12:00 +00:00
|
|
|
): List<Request<RawMessage>> = createResends(
|
|
|
|
chatId,
|
|
|
|
disableNotification,
|
|
|
|
replyToMessageId,
|
|
|
|
replyMarkup,
|
|
|
|
HTMLParseMode
|
|
|
|
)
|
|
|
|
|
|
|
|
fun createResends(
|
|
|
|
chatId: ChatIdentifier,
|
|
|
|
disableNotification: Boolean,
|
|
|
|
replyToMessageId: MessageIdentifier?,
|
|
|
|
replyMarkup: KeyboardMarkup?,
|
|
|
|
parseMode: ParseMode = HTMLParseMode
|
|
|
|
): List<Request<RawMessage>> = when (parseMode) {
|
|
|
|
is MarkdownParseMode -> toMarkdownTexts()
|
|
|
|
is HTMLParseMode -> toHtmlTexts()
|
|
|
|
}.map {
|
2019-01-29 02:22:09 +00:00
|
|
|
SendMessage(
|
|
|
|
chatId,
|
|
|
|
it,
|
2019-03-30 12:12:00 +00:00
|
|
|
parseMode,
|
2019-01-29 02:22:09 +00:00
|
|
|
false,
|
|
|
|
disableNotification,
|
|
|
|
replyToMessageId,
|
|
|
|
replyMarkup
|
|
|
|
)
|
|
|
|
}
|
2019-01-17 02:40:37 +00:00
|
|
|
}
|