From 407f2a8bf78c57a65a0353b11991ecd921eb66d1 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 17 Feb 2026 12:09:23 +0600 Subject: [PATCH] fix serialization of simple keyboard button --- .../dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt index f23e77c9b9..7278f66c4a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt @@ -263,7 +263,11 @@ object KeyboardButtonSerializer : KSerializer { is RequestLocationKeyboardButton -> RequestLocationKeyboardButton.serializer().serialize(encoder, value) is WebAppKeyboardButton -> WebAppKeyboardButton.serializer().serialize(encoder, value) is RequestPollKeyboardButton -> RequestPollKeyboardButton.serializer().serialize(encoder, value) - is SimpleKeyboardButton -> SimpleKeyboardButton.serializer().serialize(encoder, value) + is SimpleKeyboardButton -> if (value.iconCustomEmojiId != null || value.style != null) { + SimpleKeyboardButton.serializer().serialize(encoder, value) + } else { + encoder.encodeString(value.text) + } is RequestUserKeyboardButton -> RequestUserKeyboardButton.serializer().serialize(encoder, value) is RequestChatKeyboardButton -> RequestChatKeyboardButton.serializer().serialize(encoder, value) is UnknownKeyboardButton -> JsonElement.serializer().serialize(encoder, nonstrictJsonFormat.parseToJsonElement(value.raw))