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 oneTimeKeyboardField = "one_time_keyboard"
const val inputFieldPlaceholderField = "input_field_placeholder"
const val isPersistentField = "is_persistent"
const val priceDependOnShipAddressField = "is_flexible"

View File

@ -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) {

View File

@ -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<KeyboardButton>(block)
}

View File

@ -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
)