mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
deprecate old row methods for keyboard builders
This commit is contained in:
parent
8b64a0c94e
commit
b588622c3d
@ -6,23 +6,23 @@ import dev.inmo.tgbotapi.types.buttons.Matrix
|
|||||||
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder
|
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder
|
||||||
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder
|
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder
|
||||||
*/
|
*/
|
||||||
fun <T> row(block: RowBuilder<T>.() -> Unit): List<T> {
|
inline fun <T> row(block: RowBuilder<T>.() -> Unit): List<T> {
|
||||||
return RowBuilder<T>().also(block).row
|
return RowBuilder<T>().apply(block).row
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder
|
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder
|
||||||
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder
|
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder
|
||||||
*/
|
*/
|
||||||
fun <T> MatrixBuilder<T>.row(block: RowBuilder<T>.() -> Unit) {
|
inline fun <T> MatrixBuilder<T>.row(block: RowBuilder<T>.() -> Unit) {
|
||||||
add(RowBuilder<T>().also(block).row)
|
add(RowBuilder<T>().apply(block).row)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder
|
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder
|
||||||
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder
|
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder
|
||||||
*/
|
*/
|
||||||
fun <T> MatrixBuilder<T>.row(vararg elements: T) {
|
inline fun <T> MatrixBuilder<T>.row(vararg elements: T) {
|
||||||
add(elements.toList())
|
add(elements.toList())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ fun <T> MatrixBuilder<T>.row(vararg elements: T) {
|
|||||||
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder
|
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder
|
||||||
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder
|
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder
|
||||||
*/
|
*/
|
||||||
fun <T> matrix(block: MatrixBuilder<T>.() -> Unit): Matrix<T> {
|
inline fun <T> matrix(block: MatrixBuilder<T>.() -> Unit): Matrix<T> {
|
||||||
return MatrixBuilder<T>().also(block).matrix
|
return MatrixBuilder<T>().also(block).matrix
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ fun <T> matrix(block: MatrixBuilder<T>.() -> Unit): Matrix<T> {
|
|||||||
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder
|
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder
|
||||||
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder
|
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder
|
||||||
*/
|
*/
|
||||||
fun <T> flatMatrix(block: RowBuilder<T>.() -> Unit): Matrix<T> {
|
inline fun <T> flatMatrix(block: RowBuilder<T>.() -> Unit): Matrix<T> {
|
||||||
return MatrixBuilder<T>().apply {
|
return MatrixBuilder<T>().apply {
|
||||||
row(block)
|
row(block)
|
||||||
}.matrix
|
}.matrix
|
||||||
@ -48,7 +48,7 @@ fun <T> flatMatrix(block: RowBuilder<T>.() -> Unit): Matrix<T> {
|
|||||||
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder
|
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder
|
||||||
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder
|
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder
|
||||||
*/
|
*/
|
||||||
fun <T> flatMatrix(vararg elements: T): Matrix<T> {
|
inline fun <T> flatMatrix(vararg elements: T): Matrix<T> {
|
||||||
return MatrixBuilder<T>().apply {
|
return MatrixBuilder<T>().apply {
|
||||||
row { elements.forEach { +it } }
|
row { elements.forEach { +it } }
|
||||||
}.matrix
|
}.matrix
|
||||||
|
@ -4,8 +4,7 @@ import dev.inmo.tgbotapi.types.LoginURL
|
|||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.*
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.*
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
||||||
import dev.inmo.tgbotapi.utils.MatrixBuilder
|
import dev.inmo.tgbotapi.utils.*
|
||||||
import dev.inmo.tgbotapi.utils.RowBuilder
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core DSL part of Inline Keyboard DSL. Can accept only [InlineKeyboardButton] and returns ready to use
|
* Core DSL part of Inline Keyboard DSL. Can accept only [InlineKeyboardButton] and returns ready to use
|
||||||
@ -48,7 +47,7 @@ inline fun inlineKeyboard(
|
|||||||
*/
|
*/
|
||||||
inline fun flatInlineKeyboard(
|
inline fun flatInlineKeyboard(
|
||||||
block: InlineKeyboardRowBuilder.() -> Unit
|
block: InlineKeyboardRowBuilder.() -> Unit
|
||||||
) = inlineKeyboard { row(block) }
|
) = inlineKeyboard { row<InlineKeyboardButton>(block) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an [InlineKeyboardRowBuilder] and [apply] [block] with this builder
|
* Creates an [InlineKeyboardRowBuilder] and [apply] [block] with this builder
|
||||||
@ -61,6 +60,7 @@ inline fun flatInlineKeyboard(
|
|||||||
* @see inlineQueryButton
|
* @see inlineQueryButton
|
||||||
* @see urlButton
|
* @see urlButton
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Redundant", ReplaceWith("this.row(block)", "dev.inmo.tgbotapi.utils.row"))
|
||||||
inline fun InlineKeyboardBuilder.row(
|
inline fun InlineKeyboardBuilder.row(
|
||||||
block: InlineKeyboardRowBuilder.() -> Unit
|
block: InlineKeyboardRowBuilder.() -> Unit
|
||||||
) = add(InlineKeyboardRowBuilder().apply(block).row)
|
) = add(InlineKeyboardRowBuilder().apply(block).row)
|
||||||
|
@ -2,8 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.types.buttons
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.*
|
import dev.inmo.tgbotapi.types.buttons.*
|
||||||
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
||||||
import dev.inmo.tgbotapi.utils.MatrixBuilder
|
import dev.inmo.tgbotapi.utils.*
|
||||||
import dev.inmo.tgbotapi.utils.RowBuilder
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core DSL part of Keyboard DSL. Can accept only [KeyboardButton] and returns ready to use
|
* Core DSL part of Keyboard DSL. Can accept only [KeyboardButton] and returns ready to use
|
||||||
@ -58,7 +57,7 @@ inline fun flatReplyKeyboard(
|
|||||||
selective: Boolean? = null,
|
selective: Boolean? = null,
|
||||||
block: ReplyKeyboardRowBuilder.() -> Unit
|
block: ReplyKeyboardRowBuilder.() -> Unit
|
||||||
) = replyKeyboard(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) {
|
) = replyKeyboard(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) {
|
||||||
row(block)
|
row<KeyboardButton>(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,6 +68,7 @@ inline fun flatReplyKeyboard(
|
|||||||
* @see requestLocationButton
|
* @see requestLocationButton
|
||||||
* @see requestPollButton
|
* @see requestPollButton
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Redundant", ReplaceWith("this.row(block)", "dev.inmo.tgbotapi.utils.row"))
|
||||||
inline fun ReplyKeyboardBuilder.row(
|
inline fun ReplyKeyboardBuilder.row(
|
||||||
block: ReplyKeyboardRowBuilder.() -> Unit
|
block: ReplyKeyboardRowBuilder.() -> Unit
|
||||||
) = add(ReplyKeyboardRowBuilder().apply(block).row)
|
) = add(ReplyKeyboardRowBuilder().apply(block).row)
|
||||||
|
Loading…
Reference in New Issue
Block a user