From e2416b405a19b80f7c545fb7ddf506af3ff5cefe Mon Sep 17 00:00:00 2001 From: Kirill Romanov Date: Sun, 12 Apr 2020 22:30:04 +0300 Subject: [PATCH] add support for inline keyboard buttons with callback_game field --- .../insanusmokrassar/TelegramBotAPI/types/Common.kt | 1 + .../InlineKeyboardButtons/InlineKeyboardButton.kt | 9 +++++++++ .../InlineKeyboardButtonSerializer.kt | 1 + 3 files changed, 11 insertions(+) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Common.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Common.kt index d0142f6a8b..3061fec7b9 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Common.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Common.kt @@ -82,6 +82,7 @@ const val containsMasksField = "contains_masks" const val resultIdField = "result_id" const val inlineMessageIdField = "inline_message_id" const val callbackDataField = "callback_data" +const val callbackGameField = "callback_game" const val callbackQueryIdField = "callback_query_id" const val inlineQueryIdField = "inline_query_id" const val inlineKeyboardField = "inline_keyboard" diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt index 0c2da03af1..11c7ca255b 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.games.CallbackGame import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -24,6 +25,14 @@ data class CallbackDataInlineKeyboardButton( val callbackData: String ) : InlineKeyboardButton() +@Serializable +data class CallbackGameInlineKeyboardButton( + @SerialName(textField) + override val text: String, + @SerialName(callbackGameField) + val callbackGame: CallbackGame +) : InlineKeyboardButton() + @Serializable data class LoginURLInlineKeyboardButton( override val text: String, diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardButtons/InlineKeyboardButtonSerializer.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardButtons/InlineKeyboardButtonSerializer.kt index 463b6608cb..05a604fea6 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardButtons/InlineKeyboardButtonSerializer.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/buttons/InlineKeyboardButtons/InlineKeyboardButtonSerializer.kt @@ -15,6 +15,7 @@ internal object InlineKeyboardButtonSerializer : KSerializer { return when { json[callbackDataField] != null -> CallbackDataInlineKeyboardButton.serializer() + json[callbackGameField] != null -> CallbackGameInlineKeyboardButton.serializer() json[loginUrlField] != null -> LoginURLInlineKeyboardButton.serializer() json[payField] != null -> PayInlineKeyboardButton.serializer() json[switchInlineQueryField] != null -> SwitchInlineQueryInlineKeyboardButton.serializer()