diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/CopyTextButtonData.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/CopyTextButtonData.kt new file mode 100644 index 0000000000..37daf998f5 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/CopyTextButtonData.kt @@ -0,0 +1,8 @@ +package dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons + +import kotlinx.serialization.Serializable + +@Serializable +data class CopyTextButtonData( + val text: String, +) \ No newline at end of file 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 252ffba5a6..665ef09579 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 @@ -142,11 +142,13 @@ data class URLInlineKeyboardButton( ) : InlineKeyboardButton /** - * Simple [url] button. Can be forwarded in any chat with message in case if it is the only one button in message + * `copy_text` button */ @Serializable data class CopyTextButton( - override val text: String + override val text: String, + @SerialName(copyTextField) + val data: CopyTextButtonData ) : InlineKeyboardButton /** 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 40cfc06ed8..68c11acf1b 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 @@ -37,11 +37,20 @@ inline fun loginInlineButton( ) = LoginURLInlineKeyboardButton(text, loginUrl) /** - * Creates [LoginURLInlineKeyboardButton] + * Creates [CopyTextButton] */ inline fun copyTextButton( - text: String -) = CopyTextButton(text) + text: String, + data: CopyTextButtonData +) = CopyTextButton(text, data) + +/** + * Creates [CopyTextButton] + */ +inline fun copyTextButton( + text: String, + data: String +) = copyTextButton(text, CopyTextButtonData(data)) /** * Creates [SwitchInlineQueryCurrentChatInlineKeyboardButton] 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 2106d3f897..f3a90dee90 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 @@ -93,14 +93,26 @@ inline fun InlineKeyboardRowBuilder.loginButton( ) = add(LoginURLInlineKeyboardButton(text, loginUrl)) /** - * Creates and put [LoginURLInlineKeyboardButton] + * Creates [CopyTextButton] * * @see inlineKeyboard * @see InlineKeyboardBuilder.row */ inline fun InlineKeyboardRowBuilder.copyTextButton( - text: String -) = add(CopyTextButton(text)) + text: String, + data: CopyTextButtonData +) = add(CopyTextButton(text, data)) + +/** + * Creates [CopyTextButton] + * + * @see inlineKeyboard + * @see InlineKeyboardBuilder.row + */ +inline fun InlineKeyboardRowBuilder.copyTextButton( + text: String, + data: String +) = copyTextButton(text, CopyTextButtonData(data)) /** * Creates and put [SwitchInlineQueryCurrentChatInlineKeyboardButton]