Merge pull request #267 from antsupovsa/develop Add helper for InlineKeyboardButtonLoginURL
Syfaro syfaro@huefox.com
Wed, 10 Mar 2021 22:08:51 -0500
2 files changed,
26 insertions(+),
0 deletions(-)
M
helpers.go
→
helpers.go
@@ -673,6 +673,15 @@ CallbackData: &data,
} } +// 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, + } +} + // NewInlineKeyboardButtonURL creates an inline keyboard button with text // which goes to a URL. func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton {
M
helpers_test.go
→
helpers_test.go
@@ -161,6 +161,23 @@ t.Fail()
} } +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) { edit := NewEditMessageText(ChatID, ReplyToMessageID, "new text")