old matrix and row deprecation

This commit is contained in:
InsanusMokrassar 2022-03-29 12:27:03 +06:00
parent 94e5f74a90
commit 0fd146655d
2 changed files with 36 additions and 0 deletions

View File

@ -8,6 +8,7 @@
* `Klock`: `2.6.3` -> `2.7.0`
* `Core`:
* Fixes in `TextSourcesList` creating in from `RawMessageEntities`
* Old ways to create keyboards (`matrix` and `row`) have been deprecated
* `API`:
* Add opportunity to `reply` with `Poll`
* Add opportunity to `reply` with any `MessageContent`

View File

@ -2,34 +2,69 @@ package dev.inmo.tgbotapi.utils
import dev.inmo.tgbotapi.types.buttons.Matrix
/**
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder
*/
@Deprecated("This functionality will be removed soon")
fun <T> row(block: RowBuilder<T>.() -> Unit): List<T> {
return RowBuilder<T>().also(block).row
}
/**
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder
*/
@Deprecated("This functionality will be removed soon")
fun <T> MatrixBuilder<T>.row(block: RowBuilder<T>.() -> Unit) {
add(RowBuilder<T>().also(block).row)
}
/**
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder
*/
@Deprecated("This functionality will be removed soon")
fun <T> MatrixBuilder<T>.row(vararg elements: T) {
add(elements.toList())
}
/**
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder
*/
@Deprecated("This functionality will be removed soon")
fun <T> matrix(block: MatrixBuilder<T>.() -> Unit): Matrix<T> {
return MatrixBuilder<T>().also(block).matrix
}
/**
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder
*/
@Deprecated("This functionality will be removed soon")
fun <T> flatMatrix(block: RowBuilder<T>.() -> Unit): Matrix<T> {
return MatrixBuilder<T>().apply {
row(block)
}.matrix
}
/**
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder
*/
@Deprecated("This functionality will be removed soon")
fun <T> flatMatrix(vararg elements: T): Matrix<T> {
return MatrixBuilder<T>().apply {
row { elements.forEach { +it } }
}.matrix
}
/**
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder
*/
@Deprecated("This functionality will be removed soon")
operator fun <T> RowBuilder<T>.plus(t: T) = add(t)
open class RowBuilder<T> {