Skip to content

Commit d0e1dfd

Browse files
authored
Merge pull request #267 from antsupovsa/develop
Add helper for InlineKeyboardButtonLoginURL
2 parents 53d566b + 47a0a16 commit d0e1dfd

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

helpers.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,15 @@ func NewInlineKeyboardButtonData(text, data string) InlineKeyboardButton {
673673
}
674674
}
675675

676+
// NewInlineKeyboardButtonLoginURL creates an inline keyboard button with text
677+
// which goes to a LoginURL.
678+
func NewInlineKeyboardButtonLoginURL(text string, loginURL LoginURL) InlineKeyboardButton {
679+
return InlineKeyboardButton{
680+
Text: text,
681+
LoginURL: &loginURL,
682+
}
683+
}
684+
676685
// NewInlineKeyboardButtonURL creates an inline keyboard button with text
677686
// which goes to a URL.
678687
func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton {

helpers_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,23 @@ func TestNewInlineQueryResultLocation(t *testing.T) {
161161
}
162162
}
163163

164+
func TestNewInlineKeyboardButtonLoginURL(t *testing.T) {
165+
result := NewInlineKeyboardButtonLoginURL("text", LoginURL{
166+
URL: "url",
167+
ForwardText: "ForwardText",
168+
BotUsername: "username",
169+
RequestWriteAccess: false,
170+
})
171+
172+
if result.Text != "text" ||
173+
result.LoginURL.URL != "url" ||
174+
result.LoginURL.ForwardText != "ForwardText" ||
175+
result.LoginURL.BotUsername != "username" ||
176+
result.LoginURL.RequestWriteAccess != false {
177+
t.Fail()
178+
}
179+
}
180+
164181
func TestNewEditMessageText(t *testing.T) {
165182
edit := NewEditMessageText(ChatID, ReplyToMessageID, "new text")
166183

0 commit comments

Comments
 (0)