mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 19:48:43 +00:00
fix of 563
This commit is contained in:
parent
1a6a010446
commit
75fb72936f
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
## 0.38.14
|
## 0.38.14
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* Constructor of `UnknownInlineKeyboardButton` is not internal and can be created with any `json`
|
||||||
|
|
||||||
## 0.38.13
|
## 0.38.13
|
||||||
|
|
||||||
* `Core`:
|
* `Core`:
|
||||||
|
@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons
|
|||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.games.CallbackGame
|
import dev.inmo.tgbotapi.types.games.CallbackGame
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.json.JsonElement
|
import kotlinx.serialization.json.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some button of [dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup]. See inheritors and visit
|
* Some button of [dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup]. See inheritors and visit
|
||||||
@ -15,10 +15,14 @@ sealed interface InlineKeyboardButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class UnknownInlineKeyboardButton internal constructor(
|
data class UnknownInlineKeyboardButton (
|
||||||
override val text: String,
|
|
||||||
val rawData: JsonElement
|
val rawData: JsonElement
|
||||||
) : InlineKeyboardButton
|
) : InlineKeyboardButton {
|
||||||
|
override val text: String
|
||||||
|
get() = runCatching {
|
||||||
|
rawData.jsonObject[textField] ?.jsonPrimitive ?.content
|
||||||
|
}.getOrNull() ?: ""
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This type of button must always be the first button in the first row. Visit
|
* This type of button must always be the first button in the first row. Visit
|
||||||
|
@ -37,7 +37,7 @@ object InlineKeyboardButtonSerializer : KSerializer<InlineKeyboardButton> {
|
|||||||
|
|
||||||
return (json as? JsonObject) ?.let { resolveSerializer(it) } ?.let {
|
return (json as? JsonObject) ?.let { resolveSerializer(it) } ?.let {
|
||||||
nonstrictJsonFormat.decodeFromJsonElement(it, json)
|
nonstrictJsonFormat.decodeFromJsonElement(it, json)
|
||||||
} ?: UnknownInlineKeyboardButton("", json)
|
} ?: UnknownInlineKeyboardButton(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, value: InlineKeyboardButton) {
|
override fun serialize(encoder: Encoder, value: InlineKeyboardButton) {
|
||||||
|
Loading…
Reference in New Issue
Block a user