all repos — telegram-bot-api @ d0e1dfd8c604cab666e10279936e80acc0953f39

Golang bindings for the Telegram Bot API

Merge pull request #267 from antsupovsa/develop

Add helper for InlineKeyboardButtonLoginURL
Syfaro syfaro@huefox.com
Wed, 10 Mar 2021 22:08:51 -0500
commit

d0e1dfd8c604cab666e10279936e80acc0953f39

parent

53d566ba56fb4b9925de3aeb74726e870f8d2e1d

2 files changed, 26 insertions(+), 0 deletions(-)

jump to
M helpers.gohelpers.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.gohelpers_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")