1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-24 02:58:43 +00:00

fixes in copyText keyboard buttons

This commit is contained in:
InsanusMokrassar 2024-11-01 23:10:47 +06:00
parent 479923a04a
commit 636c01acb9
4 changed files with 39 additions and 8 deletions

View File

@ -0,0 +1,8 @@
package dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons
import kotlinx.serialization.Serializable
@Serializable
data class CopyTextButtonData(
val text: String,
)

View File

@ -142,11 +142,13 @@ data class URLInlineKeyboardButton(
) : InlineKeyboardButton ) : 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 @Serializable
data class CopyTextButton( data class CopyTextButton(
override val text: String override val text: String,
@SerialName(copyTextField)
val data: CopyTextButtonData
) : InlineKeyboardButton ) : InlineKeyboardButton
/** /**

View File

@ -37,11 +37,20 @@ inline fun loginInlineButton(
) = LoginURLInlineKeyboardButton(text, loginUrl) ) = LoginURLInlineKeyboardButton(text, loginUrl)
/** /**
* Creates [LoginURLInlineKeyboardButton] * Creates [CopyTextButton]
*/ */
inline fun copyTextButton( inline fun copyTextButton(
text: String text: String,
) = CopyTextButton(text) data: CopyTextButtonData
) = CopyTextButton(text, data)
/**
* Creates [CopyTextButton]
*/
inline fun copyTextButton(
text: String,
data: String
) = copyTextButton(text, CopyTextButtonData(data))
/** /**
* Creates [SwitchInlineQueryCurrentChatInlineKeyboardButton] * Creates [SwitchInlineQueryCurrentChatInlineKeyboardButton]

View File

@ -93,14 +93,26 @@ inline fun InlineKeyboardRowBuilder.loginButton(
) = add(LoginURLInlineKeyboardButton(text, loginUrl)) ) = add(LoginURLInlineKeyboardButton(text, loginUrl))
/** /**
* Creates and put [LoginURLInlineKeyboardButton] * Creates [CopyTextButton]
* *
* @see inlineKeyboard * @see inlineKeyboard
* @see InlineKeyboardBuilder.row * @see InlineKeyboardBuilder.row
*/ */
inline fun InlineKeyboardRowBuilder.copyTextButton( inline fun InlineKeyboardRowBuilder.copyTextButton(
text: String text: String,
) = add(CopyTextButton(text)) 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] * Creates and put [SwitchInlineQueryCurrentChatInlineKeyboardButton]