1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-26 03:58:44 +00:00

new PassportMessage type

This commit is contained in:
InsanusMokrassar 2021-01-15 16:27:22 +06:00
parent 5d87b86afe
commit a2ae4f71de
2 changed files with 23 additions and 1 deletions

View File

@ -0,0 +1,14 @@
package dev.inmo.tgbotapi.types.message
import com.soywiz.klock.DateTime
import dev.inmo.tgbotapi.types.MessageIdentifier
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.passport.PassportData
data class PassportMessage(
override val messageId: MessageIdentifier,
override val chat: Chat,
override val date: DateTime,
val passportData: PassportData
) : Message

View File

@ -18,6 +18,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
import dev.inmo.tgbotapi.types.message.content.media.*
import dev.inmo.tgbotapi.types.message.payments.InvoiceContent
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentInfo
import dev.inmo.tgbotapi.types.passport.PassportData
import dev.inmo.tgbotapi.types.payments.Invoice
import dev.inmo.tgbotapi.types.payments.SuccessfulPayment
import dev.inmo.tgbotapi.types.polls.Poll
@ -84,7 +85,7 @@ internal data class RawMessage(
private val connected_website: String? = null,
// passport property
private val passport_data: Unit? = null,
private val passport_data: PassportData? = null,
private val proximity_alert_triggered: ProximityAlertTriggered? = null,
private val reply_markup: InlineKeyboardMarkup? = null
@ -324,6 +325,13 @@ internal data class RawMessage(
)
else -> error("Unknown type of chat: $chat")
}
} ?: passport_data ?.let{
PassportMessage(
messageId,
chat,
date.asDate,
passport_data
)
} ?: error("Was not found supported type of data")
} catch (e: Exception) {
UnknownMessageType(