Skip to content

Commit

Permalink
Merge pull request #267 from antsupovsa/develop
Browse files Browse the repository at this point in the history
Add helper for InlineKeyboardButtonLoginURL
  • Loading branch information
Syfaro authored Mar 11, 2021
2 parents 53d566b + 47a0a16 commit d0e1dfd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
17 changes: 17 additions & 0 deletions helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit d0e1dfd

Please sign in to comment.