mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-22 16:47:13 +00:00
commit
36d30ef91b
4
.github/labeler.yml
vendored
4
.github/labeler.yml
vendored
@ -4,4 +4,6 @@ core: "TelegramBotAPI/**" # currently not work
|
||||
|
||||
code: "**/*.kt"
|
||||
gradle: "**/*.gradle"
|
||||
markdown: "**/*.md"
|
||||
markdown:
|
||||
- "**/*.md"
|
||||
- "!CHANGELOG.md"
|
||||
|
10
CHANGELOG.md
10
CHANGELOG.md
@ -49,6 +49,16 @@
|
||||
* `closePollExactAfter`
|
||||
* `closePollAfter`
|
||||
|
||||
### 0.27.7
|
||||
|
||||
* `TelegramBotAPI`:
|
||||
* Operator function `unaryPlus` was added to `RowBuilder`. Now it is possible to write `row { +button }`
|
||||
* Function `flatMatrix` was added for single-row columns
|
||||
* Operator extension `RowBuilder#plus` was added to be able to write things like `row { this + button }`
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* Function `InlineKeyboardMarkup` for flat keyboards was added
|
||||
* Function `ReplyKeyboardMarkup` for flat keyboards was added
|
||||
|
||||
### 0.27.6
|
||||
|
||||
* `Common`:
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.types.buttons
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.InlineKeyboardButton
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
|
||||
|
||||
fun InlineKeyboardMarkup(
|
||||
vararg buttons: InlineKeyboardButton
|
||||
): InlineKeyboardMarkup = InlineKeyboardMarkup(
|
||||
flatMatrix { buttons.forEach { +it } }
|
||||
)
|
@ -0,0 +1,17 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.types.buttons
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.ReplyKeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardButton
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.flatMatrix
|
||||
|
||||
fun ReplyKeyboardMarkup(
|
||||
vararg buttons: KeyboardButton,
|
||||
resizeKeyboard: Boolean? = null,
|
||||
oneTimeKeyboard: Boolean? = null,
|
||||
selective: Boolean? = null
|
||||
): ReplyKeyboardMarkup = ReplyKeyboardMarkup(
|
||||
flatMatrix { buttons.forEach { +it } },
|
||||
resizeKeyboard,
|
||||
oneTimeKeyboard,
|
||||
selective
|
||||
)
|
@ -18,12 +18,27 @@ fun <T> matrix(block: MatrixBuilder<T>.() -> Unit): Matrix<T> {
|
||||
return MatrixBuilder<T>().also(block).matrix
|
||||
}
|
||||
|
||||
fun <T> flatMatrix(block: RowBuilder<T>.() -> Unit): Matrix<T> {
|
||||
return MatrixBuilder<T>().apply {
|
||||
row(block)
|
||||
}.matrix
|
||||
}
|
||||
|
||||
fun <T> flatMatrix(vararg elements: T): Matrix<T> {
|
||||
return MatrixBuilder<T>().apply {
|
||||
row { elements.forEach { +it } }
|
||||
}.matrix
|
||||
}
|
||||
|
||||
operator fun <T> RowBuilder<T>.plus(t: T) = add(t)
|
||||
|
||||
class RowBuilder<T> {
|
||||
private val mutRow: MutableList<T> = ArrayList()
|
||||
val row: List<T>
|
||||
get() = mutRow
|
||||
|
||||
fun add(t: T) = mutRow.add(t)
|
||||
operator fun T.unaryPlus() = add(this)
|
||||
}
|
||||
|
||||
class MatrixBuilder<T> {
|
||||
|
@ -9,6 +9,6 @@ ktor_version=1.3.2
|
||||
javax_activation_version=1.1.1
|
||||
|
||||
library_group=com.github.insanusmokrassar
|
||||
library_version=0.27.6
|
||||
library_version=0.27.7
|
||||
|
||||
gradle_bintray_plugin_version=1.8.4
|
||||
|
Loading…
Reference in New Issue
Block a user