From 8df8b87d54e1d36c602b01edc7a7fd7a1b9d02e1 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 30 Dec 2022 19:38:26 +0600 Subject: [PATCH] add ReplyKeyboardMarkup --- .../commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup.kt | 4 +++- .../utils/types/buttons/ReplyKeyboardBuilder.kt | 9 ++++++--- .../utils/types/buttons/ReplyKeyboardMarkup.kt | 6 ++++-- 4 files changed, 14 insertions(+), 6 deletions(-) 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 a9ff556602..5a6d2f3398 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 @@ -461,6 +461,7 @@ const val shouldSendEmailToProviderField = "send_email_to_provider" const val resizeKeyboardField = "resize_keyboard" const val oneTimeKeyboardField = "one_time_keyboard" const val inputFieldPlaceholderField = "input_field_placeholder" +const val isPersistentField = "is_persistent" const val priceDependOnShipAddressField = "is_flexible" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup.kt index 753b947389..8ffecc9d3f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup.kt @@ -13,7 +13,9 @@ data class ReplyKeyboardMarkup( val oneTimeKeyboard: Boolean? = null, @SerialName(inputFieldPlaceholderField) val inputFieldPlaceholder: String? = null, - val selective: Boolean? = null + val selective: Boolean? = null, + @SerialName(isPersistentField) + val persistent: Boolean? = null ) : KeyboardMarkup { init { if (inputFieldPlaceholder != null && inputFieldPlaceholder.length !in inputFieldPlaceholderLimit) { diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt index 2d913a1445..9bd0909aa1 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt @@ -22,7 +22,8 @@ fun ReplyKeyboardBuilder.build( oneTimeKeyboard: Boolean? = null, inputFieldPlaceholder: String? = null, selective: Boolean? = null, -) = ReplyKeyboardMarkup(matrix, resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) + persistent: Boolean? = null, +) = ReplyKeyboardMarkup(matrix, resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective, persistent) /** * Row builder of [KeyboardButton] @@ -43,8 +44,9 @@ inline fun replyKeyboard( oneTimeKeyboard: Boolean? = null, inputFieldPlaceholder: String? = null, selective: Boolean? = null, + persistent: Boolean? = null, block: ReplyKeyboardBuilder.() -> Unit -) = ReplyKeyboardBuilder().apply(block).build(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) +) = ReplyKeyboardBuilder().apply(block).build(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective, persistent) /** * Factory-function for [ReplyKeyboardBuilder], but in difference with [replyKeyboard] this method will create single-row @@ -55,8 +57,9 @@ inline fun flatReplyKeyboard( oneTimeKeyboard: Boolean? = null, inputFieldPlaceholder: String? = null, selective: Boolean? = null, + persistent: Boolean? = null, block: ReplyKeyboardRowBuilder.() -> Unit -) = replyKeyboard(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) { +) = replyKeyboard(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective, persistent) { row(block) } diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardMarkup.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardMarkup.kt index 2b8bc76fc6..f6f45fdfd1 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardMarkup.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardMarkup.kt @@ -9,11 +9,13 @@ fun ReplyKeyboardMarkup( resizeKeyboard: Boolean? = null, oneTimeKeyboard: Boolean? = null, inputFieldPlaceholder: String? = null, - selective: Boolean? = null + selective: Boolean? = null, + persistent: Boolean? = null ): ReplyKeyboardMarkup = ReplyKeyboardMarkup( flatMatrix { buttons.forEach { +it } }, resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, - selective + selective, + persistent )