1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-26 03:58:44 +00:00

improvements in keyboards and add tgWebAppStartParamField

This commit is contained in:
InsanusMokrassar 2022-05-04 23:11:20 +06:00
parent 52f405c3b1
commit 233c789054
5 changed files with 26 additions and 4 deletions

View File

@ -2,6 +2,10 @@
## 0.38.22 ## 0.38.22
* `Core`:
* New constant `tgWebAppStartParamField`
* All keyboards builders and rows blocks becomes not crossinline
## 0.38.21 ## 0.38.21
* `WebApps`: * `WebApps`:

View File

@ -96,6 +96,8 @@ val telegramInlineModeGifPermittedMimeTypes by lazy {
) )
} }
const val tgWebAppStartParamField = "tgWebAppStartParam"
const val chatIdField = "chat_id" const val chatIdField = "chat_id"
const val senderChatIdField = "sender_chat_id" const val senderChatIdField = "sender_chat_id"
const val messageIdField = "message_id" const val messageIdField = "message_id"

View File

@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.utils.extensions
import dev.inmo.tgbotapi.types.tgWebAppStartParamField
fun createWebAppStartParam(value: String) = tgWebAppStartParamField to value

View File

@ -37,7 +37,7 @@ class InlineKeyboardRowBuilder : RowBuilder<InlineKeyboardButton>()
* @see InlineKeyboardBuilder.row * @see InlineKeyboardBuilder.row
*/ */
inline fun inlineKeyboard( inline fun inlineKeyboard(
crossinline block: InlineKeyboardBuilder.() -> Unit block: InlineKeyboardBuilder.() -> Unit
) = InlineKeyboardBuilder().apply(block).build() ) = InlineKeyboardBuilder().apply(block).build()
/** /**
@ -52,7 +52,7 @@ inline fun inlineKeyboard(
* @see urlButton * @see urlButton
*/ */
inline fun InlineKeyboardBuilder.row( inline fun InlineKeyboardBuilder.row(
crossinline block: InlineKeyboardRowBuilder.() -> Unit block: InlineKeyboardRowBuilder.() -> Unit
) = add(InlineKeyboardRowBuilder().apply(block).row) ) = add(InlineKeyboardRowBuilder().apply(block).row)
/** /**

View File

@ -44,7 +44,7 @@ inline fun replyKeyboard(
oneTimeKeyboard: Boolean? = null, oneTimeKeyboard: Boolean? = null,
inputFieldPlaceholder: String? = null, inputFieldPlaceholder: String? = null,
selective: Boolean? = null, selective: Boolean? = null,
crossinline block: ReplyKeyboardBuilder.() -> Unit block: ReplyKeyboardBuilder.() -> Unit
) = ReplyKeyboardBuilder().apply(block).build(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) ) = ReplyKeyboardBuilder().apply(block).build(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective)
/** /**
@ -56,7 +56,7 @@ inline fun replyKeyboard(
* @see requestPollButton * @see requestPollButton
*/ */
inline fun ReplyKeyboardBuilder.row( inline fun ReplyKeyboardBuilder.row(
crossinline block: ReplyKeyboardRowBuilder.() -> Unit block: ReplyKeyboardRowBuilder.() -> Unit
) = add(ReplyKeyboardRowBuilder().apply(block).row) ) = add(ReplyKeyboardRowBuilder().apply(block).row)
/** /**
@ -110,3 +110,14 @@ inline fun ReplyKeyboardRowBuilder.webAppButton(
text: String, text: String,
webApp: WebAppInfo webApp: WebAppInfo
) = add(WebAppKeyboardButton(text, webApp)) ) = add(WebAppKeyboardButton(text, webApp))
/**
* Creates and put [WebAppKeyboardButton]
*
* @see replyKeyboard
* @see ReplyKeyboardBuilder.row
*/
inline fun ReplyKeyboardRowBuilder.webAppButton(
text: String,
url: String
) = webAppButton(text, WebAppInfo(url))