From 0da0c4e894d1da2784121128b74a68f65a7d0358 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 5 Feb 2023 22:25:43 +0600 Subject: [PATCH] Revert "fixes in keyboards" This reverts commit ae8ef0dd3cacd5f8ef417166b90cee41d76f95b2. --- .../InlineKeyboardButton.kt | 39 ------- .../InlineKeyboardButtonSerializer.kt | 4 - .../tgbotapi/types/buttons/KeyboardButton.kt | 52 +++++++++ .../inline/InlineKeyboardButtonsShortcuts.kt | 101 ----------------- .../reply/ReplyKeyboardButtonsShortcuts.kt | 96 ++++++++++++++++ .../types/buttons/InlineKeyboardBuilder.kt | 106 ------------------ .../types/buttons/ReplyKeyboardBuilder.kt | 104 +++++++++++++++++ 7 files changed, 252 insertions(+), 250 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt index bc0b89accd..6c31cdccee 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt @@ -2,9 +2,6 @@ package dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.buttons.KeyboardButton -import dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestChat -import dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser import dev.inmo.tgbotapi.types.games.CallbackGame import dev.inmo.tgbotapi.types.webapps.WebAppInfo import kotlinx.serialization.* @@ -137,39 +134,3 @@ data class WebAppInlineKeyboardButton( @SerialName(webAppField) val webApp: WebAppInfo ) : InlineKeyboardButton - -/** - * Private chats only. When user will tap on this button, he will be asked for the chat with [requestChat] options. You - * will be able to catch this [ChatId] in updates and data using - * [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onUserShared] in case you are using Behaviour - * Builder OR with [dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter.messagesFlow] - * and [kotlinx.coroutines.flow.filterIsInstance]. - * - * In case you will use [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onUserShared] it is - * recommended to use [kotlinx.coroutines.flow.Flow] [kotlinx.coroutines.flow.filter] with checking of incoming - * [dev.inmo.tgbotapi.types.request.UserShared.requestId] - */ -@Serializable -data class RequestUserInlineKeyboardButton( - override val text: String, - @SerialName(requestUserField) - val requestUser: KeyboardButtonRequestUser -) : InlineKeyboardButton - -/** - * Private chats only. When user will tap on this button, he will be asked for the chat with [requestChat] options. You - * will be able to catch this [ChatId] in updates and data using - * [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onChatShared] in case you are using Behaviour - * Builder OR with [dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter.messagesFlow] - * and [kotlinx.coroutines.flow.filterIsInstance]. - * - * In case you will use [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onChatShared] it is - * recommended to use [kotlinx.coroutines.flow.Flow] [kotlinx.coroutines.flow.filter] with checking of incoming - * [dev.inmo.tgbotapi.types.request.ChatShared.requestId] - */ -@Serializable -data class RequestChatInlineKeyboardButton( - override val text: String, - @SerialName(requestChatField) - val requestChat: KeyboardButtonRequestChat -) : InlineKeyboardButton diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButtonSerializer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButtonSerializer.kt index ce9ae6a843..70005d12c7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButtonSerializer.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButtonSerializer.kt @@ -28,8 +28,6 @@ object InlineKeyboardButtonSerializer : KSerializer { json[switchInlineQueryField] != null -> SwitchInlineQueryInlineKeyboardButton.serializer() json[switchInlineQueryCurrentChatField] != null -> SwitchInlineQueryCurrentChatInlineKeyboardButton.serializer() json[urlField] != null -> URLInlineKeyboardButton.serializer() - json[requestUserField] != null -> RequestUserInlineKeyboardButton.serializer() - json[requestChatField] != null -> RequestChatInlineKeyboardButton.serializer() else -> null } } @@ -52,8 +50,6 @@ object InlineKeyboardButtonSerializer : KSerializer { is URLInlineKeyboardButton -> URLInlineKeyboardButton.serializer().serialize(encoder, value) is WebAppInlineKeyboardButton -> WebAppInlineKeyboardButton.serializer().serialize(encoder, value) is CallbackGameInlineKeyboardButton -> CallbackGameInlineKeyboardButton.serializer().serialize(encoder, value) - is RequestUserInlineKeyboardButton -> RequestUserInlineKeyboardButton.serializer().serialize(encoder, value) - is RequestChatInlineKeyboardButton -> RequestChatInlineKeyboardButton.serializer().serialize(encoder, value) is UnknownInlineKeyboardButton -> JsonElement.serializer().serialize(encoder, value.rawData) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt index 4226bc94d2..64c326637d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt @@ -94,6 +94,42 @@ data class RequestPollKeyboardButton( val requestPoll: KeyboardButtonPollType ) : KeyboardButton +/** + * Private chats only. When user will tap on this button, he will be asked for the chat with [requestChat] options. You + * will be able to catch this [ChatId] in updates and data using + * [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onUserShared] in case you are using Behaviour + * Builder OR with [dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter.messagesFlow] + * and [kotlinx.coroutines.flow.filterIsInstance]. + * + * In case you will use [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onUserShared] it is + * recommended to use [kotlinx.coroutines.flow.Flow] [kotlinx.coroutines.flow.filter] with checking of incoming + * [dev.inmo.tgbotapi.types.request.UserShared.requestId] + */ +@Serializable +data class RequestUserKeyboardButton( + override val text: String, + @SerialName(requestUserField) + val requestUser: KeyboardButtonRequestUser +) : KeyboardButton + +/** + * Private chats only. When user will tap on this button, he will be asked for the chat with [requestChat] options. You + * will be able to catch this [ChatId] in updates and data using + * [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onChatShared] in case you are using Behaviour + * Builder OR with [dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter.messagesFlow] + * and [kotlinx.coroutines.flow.filterIsInstance]. + * + * In case you will use [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onChatShared] it is + * recommended to use [kotlinx.coroutines.flow.Flow] [kotlinx.coroutines.flow.filter] with checking of incoming + * [dev.inmo.tgbotapi.types.request.ChatShared.requestId] + */ +@Serializable +data class RequestChatKeyboardButton( + override val text: String, + @SerialName(requestChatField) + val requestChat: KeyboardButtonRequestChat +) : KeyboardButton + @RiskFeature object KeyboardButtonSerializer : KSerializer { private val internalSerializer = JsonElement.serializer() @@ -124,6 +160,20 @@ object KeyboardButtonSerializer : KSerializer { asJson[requestPollField] ?.jsonObject ?: buildJsonObject { } ) ) + asJson is JsonObject && asJson[requestUserField] != null -> RequestUserKeyboardButton( + asJson[textField]!!.jsonPrimitive.content, + nonstrictJsonFormat.decodeFromJsonElement( + KeyboardButtonRequestUser.serializer(), + asJson[requestUserField] ?.jsonObject ?: buildJsonObject { } + ) + ) + asJson is JsonObject && asJson[requestChatField] != null -> RequestChatKeyboardButton( + asJson[textField]!!.jsonPrimitive.content, + nonstrictJsonFormat.decodeFromJsonElement( + KeyboardButtonRequestChat.serializer(), + asJson[requestChatField] ?.jsonObject ?: buildJsonObject { } + ) + ) else -> UnknownKeyboardButton( when (asJson) { is JsonObject -> asJson[textField]!!.jsonPrimitive.content @@ -142,6 +192,8 @@ object KeyboardButtonSerializer : KSerializer { is WebAppKeyboardButton -> WebAppKeyboardButton.serializer().serialize(encoder, value) is RequestPollKeyboardButton -> RequestPollKeyboardButton.serializer().serialize(encoder, value) is SimpleKeyboardButton -> encoder.encodeString(value.text) + is RequestUserKeyboardButton -> RequestUserKeyboardButton.serializer().serialize(encoder, value) + is RequestChatKeyboardButton -> RequestChatKeyboardButton.serializer().serialize(encoder, value) is UnknownKeyboardButton -> JsonElement.serializer().serialize(encoder, nonstrictJsonFormat.parseToJsonElement(value.raw)) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/inline/InlineKeyboardButtonsShortcuts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/inline/InlineKeyboardButtonsShortcuts.kt index 86854e8890..9f148a98fe 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/inline/InlineKeyboardButtonsShortcuts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/inline/InlineKeyboardButtonsShortcuts.kt @@ -2,10 +2,6 @@ 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.buttons.KeyboardButtonRequestChat -import dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser -import dev.inmo.tgbotapi.types.chat.member.ChatAdministratorRights -import dev.inmo.tgbotapi.types.request.RequestId import dev.inmo.tgbotapi.types.webapps.WebAppInfo /** @@ -104,100 +100,3 @@ inline fun webAppInlineButton( text: String, url: String ) = webAppInlineButton(text, WebAppInfo(url)) - - -/** - * Creates and put [RequestUserKeyboardButton] - * - * @see replyKeyboard - * @see ReplyKeyboardBuilder.row - */ -inline fun requestUserInlineButton( - text: String, - requestUser: KeyboardButtonRequestUser -) = RequestUserInlineKeyboardButton( - text, - requestUser -) - -/** - * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Bot] - * - * @see replyKeyboard - * @see ReplyKeyboardBuilder.row - */ -inline fun requestBotInlineButton( - text: String, - requestId: RequestId -) = requestUserInlineButton( - text, - KeyboardButtonRequestUser.Bot(requestId) -) - -/** - * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Common] - * - * @see replyKeyboard - * @see ReplyKeyboardBuilder.row - */ -inline fun requestUserInlineButton( - text: String, - requestId: RequestId, - premiumUser: Boolean? = null -) = requestUserInlineButton( - text, - KeyboardButtonRequestUser.Common(requestId, premiumUser) -) - -/** - * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Any] - * - * @see replyKeyboard - * @see ReplyKeyboardBuilder.row - */ -inline fun requestUserOrBotInlineButton( - text: String, - requestId: RequestId -) = requestUserInlineButton( - text, - KeyboardButtonRequestUser.Any(requestId) -) - - -/** - * Creates and put [RequestChatKeyboardButton] - * - * @see replyKeyboard - * @see ReplyKeyboardBuilder.row - */ -inline fun requestChatInlineButton( - text: String, - requestChat: KeyboardButtonRequestChat -) = RequestChatInlineKeyboardButton( - text, - requestChat -) - -/** - * Creates and put [RequestChatKeyboardButton] with [KeyboardButtonRequestChat] - * - * @see replyKeyboard - * @see ReplyKeyboardBuilder.row - */ -inline fun requestChatInlineButton( - text: String, - requestId: RequestId, - isChannel: Boolean? = null, - isForum: Boolean? = null, - withUsername: Boolean? = null, - ownedBy: Boolean? = null, - userRightsInChat: ChatAdministratorRights? = null, - botRightsInChat: ChatAdministratorRights? = null, - botIsMember: Boolean = false -) = requestChatInlineButton( - text, - KeyboardButtonRequestChat( - requestId, isChannel, isForum, withUsername, ownedBy, userRightsInChat, botRightsInChat, botIsMember - ) -) - diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/reply/ReplyKeyboardButtonsShortcuts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/reply/ReplyKeyboardButtonsShortcuts.kt index dd8debb4fe..dba7cac982 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/reply/ReplyKeyboardButtonsShortcuts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/reply/ReplyKeyboardButtonsShortcuts.kt @@ -69,3 +69,99 @@ inline fun webAppReplyButton( text: String, url: String ) = webAppReplyButton(text, WebAppInfo(url)) + + +/** + * Creates and put [RequestUserKeyboardButton] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun requestUserReplyButton( + text: String, + requestUser: KeyboardButtonRequestUser +) = RequestUserKeyboardButton( + text, + requestUser +) + +/** + * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Bot] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun requestBotReplyButton( + text: String, + requestId: RequestId +) = requestUserReplyButton( + text, + KeyboardButtonRequestUser.Bot(requestId) +) + +/** + * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Common] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun requestUserReplyButton( + text: String, + requestId: RequestId, + premiumUser: Boolean? = null +) = requestUserReplyButton( + text, + KeyboardButtonRequestUser.Common(requestId, premiumUser) +) + +/** + * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Any] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun requestUserOrBotReplyButton( + text: String, + requestId: RequestId +) = requestUserReplyButton( + text, + KeyboardButtonRequestUser.Any(requestId) +) + + +/** + * Creates and put [RequestChatKeyboardButton] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun requestChatReplyButton( + text: String, + requestChat: KeyboardButtonRequestChat +) = RequestChatKeyboardButton( + text, + requestChat +) + +/** + * Creates and put [RequestChatKeyboardButton] with [KeyboardButtonRequestChat] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun requestChatReplyButton( + text: String, + requestId: RequestId, + isChannel: Boolean? = null, + isForum: Boolean? = null, + withUsername: Boolean? = null, + ownedBy: Boolean? = null, + userRightsInChat: ChatAdministratorRights? = null, + botRightsInChat: ChatAdministratorRights? = null, + botIsMember: Boolean = false +) = requestChatReplyButton( + text, + KeyboardButtonRequestChat( + requestId, isChannel, isForum, withUsername, ownedBy, userRightsInChat, botRightsInChat, botIsMember + ) +) 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 3b23df15fd..69037b21e3 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 @@ -3,12 +3,6 @@ package dev.inmo.tgbotapi.extensions.utils.types.buttons import dev.inmo.tgbotapi.types.LoginURL import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.* import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup -import dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestChat -import dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser -import dev.inmo.tgbotapi.types.buttons.inline.requestChatInlineButton -import dev.inmo.tgbotapi.types.buttons.inline.requestUserInlineButton -import dev.inmo.tgbotapi.types.chat.member.ChatAdministratorRights -import dev.inmo.tgbotapi.types.request.RequestId import dev.inmo.tgbotapi.types.webapps.WebAppInfo import dev.inmo.tgbotapi.utils.* @@ -167,103 +161,3 @@ inline fun InlineKeyboardRowBuilder.webAppButton( text: String, url: String ) = webAppButton(text, WebAppInfo(url)) - - -/** - * Creates and put [RequestUserKeyboardButton] - * - * @see replyKeyboard - * @see ReplyKeyboardBuilder.row - */ -inline fun InlineKeyboardRowBuilder.requestUserButton( - text: String, - requestUser: KeyboardButtonRequestUser -) = add( - requestUserInlineButton( - text, - requestUser - ) -) - -/** - * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Bot] - * - * @see replyKeyboard - * @see ReplyKeyboardBuilder.row - */ -inline fun InlineKeyboardRowBuilder.requestBotButton( - text: String, - requestId: RequestId -) = requestUserButton( - text, - KeyboardButtonRequestUser.Bot(requestId) -) - -/** - * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Common] - * - * @see replyKeyboard - * @see ReplyKeyboardBuilder.row - */ -inline fun InlineKeyboardRowBuilder.requestUserButton( - text: String, - requestId: RequestId, - premiumUser: Boolean? = null -) = requestUserButton( - text, - KeyboardButtonRequestUser.Common(requestId, premiumUser) -) - -/** - * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Any] - * - * @see replyKeyboard - * @see ReplyKeyboardBuilder.row - */ -inline fun InlineKeyboardRowBuilder.requestUserOrBotButton( - text: String, - requestId: RequestId -) = requestUserButton( - text, - KeyboardButtonRequestUser.Any(requestId) -) - - -/** - * Creates and put [RequestChatKeyboardButton] - * - * @see replyKeyboard - * @see ReplyKeyboardBuilder.row - */ -inline fun InlineKeyboardRowBuilder.requestChatButton( - text: String, - requestChat: KeyboardButtonRequestChat -) = add( - requestChatInlineButton( - text, - requestChat - ) -) - -/** - * Creates and put [RequestChatKeyboardButton] with [KeyboardButtonRequestChat] - * - * @see replyKeyboard - * @see ReplyKeyboardBuilder.row - */ -inline fun InlineKeyboardRowBuilder.requestChatButton( - text: String, - requestId: RequestId, - isChannel: Boolean? = null, - isForum: Boolean? = null, - withUsername: Boolean? = null, - ownedBy: Boolean? = null, - userRightsInChat: ChatAdministratorRights? = null, - botRightsInChat: ChatAdministratorRights? = null, - botIsMember: Boolean = false -) = requestChatButton( - text, - KeyboardButtonRequestChat( - requestId, isChannel, isForum, withUsername, ownedBy, userRightsInChat, botRightsInChat, botIsMember - ) -) 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 9bd0909aa1..3b8cce77cf 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 @@ -1,6 +1,10 @@ package dev.inmo.tgbotapi.extensions.utils.types.buttons import dev.inmo.tgbotapi.types.buttons.* +import dev.inmo.tgbotapi.types.buttons.reply.requestChatReplyButton +import dev.inmo.tgbotapi.types.buttons.reply.requestUserReplyButton +import dev.inmo.tgbotapi.types.chat.member.ChatAdministratorRights +import dev.inmo.tgbotapi.types.request.RequestId import dev.inmo.tgbotapi.types.webapps.WebAppInfo import dev.inmo.tgbotapi.utils.* @@ -138,3 +142,103 @@ inline fun ReplyKeyboardRowBuilder.webAppButton( text: String, url: String ) = webAppButton(text, WebAppInfo(url)) + + +/** + * Creates and put [RequestUserKeyboardButton] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun ReplyKeyboardRowBuilder.requestUserButton( + text: String, + requestUser: KeyboardButtonRequestUser +) = add( + requestUserReplyButton( + text, + requestUser + ) +) + +/** + * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Bot] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun ReplyKeyboardRowBuilder.requestBotButton( + text: String, + requestId: RequestId +) = requestUserButton( + text, + KeyboardButtonRequestUser.Bot(requestId) +) + +/** + * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Common] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun ReplyKeyboardRowBuilder.requestUserButton( + text: String, + requestId: RequestId, + premiumUser: Boolean? = null +) = requestUserButton( + text, + KeyboardButtonRequestUser.Common(requestId, premiumUser) +) + +/** + * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Any] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun ReplyKeyboardRowBuilder.requestUserOrBotButton( + text: String, + requestId: RequestId +) = requestUserButton( + text, + KeyboardButtonRequestUser.Any(requestId) +) + + +/** + * Creates and put [RequestChatKeyboardButton] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun ReplyKeyboardRowBuilder.requestChatButton( + text: String, + requestChat: KeyboardButtonRequestChat +) = add( + requestChatReplyButton( + text, + requestChat + ) +) + +/** + * Creates and put [RequestChatKeyboardButton] with [KeyboardButtonRequestChat] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun ReplyKeyboardRowBuilder.requestChatButton( + text: String, + requestId: RequestId, + isChannel: Boolean? = null, + isForum: Boolean? = null, + withUsername: Boolean? = null, + ownedBy: Boolean? = null, + userRightsInChat: ChatAdministratorRights? = null, + botRightsInChat: ChatAdministratorRights? = null, + botIsMember: Boolean = false +) = requestChatButton( + text, + KeyboardButtonRequestChat( + requestId, isChannel, isForum, withUsername, ownedBy, userRightsInChat, botRightsInChat, botIsMember + ) +)