From 340b51ef13cef4fc0e8a3a927b48b95245390054 Mon Sep 17 00:00:00 2001 From: Poori Date: Sat, 30 Nov 2024 17:52:16 +0330 Subject: [PATCH] =?UTF-8?q?feat:=E2=80=8C=20Add=20CopyText=20button=20to?= =?UTF-8?q?=20InlineKeyboardButton=20for=20text=20copy=20functionality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helpers.go | 9 +++++++++ types.go | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/helpers.go b/helpers.go index 3a0e8187..a8ad392b 100644 --- a/helpers.go +++ b/helpers.go @@ -745,6 +745,15 @@ func NewInlineKeyboardMarkup(rows ...[]InlineKeyboardButton) InlineKeyboardMarku } } +// NewInlineKeyboardButtonCopyText creates an inline keyboard button with text +// that copies a verification code or other specified text to the clipboard. +func NewInlineKeyboardButtonCopyText(text string, copyText CopyTextButton) InlineKeyboardButton { + return InlineKeyboardButton{ + Text: text, + CopyText: ©Text, + } +} + // NewCallback creates a new callback message. func NewCallback(id, text string) CallbackConfig { return CallbackConfig{ diff --git a/types.go b/types.go index 36c174b8..50c01d23 100644 --- a/types.go +++ b/types.go @@ -1416,6 +1416,11 @@ type InlineKeyboardButton struct { // // optional SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"` + // CopyText represents an inline keyboard button that copies a verification code + // or other specified text to the clipboard. + // + // optional + CopyText *CopyTextButton `json:"copy_text,omitempty"` // CallbackGame description of the game that will be launched when the user presses the button. // // optional @@ -2113,6 +2118,11 @@ type GameHighScore struct { // CallbackGame is for starting a game in an inline keyboard button. type CallbackGame struct{} +// CopyTextButton is for copy text in an inline keyboard button. +type CopyTextButton struct { + Text string `json:"text"` +} + // WebhookInfo is information about a currently set webhook. type WebhookInfo struct { // URL webhook URL, may be empty if webhook is not set up.