Merge pull request #267 from antsupovsa/develop

Add helper for InlineKeyboardButtonLoginURL
bot-api-6.1
Syfaro 2021-03-10 22:08:51 -05:00 committed by GitHub
commit d0e1dfd8c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -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 // NewInlineKeyboardButtonURL creates an inline keyboard button with text
// which goes to a URL. // which goes to a URL.
func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton { func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton {

View File

@ -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) { func TestNewEditMessageText(t *testing.T) {
edit := NewEditMessageText(ChatID, ReplyToMessageID, "new text") edit := NewEditMessageText(ChatID, ReplyToMessageID, "new text")