diff --git a/CHANGELOG.md b/CHANGELOG.md index 650dfbf0ff..a741304a48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * `Utils`: * New extension `Message#sameChat` * New extension `Message#sameMessage` + * New functions `flatInlineKeyboard` and `flatReplyKeyboard` ## 2.1.3 diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt index 595d0de9a3..b458ba7ae0 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt @@ -40,6 +40,16 @@ inline fun inlineKeyboard( block: InlineKeyboardBuilder.() -> Unit ) = InlineKeyboardBuilder().apply(block).build() +/** + * Factory-function for [InlineKeyboardBuilder], but in difference with [inlineKeyboard] this function will create single-row + * inline keyboard + * + * @see InlineKeyboardBuilder.row + */ +inline fun flatInlineKeyboard( + block: InlineKeyboardRowBuilder.() -> Unit +) = inlineKeyboard { row(block) } + /** * Creates an [InlineKeyboardRowBuilder] and [apply] [block] with this builder * 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 2bb771e86d..fd88ee744f 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 @@ -47,6 +47,20 @@ inline fun replyKeyboard( block: ReplyKeyboardBuilder.() -> Unit ) = ReplyKeyboardBuilder().apply(block).build(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) +/** + * Factory-function for [ReplyKeyboardBuilder], but in difference with [replyKeyboard] this method will create single-row + * keyboard + */ +inline fun flatReplyKeyboard( + resizeKeyboard: Boolean? = null, + oneTimeKeyboard: Boolean? = null, + inputFieldPlaceholder: String? = null, + selective: Boolean? = null, + block: ReplyKeyboardRowBuilder.() -> Unit +) = replyKeyboard(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) { + row(block) +} + /** * Creates an [ReplyKeyboardRowBuilder] and [apply] [block] with this builder *