diff --git a/CHANGELOG.md b/CHANGELOG.md index 573d2a5192..36017cd539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Matrix.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Matrix.kt index 8187de14cc..902554c978 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Matrix.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Matrix.kt @@ -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 row(block: RowBuilder.() -> Unit): List { return RowBuilder().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 MatrixBuilder.row(block: RowBuilder.() -> Unit) { add(RowBuilder().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 MatrixBuilder.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 matrix(block: MatrixBuilder.() -> Unit): Matrix { return MatrixBuilder().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 flatMatrix(block: RowBuilder.() -> Unit): Matrix { return MatrixBuilder().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 flatMatrix(vararg elements: T): Matrix { return MatrixBuilder().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 RowBuilder.plus(t: T) = add(t) open class RowBuilder {