From dd0a8b99c7a0bc4a8db260064abe71e7290871a3 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 17 Apr 2022 18:36:40 +0600 Subject: [PATCH] add WebAppData --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 2 ++ .../types/message/ChatEvents/WebAppData.kt | 15 +++++++++++++++ .../dev/inmo/tgbotapi/types/message/RawMessage.kt | 4 ++++ 3 files changed, 21 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/WebAppData.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 0f432f60a8..629d374372 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -430,3 +430,5 @@ const val bankStatementField = "bank_statement" const val rentalAgreementField = "rental_agreement" const val passportRegistrationField = "passport_registration" const val temporaryRegistrationField = "temporary_registration" + +const val buttonTextField = "button_text" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/WebAppData.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/WebAppData.kt new file mode 100644 index 0000000000..6f1d00b4a4 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/WebAppData.kt @@ -0,0 +1,15 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents + +import dev.inmo.tgbotapi.types.buttonTextField +import dev.inmo.tgbotapi.types.dataField +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PrivateEvent +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +class WebAppData( + @SerialName(dataField) + val data: String, + @SerialName(buttonTextField) + val buttonText: String +) : PrivateEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt index 4022e0ddae..ec45e22643 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt @@ -95,6 +95,9 @@ internal data class RawMessage( // login property private val connected_website: String? = null, + // login property + private val web_app_data: WebAppData? = null, + // passport property private val passport_data: PassportData? = null, private val proximity_alert_triggered: ProximityAlertTriggered? = null, @@ -203,6 +206,7 @@ internal data class RawMessage( proximity_alert_triggered != null -> proximity_alert_triggered successful_payment != null -> SuccessfulPaymentEvent(successful_payment) connected_website != null -> UserLoggedIn(connected_website) + web_app_data != null -> web_app_data else -> null } }