diff --git a/CHANGELOG.md b/CHANGELOG.md index fe957764ab..fe4e425156 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # TelegramBotAPI changelog +## 0.38.22 + +* `Core`: + * New constant `tgWebAppStartParamField` + * All keyboards builders and rows blocks becomes not crossinline + ## 0.38.21 * `WebApps`: diff --git a/gradle.properties b/gradle.properties index 41eec25c51..d804f6b631 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,6 +20,6 @@ javax_activation_version=1.1.1 dokka_version=1.6.10 library_group=dev.inmo -library_version=0.38.21 +library_version=0.38.22 github_release_plugin_version=2.3.7 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 3c69c82260..c90052f0c8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -96,6 +96,8 @@ val telegramInlineModeGifPermittedMimeTypes by lazy { ) } +const val tgWebAppStartParamField = "tgWebAppStartParam" + const val chatIdField = "chat_id" const val senderChatIdField = "sender_chat_id" const val messageIdField = "message_id" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/WebAppParamHelper.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/WebAppParamHelper.kt new file mode 100644 index 0000000000..766073d78e --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/WebAppParamHelper.kt @@ -0,0 +1,5 @@ +package dev.inmo.tgbotapi.utils.extensions + +import dev.inmo.tgbotapi.types.tgWebAppStartParamField + +fun createWebAppStartParam(value: String) = tgWebAppStartParamField to value diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt index 24ff8e370c..595d0de9a3 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt @@ -37,7 +37,7 @@ class InlineKeyboardRowBuilder : RowBuilder() * @see InlineKeyboardBuilder.row */ inline fun inlineKeyboard( - crossinline block: InlineKeyboardBuilder.() -> Unit + block: InlineKeyboardBuilder.() -> Unit ) = InlineKeyboardBuilder().apply(block).build() /** @@ -52,7 +52,7 @@ inline fun inlineKeyboard( * @see urlButton */ inline fun InlineKeyboardBuilder.row( - crossinline block: InlineKeyboardRowBuilder.() -> Unit + block: InlineKeyboardRowBuilder.() -> Unit ) = add(InlineKeyboardRowBuilder().apply(block).row) /** diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt index 78e86fb8d8..2bb771e86d 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt @@ -44,7 +44,7 @@ inline fun replyKeyboard( oneTimeKeyboard: Boolean? = null, inputFieldPlaceholder: String? = null, selective: Boolean? = null, - crossinline block: ReplyKeyboardBuilder.() -> Unit + block: ReplyKeyboardBuilder.() -> Unit ) = ReplyKeyboardBuilder().apply(block).build(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) /** @@ -56,7 +56,7 @@ inline fun replyKeyboard( * @see requestPollButton */ inline fun ReplyKeyboardBuilder.row( - crossinline block: ReplyKeyboardRowBuilder.() -> Unit + block: ReplyKeyboardRowBuilder.() -> Unit ) = add(ReplyKeyboardRowBuilder().apply(block).row) /** @@ -110,3 +110,14 @@ inline fun ReplyKeyboardRowBuilder.webAppButton( text: String, webApp: WebAppInfo ) = 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))