From e22b5f4f6451947325d230b268840e4955b19e6b Mon Sep 17 00:00:00 2001 From: Mikhail Borovikov Date: Sun, 17 Apr 2022 22:54:30 +0700 Subject: [PATCH] Added web_app fields for the buttons --- callbacks.go | 19 +++++++++++++------ options.go | 7 ++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/callbacks.go b/callbacks.go index 23894a4..f511b5d 100644 --- a/callbacks.go +++ b/callbacks.go @@ -80,12 +80,13 @@ type InlineButton struct { // It will be used as a callback endpoint. Unique string `json:"unique,omitempty"` - Text string `json:"text"` - URL string `json:"url,omitempty"` - Data string `json:"callback_data,omitempty"` - InlineQuery string `json:"switch_inline_query,omitempty"` - InlineQueryChat string `json:"switch_inline_query_current_chat"` - Login *Login `json:"login_url,omitempty"` + Text string `json:"text"` + URL string `json:"url,omitempty"` + Data string `json:"callback_data,omitempty"` + InlineQuery string `json:"switch_inline_query,omitempty"` + InlineQueryChat string `json:"switch_inline_query_current_chat"` + WebApp *WebAppInfo `json:"web_app,omitempty"` + Login *Login `json:"login_url,omitempty"` } // With returns a copy of the button with data. @@ -129,6 +130,12 @@ type Login struct { WriteAccess bool `json:"request_write_access,omitempty"` } +// WebAppInfo represents a parameter of the inline keyboard button +// or the keyboard button used to launch Web App. +type WebAppInfo struct { + URL string `json:"url"` +} + // MarshalJSON implements json.Marshaler interface. // It needed to avoid InlineQueryChat and Login fields conflict. // If you have Login field in your button, InlineQueryChat must be skipped. diff --git a/options.go b/options.go index 1f5a0c6..5ad30d3 100644 --- a/options.go +++ b/options.go @@ -169,9 +169,10 @@ func (r *ReplyMarkup) copy() *ReplyMarkup { type ReplyButton struct { Text string `json:"text"` - Contact bool `json:"request_contact,omitempty"` - Location bool `json:"request_location,omitempty"` - Poll PollType `json:"request_poll,omitempty"` + Contact bool `json:"request_contact,omitempty"` + Location bool `json:"request_location,omitempty"` + Poll PollType `json:"request_poll,omitempty"` + WebApp WebAppInfo `json:"request_web_app,omitempty"` } // MarshalJSON implements json.Marshaler. It allows to pass