mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
keyboard builders become typealiases
This commit is contained in:
parent
959f0dffba
commit
8b64a0c94e
@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
## 3.2.7
|
## 3.2.7
|
||||||
|
|
||||||
|
* `Utils`:
|
||||||
|
* Next classes become typealiases instead of classes:
|
||||||
|
* `ReplyKeyboardBuilder`
|
||||||
|
* `ReplyKeyboardRowBuilder`
|
||||||
|
* `InlineKeyboardBuilder`
|
||||||
|
* `InlineKeyboardRowBuilder`
|
||||||
|
|
||||||
## 3.2.6
|
## 3.2.6
|
||||||
|
|
||||||
* `Core`:
|
* `Core`:
|
||||||
|
@ -0,0 +1,102 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.buttons.inline
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.LoginURL
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.*
|
||||||
|
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [PayInlineKeyboardButton]
|
||||||
|
*
|
||||||
|
* @see inlineKeyboard
|
||||||
|
* @see InlineKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun payInlineButton(
|
||||||
|
text: String
|
||||||
|
) = PayInlineKeyboardButton(text)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [CallbackDataInlineKeyboardButton]
|
||||||
|
*
|
||||||
|
* @see inlineKeyboard
|
||||||
|
* @see InlineKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun dataInlineButton(
|
||||||
|
text: String,
|
||||||
|
data: String
|
||||||
|
) = CallbackDataInlineKeyboardButton(text, data)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [CallbackGameInlineKeyboardButton]
|
||||||
|
*
|
||||||
|
* @see inlineKeyboard
|
||||||
|
* @see InlineKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun gameInlineButton(
|
||||||
|
text: String
|
||||||
|
) = CallbackGameInlineKeyboardButton(text)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [LoginURLInlineKeyboardButton]
|
||||||
|
*
|
||||||
|
* @see inlineKeyboard
|
||||||
|
* @see InlineKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun loginInlineButton(
|
||||||
|
text: String,
|
||||||
|
loginUrl: LoginURL
|
||||||
|
) = LoginURLInlineKeyboardButton(text, loginUrl)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [SwitchInlineQueryCurrentChatInlineKeyboardButton]
|
||||||
|
*
|
||||||
|
* @see inlineKeyboard
|
||||||
|
* @see InlineKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun inlineQueryInCurrentChatInlineButton(
|
||||||
|
text: String,
|
||||||
|
data: String
|
||||||
|
) = SwitchInlineQueryCurrentChatInlineKeyboardButton(text, data)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [SwitchInlineQueryInlineKeyboardButton]
|
||||||
|
*
|
||||||
|
* @see inlineKeyboard
|
||||||
|
* @see InlineKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun inlineQueryInlineButton(
|
||||||
|
text: String,
|
||||||
|
data: String
|
||||||
|
) = SwitchInlineQueryInlineKeyboardButton(text, data)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [URLInlineKeyboardButton]
|
||||||
|
*
|
||||||
|
* @see inlineKeyboard
|
||||||
|
* @see InlineKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun urlInlineButton(
|
||||||
|
text: String,
|
||||||
|
url: String
|
||||||
|
) = URLInlineKeyboardButton(text, url)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [WebAppInlineKeyboardButton]. Please, remember that this button is available in private chats only
|
||||||
|
*
|
||||||
|
* @see inlineKeyboard
|
||||||
|
* @see InlineKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun webAppInlineButton(
|
||||||
|
text: String,
|
||||||
|
webApp: WebAppInfo
|
||||||
|
) = WebAppInlineKeyboardButton(text, webApp)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [WebAppInlineKeyboardButton]. Please, remember that this button is available in private chats only
|
||||||
|
*
|
||||||
|
* @see inlineKeyboard
|
||||||
|
* @see InlineKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun webAppInlineButton(
|
||||||
|
text: String,
|
||||||
|
url: String
|
||||||
|
) = webAppInlineButton(text, WebAppInfo(url))
|
@ -0,0 +1,69 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.buttons.reply
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.*
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.*
|
||||||
|
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [SimpleKeyboardButton]
|
||||||
|
*
|
||||||
|
* @see replyKeyboard
|
||||||
|
* @see ReplyKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun simpleReplyButton(
|
||||||
|
text: String
|
||||||
|
) = SimpleKeyboardButton(text)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [RequestContactKeyboardButton]
|
||||||
|
*
|
||||||
|
* @see replyKeyboard
|
||||||
|
* @see ReplyKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun requestContactReplyButton(
|
||||||
|
text: String
|
||||||
|
) = RequestContactKeyboardButton(text)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [RequestLocationKeyboardButton]
|
||||||
|
*
|
||||||
|
* @see replyKeyboard
|
||||||
|
* @see ReplyKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun requestLocationReplyButton(
|
||||||
|
text: String
|
||||||
|
) = RequestLocationKeyboardButton(text)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [RequestPollKeyboardButton]
|
||||||
|
*
|
||||||
|
* @see replyKeyboard
|
||||||
|
* @see ReplyKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun requestPollReplyButton(
|
||||||
|
text: String,
|
||||||
|
pollType: KeyboardButtonPollType
|
||||||
|
) = RequestPollKeyboardButton(text, pollType)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [WebAppKeyboardButton]
|
||||||
|
*
|
||||||
|
* @see replyKeyboard
|
||||||
|
* @see ReplyKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun webAppReplyButton(
|
||||||
|
text: String,
|
||||||
|
webApp: WebAppInfo
|
||||||
|
) = WebAppKeyboardButton(text, webApp)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [WebAppKeyboardButton]
|
||||||
|
*
|
||||||
|
* @see replyKeyboard
|
||||||
|
* @see ReplyKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun webAppReplyButton(
|
||||||
|
text: String,
|
||||||
|
url: String
|
||||||
|
) = webAppReplyButton(text, WebAppInfo(url))
|
@ -15,12 +15,12 @@ import dev.inmo.tgbotapi.utils.RowBuilder
|
|||||||
* @see InlineKeyboardBuilder.row
|
* @see InlineKeyboardBuilder.row
|
||||||
* @see InlineKeyboardRowBuilder
|
* @see InlineKeyboardRowBuilder
|
||||||
*/
|
*/
|
||||||
class InlineKeyboardBuilder : MatrixBuilder<InlineKeyboardButton>() {
|
typealias InlineKeyboardBuilder = MatrixBuilder<InlineKeyboardButton>
|
||||||
/**
|
|
||||||
* Creates [InlineKeyboardMarkup] using internal [matrix]
|
/**
|
||||||
*/
|
* Creates [InlineKeyboardMarkup] using internal [matrix]
|
||||||
fun build() = InlineKeyboardMarkup(matrix)
|
*/
|
||||||
}
|
fun InlineKeyboardBuilder.build() = InlineKeyboardMarkup(matrix)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Row builder of [InlineKeyboardBuilder]
|
* Row builder of [InlineKeyboardBuilder]
|
||||||
@ -28,7 +28,7 @@ class InlineKeyboardBuilder : MatrixBuilder<InlineKeyboardButton>() {
|
|||||||
* @see inlineKeyboard
|
* @see inlineKeyboard
|
||||||
* @see InlineKeyboardBuilder.row
|
* @see InlineKeyboardBuilder.row
|
||||||
*/
|
*/
|
||||||
class InlineKeyboardRowBuilder : RowBuilder<InlineKeyboardButton>()
|
typealias InlineKeyboardRowBuilder = RowBuilder<InlineKeyboardButton>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory-function for [InlineKeyboardBuilder]. It will [apply] [block] to internally created [InlineKeyboardMarkup]
|
* Factory-function for [InlineKeyboardBuilder]. It will [apply] [block] to internally created [InlineKeyboardMarkup]
|
||||||
|
@ -13,17 +13,17 @@ import dev.inmo.tgbotapi.utils.RowBuilder
|
|||||||
* @see ReplyKeyboardBuilder.row
|
* @see ReplyKeyboardBuilder.row
|
||||||
* @see ReplyKeyboardRowBuilder
|
* @see ReplyKeyboardRowBuilder
|
||||||
*/
|
*/
|
||||||
class ReplyKeyboardBuilder : MatrixBuilder<KeyboardButton>() {
|
typealias ReplyKeyboardBuilder = MatrixBuilder<KeyboardButton>
|
||||||
/**
|
|
||||||
* Creates [InlineKeyboardMarkup] using internal [matrix]
|
/**
|
||||||
*/
|
* Creates [InlineKeyboardMarkup] using internal [matrix]
|
||||||
fun build(
|
*/
|
||||||
resizeKeyboard: Boolean? = null,
|
fun ReplyKeyboardBuilder.build(
|
||||||
oneTimeKeyboard: Boolean? = null,
|
resizeKeyboard: Boolean? = null,
|
||||||
inputFieldPlaceholder: String? = null,
|
oneTimeKeyboard: Boolean? = null,
|
||||||
selective: Boolean? = null,
|
inputFieldPlaceholder: String? = null,
|
||||||
) = ReplyKeyboardMarkup(matrix, resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective)
|
selective: Boolean? = null,
|
||||||
}
|
) = ReplyKeyboardMarkup(matrix, resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Row builder of [KeyboardButton]
|
* Row builder of [KeyboardButton]
|
||||||
@ -31,7 +31,7 @@ class ReplyKeyboardBuilder : MatrixBuilder<KeyboardButton>() {
|
|||||||
* @see replyKeyboard
|
* @see replyKeyboard
|
||||||
* @see ReplyKeyboardBuilder.row
|
* @see ReplyKeyboardBuilder.row
|
||||||
*/
|
*/
|
||||||
class ReplyKeyboardRowBuilder : RowBuilder<KeyboardButton>()
|
typealias ReplyKeyboardRowBuilder = RowBuilder<KeyboardButton>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory-function for [ReplyKeyboardBuilder]. It will [apply] [block] to internally created [ReplyKeyboardMarkup]
|
* Factory-function for [ReplyKeyboardBuilder]. It will [apply] [block] to internally created [ReplyKeyboardMarkup]
|
||||||
|
Loading…
Reference in New Issue
Block a user