1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

add ReplyKeyboardMarkup

This commit is contained in:
InsanusMokrassar 2022-12-30 19:38:26 +06:00
parent c882717bcc
commit 8df8b87d54
4 changed files with 14 additions and 6 deletions

View File

@ -461,6 +461,7 @@ const val shouldSendEmailToProviderField = "send_email_to_provider"
const val resizeKeyboardField = "resize_keyboard" const val resizeKeyboardField = "resize_keyboard"
const val oneTimeKeyboardField = "one_time_keyboard" const val oneTimeKeyboardField = "one_time_keyboard"
const val inputFieldPlaceholderField = "input_field_placeholder" const val inputFieldPlaceholderField = "input_field_placeholder"
const val isPersistentField = "is_persistent"
const val priceDependOnShipAddressField = "is_flexible" const val priceDependOnShipAddressField = "is_flexible"

View File

@ -13,7 +13,9 @@ data class ReplyKeyboardMarkup(
val oneTimeKeyboard: Boolean? = null, val oneTimeKeyboard: Boolean? = null,
@SerialName(inputFieldPlaceholderField) @SerialName(inputFieldPlaceholderField)
val inputFieldPlaceholder: String? = null, val inputFieldPlaceholder: String? = null,
val selective: Boolean? = null val selective: Boolean? = null,
@SerialName(isPersistentField)
val persistent: Boolean? = null
) : KeyboardMarkup { ) : KeyboardMarkup {
init { init {
if (inputFieldPlaceholder != null && inputFieldPlaceholder.length !in inputFieldPlaceholderLimit) { if (inputFieldPlaceholder != null && inputFieldPlaceholder.length !in inputFieldPlaceholderLimit) {

View File

@ -22,7 +22,8 @@ fun ReplyKeyboardBuilder.build(
oneTimeKeyboard: Boolean? = null, oneTimeKeyboard: Boolean? = null,
inputFieldPlaceholder: String? = null, inputFieldPlaceholder: String? = null,
selective: Boolean? = null, selective: Boolean? = null,
) = ReplyKeyboardMarkup(matrix, resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) persistent: Boolean? = null,
) = ReplyKeyboardMarkup(matrix, resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective, persistent)
/** /**
* Row builder of [KeyboardButton] * Row builder of [KeyboardButton]
@ -43,8 +44,9 @@ inline fun replyKeyboard(
oneTimeKeyboard: Boolean? = null, oneTimeKeyboard: Boolean? = null,
inputFieldPlaceholder: String? = null, inputFieldPlaceholder: String? = null,
selective: Boolean? = null, selective: Boolean? = null,
persistent: Boolean? = null,
block: ReplyKeyboardBuilder.() -> Unit 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 * 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, oneTimeKeyboard: Boolean? = null,
inputFieldPlaceholder: String? = null, inputFieldPlaceholder: String? = null,
selective: Boolean? = null, selective: Boolean? = null,
persistent: Boolean? = null,
block: ReplyKeyboardRowBuilder.() -> Unit block: ReplyKeyboardRowBuilder.() -> Unit
) = replyKeyboard(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) { ) = replyKeyboard(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective, persistent) {
row<KeyboardButton>(block) row<KeyboardButton>(block)
} }

View File

@ -9,11 +9,13 @@ fun ReplyKeyboardMarkup(
resizeKeyboard: Boolean? = null, resizeKeyboard: Boolean? = null,
oneTimeKeyboard: Boolean? = null, oneTimeKeyboard: Boolean? = null,
inputFieldPlaceholder: String? = null, inputFieldPlaceholder: String? = null,
selective: Boolean? = null selective: Boolean? = null,
persistent: Boolean? = null
): ReplyKeyboardMarkup = ReplyKeyboardMarkup( ): ReplyKeyboardMarkup = ReplyKeyboardMarkup(
flatMatrix { buttons.forEach { +it } }, flatMatrix { buttons.forEach { +it } },
resizeKeyboard, resizeKeyboard,
oneTimeKeyboard, oneTimeKeyboard,
inputFieldPlaceholder, inputFieldPlaceholder,
selective selective,
persistent
) )