commonMain.com.github.insanusmokrassar.TelegramBotAPI.utils.Matrix.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of TelegramBotAPI-js Show documentation
Show all versions of TelegramBotAPI-js Show documentation
Library for Object-Oriented and type-safe work with Telegram Bot API
package com.github.insanusmokrassar.TelegramBotAPI.utils
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.Matrix
fun row(block: RowBuilder.() -> Unit): List {
return RowBuilder().also(block).row
}
fun MatrixBuilder.row(block: RowBuilder.() -> Unit) {
add(RowBuilder().also(block).row)
}
fun matrix(block: MatrixBuilder.() -> Unit): Matrix {
return MatrixBuilder().also(block).matrix
}
class RowBuilder {
private val mutRow: MutableList = ArrayList()
val row: List
get() = mutRow
fun add(t: T) = mutRow.add(t)
}
class MatrixBuilder {
private val mutMatrix: MutableList> = ArrayList()
val matrix: Matrix
get() = mutMatrix
fun add(t: List) = mutMatrix.add(t)
operator fun plus(t: List) = add(t)
}