Add helper for InlineKeyboardButtonLoginURL
parent
ffe77fb717
commit
43b3f0ace1
11
helpers.go
11
helpers.go
|
@ -679,7 +679,16 @@ func NewInlineKeyboardButtonData(text, data string) InlineKeyboardButton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewInlineKeyboardButtonURL creates an inline keyboard button with text
|
// NewInlineKeyboardButtonLoginURL creates an inline keyboard button with text
|
||||||
|
// which goes to a LoginURL.
|
||||||
|
func NewInlineKeyboardButtonLoginURL(text string, loginUrl LoginURL) InlineKeyboardButton {
|
||||||
|
return InlineKeyboardButton{
|
||||||
|
Text: text,
|
||||||
|
LoginURL: &loginUrl,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewInlineKeyboardButtonLoginURL creates an inline keyboard button with text
|
||||||
// which goes to a URL.
|
// which goes to a URL.
|
||||||
func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton {
|
func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton {
|
||||||
return InlineKeyboardButton{
|
return InlineKeyboardButton{
|
||||||
|
|
|
@ -136,6 +136,23 @@ func TestNewInlineQueryResultLocation(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewInlineKeyboardButtonLoginURL(t *testing.T) {
|
||||||
|
result := NewInlineKeyboardButtonLoginURL("text", LoginURL{
|
||||||
|
URL: "url",
|
||||||
|
ForwardText: "ForwardText",
|
||||||
|
BotUsername: "username",
|
||||||
|
RequestWriteAccess: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
if result.Text != "text" ||
|
||||||
|
result.LoginURL.URL != "url" ||
|
||||||
|
result.LoginURL.ForwardText != "ForwardText" ||
|
||||||
|
result.LoginURL.BotUsername != "username" ||
|
||||||
|
result.LoginURL.RequestWriteAccess != false {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestNewEditMessageText(t *testing.T) {
|
func TestNewEditMessageText(t *testing.T) {
|
||||||
edit := NewEditMessageText(ChatID, ReplyToMessageID, "new text")
|
edit := NewEditMessageText(ChatID, ReplyToMessageID, "new text")
|
||||||
|
|
||||||
|
|
6
types.go
6
types.go
|
@ -476,9 +476,9 @@ type InlineKeyboardButton struct {
|
||||||
// LoginURL is the parameters for the login inline keyboard button type.
|
// LoginURL is the parameters for the login inline keyboard button type.
|
||||||
type LoginURL struct {
|
type LoginURL struct {
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
ForwardText string `json:"forward_text"`
|
ForwardText string `json:"forward_text,omitempty"`
|
||||||
BotUsername string `json:"bot_username"`
|
BotUsername string `json:"bot_username,omitempty"`
|
||||||
RequestWriteAccess bool `json:"request_write_access"`
|
RequestWriteAccess bool `json:"request_write_access,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CallbackQuery is data sent when a keyboard button with callback data
|
// CallbackQuery is data sent when a keyboard button with callback data
|
||||||
|
|
Loading…
Reference in New Issue