Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:‌ Add CopyText button to InlineKeyboardButton for text copy functionality #758

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: &copyText,
}
}

// NewCallback creates a new callback message.
func NewCallback(id, text string) CallbackConfig {
return CallbackConfig{
Expand Down
10 changes: 10 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down