From 1ac1b9d32ee1988af1b0aab00b0c1a652d341ab0 Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Tue, 11 Jun 2019 11:48:59 +0500 Subject: [PATCH] :sparkles: Added LoginURL support See: https://core.telegram.org/bots/api#may-31-2019 --- types.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/types.go b/types.go index 0f332ad..d62cf08 100644 --- a/types.go +++ b/types.go @@ -321,6 +321,9 @@ type ( // Telegram Passport data PassportData *PassportData `json:"passport_data,omitempty"` + + // Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. + ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` } // MessageEntity represents one special entity in a text message. For @@ -648,6 +651,10 @@ type ( // HTTP url to be opened when button is pressed URL string `json:"url,omitempty"` + // An HTTP URL used to automatically authorize the user. Can be used as a replacement for the Telegram + // Login Widget. + LoginURL *LoginURL `json:"login_url,omitempty"` + // Data to be sent in a callback query to the bot when button is pressed, // 1-64 bytes CallbackData string `json:"callback_data,omitempty"` @@ -686,6 +693,29 @@ type ( Pay bool `json:"pay,omitempty"` } + // LoginURL represents a parameter of the inline keyboard button used to automatically authorize a user. + LoginURL struct { + // An HTTP URL to be opened with user authorization data added to the query string when the button is + // pressed. If the user refuses to provide authorization data, the original URL without information + // about the user will be opened. The data added is the same as described in Receiving authorization + // data. + // + // NOTE: You must always check the hash of the received data to verify the authentication and the + // integrity of the data as described in Checking authorization. + URL string `json:"url"` + + // New text of the button in forwarded messages. + ForwardText string `json:"forward_text,omitempty"` + + // Username of a bot, which will be used for user authorization. See Setting up a bot for more + // details. If not specified, the current bot's username will be assumed. The url's domain must be the + // same as the domain linked with the bot. See Linking your domain to the bot for more details. + BotUsername string `json:"bot_username,omitempty"` + + // Pass true to request the permission for your bot to send messages to the user. + RequestWriteAccess bool `json:"request_write_access,omitempty"` + } + // CallbackQuery represents an incoming callback query from a callback button // in an inline keyboard. If the button that originated the query was // attached to a message sent by the bot, the field message will be present.