From ae8ef0dd3cacd5f8ef417166b90cee41d76f95b2 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 5 Feb 2023 21:47:15 +0600 Subject: [PATCH] fixes in keyboards --- .../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, 250 insertions(+), 252 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 6c31cdccee..bc0b89accd 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,6 +2,9 @@ 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.* @@ -134,3 +137,39 @@ 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 70005d12c7..ce9ae6a843 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,6 +28,8 @@ 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 } } @@ -50,6 +52,8 @@ 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 64c326637d..4226bc94d2 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,42 +94,6 @@ 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() @@ -160,20 +124,6 @@ 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 @@ -192,8 +142,6 @@ 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 9f148a98fe..86854e8890 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,6 +2,10 @@ 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 /** @@ -100,3 +104,100 @@ 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 dba7cac982..dd8debb4fe 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,99 +69,3 @@ 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 69037b21e3..3b23df15fd 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,6 +3,12 @@ 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.* @@ -161,3 +167,103 @@ 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 3b8cce77cf..9bd0909aa1 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,10 +1,6 @@ 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.* @@ -142,103 +138,3 @@ 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 - ) -)