diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | include/tgbot/types/InlineKeyboardButton.h | 6 | ||||
-rw-r--r-- | include/tgbot/types/LoginUrl.h | 45 | ||||
-rw-r--r-- | include/tgbot/types/Message.h | 6 | ||||
-rw-r--r-- | src/TgTypeParser.cpp | 3 |
6 files changed, 62 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 411535d..e19b925 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ set(SRC_LIST src/tools/StringTools.cpp src/types/InlineQueryResult.cpp src/types/InputFile.cpp - include/tgbot/types/Poll.h include/tgbot/types/PollOption.h) + include/tgbot/types/Poll.h include/tgbot/types/PollOption.h include/tgbot/types/LoginUrl.h) # libs ## threads @@ -20,7 +20,7 @@ Documentation is located [here](http://reo7sp.github.io/tgbot-cpp). ## State - [x] Bot API 3.0 ~ 3.6 -- [x] Bot API 4.0 ~ 4.2 (Implemented all APIs except 'Telegram Passport') +- [x] Bot API 4.0 ~ 4.3 (Implemented all APIs except 'Telegram Passport') ## Sample diff --git a/include/tgbot/types/InlineKeyboardButton.h b/include/tgbot/types/InlineKeyboardButton.h index 4b83087..f02d788 100644 --- a/include/tgbot/types/InlineKeyboardButton.h +++ b/include/tgbot/types/InlineKeyboardButton.h @@ -9,6 +9,7 @@ #include <memory> #include "tgbot/types/CallbackGame.h" +#include "tgbot/types/LoginUrl.h" namespace TgBot { @@ -32,6 +33,11 @@ public: std::string url; /** + * @brief Optional. An HTTP URL used to automatically authorize the user. + */ + LoginUrl::Ptr loginUrl; + + /** * @brief Optional. Data to be sent in a callback query to the bot when button is pressed. */ std::string callbackData; diff --git a/include/tgbot/types/LoginUrl.h b/include/tgbot/types/LoginUrl.h new file mode 100644 index 0000000..1627399 --- /dev/null +++ b/include/tgbot/types/LoginUrl.h @@ -0,0 +1,45 @@ +// +// Created by alexandrumarcel on 19.11.2019. +// + +#ifndef TGBOT_CPP_LOGINURL_H +#define TGBOT_CPP_LOGINURL_H + +#include <memory> +#include <string> +#include <vector> + + +namespace TgBot{ + /** + * @brief This object represents a Poll. + * + * @ingroup types + */ + class LoginUrl{ + public: + typedef std::shared_ptr<LoginUrl> Ptr; + + /** + * @brief UAn HTTP URL to be opened with user authorization data added to the query string when the button is pressed.. + */ + std::string url; + + /** + * @brief Optional. New text of the button in forwarded messages. + */ + std::string forward_text; + + /** + * @brief Optional. Username of a bot, which will be used for user authorization. + */ + std::string bot_username; + + /** + * @brief Optional. Pass True to request the permission for your bot to send messages to the user. + */ + bool request_write_access; + }; +} + +#endif //TGBOT_CPP_LOGINURL_H diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h index 4b7ce59..9e831bc 100644 --- a/include/tgbot/types/Message.h +++ b/include/tgbot/types/Message.h @@ -45,6 +45,7 @@ #include "tgbot/types/Voice.h" #include "tgbot/types/Invoice.h" #include "tgbot/types/SuccessfulPayment.h" +#include "tgbot/types/InlineKeyboardMarkup.h" namespace TgBot { @@ -278,6 +279,11 @@ public: * @brief Optional. The domain name of the website on which the user has logged in. */ std::string connectedWebsite; + + /** + * @brief Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. + */ + InlineKeyboardMarkup::Ptr replyMarkup; }; } diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp index 528993b..02fed47 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -179,6 +179,7 @@ Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const { result->invoice = tryParseJson<Invoice>(&TgTypeParser::parseJsonAndGetInvoice, data, "invoice"); result->successfulPayment = tryParseJson<SuccessfulPayment>(&TgTypeParser::parseJsonAndGetSuccessfulPayment, data, "successful_payment"); result->connectedWebsite = data.get("connected_website", ""); + result->replyMarkup = tryParseJson<InlineKeyboardMarkup>(&TgTypeParser::parseJsonAndGetInlineKeyboardMarkup, data, "reply_markup"); return result; } @@ -228,6 +229,7 @@ string TgTypeParser::parseMessage(const Message::Ptr& object) const { appendToJson(result, "connected_website", object->connectedWebsite); appendToJson(result, "invoice", parseInvoice(object->invoice)); appendToJson(result, "successful_payment", parseSuccessfulPayment(object->successfulPayment)); + appendToJson(result, "reply_markup", parseReplyKeyboardMarkup(object->replyMarkup)); removeLastComma(result); result += '}'; return result; @@ -1759,6 +1761,7 @@ InlineKeyboardButton::Ptr TgTypeParser::parseJsonAndGetInlineKeyboardButton(cons auto result(make_shared<InlineKeyboardButton>()); result->text = data.get<string>("text"); result->url = data.get<string>("url", ""); + result->loginUrl = make_shared<LoginUrl>(); result->callbackData = data.get<string>("callback_data", ""); result->switchInlineQuery = data.get<string>("switch_inline_query", ""); result->switchInlineQueryCurrentChat = data.get<string>("switch_inline_query_current_chat", ""); |