diff --git a/helpers.go b/helpers.go index 3dabe11..6247462 100644 --- a/helpers.go +++ b/helpers.go @@ -722,6 +722,15 @@ func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton { } } +// NewInlineKeyboardButtonLoginURL creates an inline keyboard button with text +// which allows user to login into provided LoginURL. +func NewInlineKeyboardButtonLoginURL(text string, loginURL *LoginURL) InlineKeyboardButton { + return InlineKeyboardButton{ + Text: text, + LoginURL: loginURL, + } +} + // NewInlineKeyboardButtonSwitch creates an inline keyboard button with // text which allows the user to switch to a chat or return to a chat. func NewInlineKeyboardButtonSwitch(text, sw string) InlineKeyboardButton { diff --git a/types.go b/types.go index 52cb36c..d56dc70 100644 --- a/types.go +++ b/types.go @@ -135,42 +135,43 @@ type Message struct { From *User `json:"from"` // optional Date int `json:"date"` Chat *Chat `json:"chat"` - ForwardFrom *User `json:"forward_from"` // optional - ForwardFromChat *Chat `json:"forward_from_chat"` // optional - ForwardFromMessageID int `json:"forward_from_message_id"` // optional - ForwardDate int `json:"forward_date"` // optional - ReplyToMessage *Message `json:"reply_to_message"` // optional - EditDate int `json:"edit_date"` // optional - Text string `json:"text"` // optional - Entities *[]MessageEntity `json:"entities"` // optional - CaptionEntities *[]MessageEntity `json:"caption_entities"` // optional - Audio *Audio `json:"audio"` // optional - Document *Document `json:"document"` // optional - Animation *ChatAnimation `json:"animation"` // optional - Game *Game `json:"game"` // optional - Photo *[]PhotoSize `json:"photo"` // optional - Sticker *Sticker `json:"sticker"` // optional - Video *Video `json:"video"` // optional - VideoNote *VideoNote `json:"video_note"` // optional - Voice *Voice `json:"voice"` // optional - Caption string `json:"caption"` // optional - Contact *Contact `json:"contact"` // optional - Location *Location `json:"location"` // optional - Venue *Venue `json:"venue"` // optional - NewChatMembers *[]User `json:"new_chat_members"` // optional - LeftChatMember *User `json:"left_chat_member"` // optional - NewChatTitle string `json:"new_chat_title"` // optional - NewChatPhoto *[]PhotoSize `json:"new_chat_photo"` // optional - DeleteChatPhoto bool `json:"delete_chat_photo"` // optional - GroupChatCreated bool `json:"group_chat_created"` // optional - SuperGroupChatCreated bool `json:"supergroup_chat_created"` // optional - ChannelChatCreated bool `json:"channel_chat_created"` // optional - MigrateToChatID int64 `json:"migrate_to_chat_id"` // optional - MigrateFromChatID int64 `json:"migrate_from_chat_id"` // optional - PinnedMessage *Message `json:"pinned_message"` // optional - Invoice *Invoice `json:"invoice"` // optional - SuccessfulPayment *SuccessfulPayment `json:"successful_payment"` // optional - PassportData *PassportData `json:"passport_data,omitempty"` // optional + ForwardFrom *User `json:"forward_from"` // optional + ForwardFromChat *Chat `json:"forward_from_chat"` // optional + ForwardFromMessageID int `json:"forward_from_message_id"` // optional + ForwardDate int `json:"forward_date"` // optional + ReplyToMessage *Message `json:"reply_to_message"` // optional + EditDate int `json:"edit_date"` // optional + Text string `json:"text"` // optional + Entities *[]MessageEntity `json:"entities"` // optional + CaptionEntities *[]MessageEntity `json:"caption_entities"` // optional + Audio *Audio `json:"audio"` // optional + Document *Document `json:"document"` // optional + Animation *ChatAnimation `json:"animation"` // optional + Game *Game `json:"game"` // optional + Photo *[]PhotoSize `json:"photo"` // optional + Sticker *Sticker `json:"sticker"` // optional + Video *Video `json:"video"` // optional + VideoNote *VideoNote `json:"video_note"` // optional + Voice *Voice `json:"voice"` // optional + Caption string `json:"caption"` // optional + Contact *Contact `json:"contact"` // optional + Location *Location `json:"location"` // optional + Venue *Venue `json:"venue"` // optional + NewChatMembers *[]User `json:"new_chat_members"` // optional + LeftChatMember *User `json:"left_chat_member"` // optional + NewChatTitle string `json:"new_chat_title"` // optional + NewChatPhoto *[]PhotoSize `json:"new_chat_photo"` // optional + DeleteChatPhoto bool `json:"delete_chat_photo"` // optional + GroupChatCreated bool `json:"group_chat_created"` // optional + SuperGroupChatCreated bool `json:"supergroup_chat_created"` // optional + ChannelChatCreated bool `json:"channel_chat_created"` // optional + MigrateToChatID int64 `json:"migrate_to_chat_id"` // optional + MigrateFromChatID int64 `json:"migrate_from_chat_id"` // optional + PinnedMessage *Message `json:"pinned_message"` // optional + Invoice *Invoice `json:"invoice"` // optional + SuccessfulPayment *SuccessfulPayment `json:"successful_payment"` // optional + PassportData *PassportData `json:"passport_data,omitempty"` // optional + ConnectedWebsite *string `json:"connected_website,omitempty"` // optional } // Time converts the message timestamp into a Time. @@ -473,6 +474,7 @@ type InlineKeyboardMarkup struct { type InlineKeyboardButton struct { Text string `json:"text"` URL *string `json:"url,omitempty"` // optional + LoginURL *LoginURL `json:"login_url,omitempty"` // optional CallbackData *string `json:"callback_data,omitempty"` // optional SwitchInlineQuery *string `json:"switch_inline_query,omitempty"` // optional SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"` // optional @@ -572,6 +574,14 @@ type WebhookInfo struct { LastErrorMessage string `json:"last_error_message"` // optional } +// LoginURL contains fields that allows user to login to webpage +type LoginURL struct { + URL string `json:"url"` + ForwardText *string `json:"forward_text,omitempty"` + BotUsername *string `json:"bot_username,omitempty"` + RequestWriteAcces *bool `json:"request_write_access,omitempty"` +} + // IsSet returns true if a webhook is currently set. func (info WebhookInfo) IsSet() bool { return info.URL != ""