diff --git a/helpers.go b/helpers.go index 637ca98..7e22b67 100644 --- a/helpers.go +++ b/helpers.go @@ -673,6 +673,15 @@ func NewInlineKeyboardButtonData(text, data string) InlineKeyboardButton { } } +// 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 { diff --git a/helpers_test.go b/helpers_test.go index fdeaf80..3739892 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -161,6 +161,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) { edit := NewEditMessageText(ChatID, ReplyToMessageID, "new text")