summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorllnulldisk <48621230+llnulldisk@users.noreply.github.com>2024-04-15 01:24:12 +0200
committerllnulldisk <48621230+llnulldisk@users.noreply.github.com>2024-04-15 01:24:12 +0200
commitfbeb025e21fad2fa1fb6cd5ae186eabf9a349091 (patch)
tree032c992390707b7f68c0e5259c9a23d74ec8553f
parent38258eb91f752222e1e64f0499a408643a107149 (diff)
Update to Bot API 6.7
-rw-r--r--README.md6
-rw-r--r--include/tgbot/Api.h28
-rw-r--r--include/tgbot/TgTypeParser.h12
-rw-r--r--include/tgbot/types/BotName.h25
-rw-r--r--include/tgbot/types/ChatMemberUpdated.h8
-rw-r--r--include/tgbot/types/InlineKeyboardButton.h6
-rw-r--r--include/tgbot/types/InlineQueryResultsButton.h44
-rw-r--r--include/tgbot/types/InputSticker.h2
-rw-r--r--include/tgbot/types/KeyboardButtonRequestChat.h2
-rw-r--r--include/tgbot/types/KeyboardButtonRequestUser.h2
-rw-r--r--include/tgbot/types/SwitchInlineQueryChosenChat.h46
-rw-r--r--include/tgbot/types/WriteAccessAllowed.h10
-rw-r--r--src/Api.cpp42
-rw-r--r--src/TgTypeParser.cpp74
14 files changed, 282 insertions, 25 deletions
diff --git a/README.md b/README.md
index 46df671..5b4bb72 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ Documentation is located [here](http://reo7sp.github.io/tgbot-cpp).
## State
-- [x] Telegram Bot API 6.6
+- [x] Telegram Bot API 6.7
- [ ] [Deep Linking](https://core.telegram.org/bots/features#deep-linking)
@@ -105,8 +105,8 @@ Taken from [Vcpkg - Quick Start: Windows](https://github.com/Microsoft/vcpkg/#qu
Prerequisites:
- Windows 7 or newer
-- Git
-- Visual Studio 2015 Update 3 or greater with the English language pack
+- [Git][https://git-scm.com/downloads]
+- [Visual Studio][https://visualstudio.microsoft.com] 2015 Update 3 or greater with the English language pack
First, download and bootstrap vcpkg itself; it can be installed anywhere, but generally we recommend using vcpkg as a submodule for CMake projects, and installing it globally for Visual Studio projects. We recommend somewhere like `C:\src\vcpkg` or `C:\dev\vcpkg`, since otherwise you may run into path issues for some port build systems.
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index a30a9fe..5efe50f 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -1412,6 +1412,26 @@ public:
const std::string& languageCode = "") const;
/**
+ * @brief Use this method to change the bot's name.
+ *
+ * @param name Optional. New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.
+ * @param languageCode Optional. A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.
+ *
+ * @return Returns True on success.
+ */
+ bool setMyName(const std::string& name = "",
+ const std::string& languageCode = "") const;
+
+ /**
+ * @brief Use this method to get the current bot name for the given user language.
+ *
+ * @param languageCode Optional. A two-letter ISO 639-1 language code or an empty string
+ *
+ * @return Returns BotName on success.
+ */
+ BotName::Ptr getMyName(const std::string& languageCode = "") const;
+
+ /**
* @brief Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
*
* @param description Optional. New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.
@@ -1815,10 +1835,9 @@ public:
* @param inlineQueryId Unique identifier for the answered query
* @param results A JSON-serialized array of results for the inline query
* @param cacheTime Optional. The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
- * @param isPersonal Optional. Pass True if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
+ * @param isPersonal Optional. Pass True if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query.
* @param nextOffset Optional. Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes.
- * @param switchPmText Optional. If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switchPmParameter
- * @param switchPmParameter Optional. Deep-linking parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed. Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer an InlineKeyboardMarkup button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.
+ * @param button Optional. A JSON-serialized object describing a button to be shown above inline query results
*
* @return On success, True is returned.
*/
@@ -1827,8 +1846,7 @@ public:
std::int32_t cacheTime = 300,
bool isPersonal = false,
const std::string& nextOffset = "",
- const std::string& switchPmText = "",
- const std::string& switchPmParameter = "") const;
+ InlineQueryResultsButton::Ptr button = nullptr) const;
/**
* @brief Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated.
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index 9f135fd..99a38a9 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -51,6 +51,7 @@
#include "tgbot/types/InlineKeyboardMarkup.h"
#include "tgbot/types/InlineKeyboardButton.h"
#include "tgbot/types/LoginUrl.h"
+#include "tgbot/types/SwitchInlineQueryChosenChat.h"
#include "tgbot/types/CallbackQuery.h"
#include "tgbot/types/ForceReply.h"
#include "tgbot/types/ChatPhoto.h"
@@ -77,6 +78,7 @@
#include "tgbot/types/BotCommandScopeChat.h"
#include "tgbot/types/BotCommandScopeChatAdministrators.h"
#include "tgbot/types/BotCommandScopeChatMember.h"
+#include "tgbot/types/BotName.h"
#include "tgbot/types/BotDescription.h"
#include "tgbot/types/BotShortDescription.h"
#include "tgbot/types/MenuButton.h"
@@ -95,6 +97,7 @@
#include "tgbot/types/MaskPosition.h"
#include "tgbot/types/InputSticker.h"
#include "tgbot/types/InlineQuery.h"
+#include "tgbot/types/InlineQueryResultsButton.h"
#include "tgbot/types/InlineQueryResult.h"
#include "tgbot/types/InlineQueryResultArticle.h"
#include "tgbot/types/InlineQueryResultPhoto.h"
@@ -316,6 +319,9 @@ public:
LoginUrl::Ptr parseJsonAndGetLoginUrl(const boost::property_tree::ptree& data) const;
std::string parseLoginUrl(const LoginUrl::Ptr& object) const;
+ SwitchInlineQueryChosenChat::Ptr parseJsonAndGetSwitchInlineQueryChosenChat(const boost::property_tree::ptree& data) const;
+ std::string parseSwitchInlineQueryChosenChat(const SwitchInlineQueryChosenChat::Ptr& object) const;
+
CallbackQuery::Ptr parseJsonAndGetCallbackQuery(const boost::property_tree::ptree& data) const;
std::string parseCallbackQuery(const CallbackQuery::Ptr& object) const;
@@ -394,6 +400,9 @@ public:
BotCommandScopeChatMember::Ptr parseJsonAndGetBotCommandScopeChatMember(const boost::property_tree::ptree& data) const;
std::string parseBotCommandScopeChatMember(const BotCommandScopeChatMember::Ptr& object) const;
+ BotName::Ptr parseJsonAndGetBotName(const boost::property_tree::ptree& data) const;
+ std::string parseBotName(const BotName::Ptr& object) const;
+
BotDescription::Ptr parseJsonAndGetBotDescription(const boost::property_tree::ptree& data) const;
std::string parseBotDescription(const BotDescription::Ptr& object) const;
@@ -448,6 +457,9 @@ public:
InlineQuery::Ptr parseJsonAndGetInlineQuery(const boost::property_tree::ptree& data) const;
std::string parseInlineQuery(const InlineQuery::Ptr& object) const;
+ InlineQueryResultsButton::Ptr parseJsonAndGetInlineQueryResultsButton(const boost::property_tree::ptree& data) const;
+ std::string parseInlineQueryResultsButton(const InlineQueryResultsButton::Ptr& object) const;
+
InlineQueryResult::Ptr parseJsonAndGetInlineQueryResult(const boost::property_tree::ptree& data) const;
std::string parseInlineQueryResult(const InlineQueryResult::Ptr& object) const;
diff --git a/include/tgbot/types/BotName.h b/include/tgbot/types/BotName.h
new file mode 100644
index 0000000..d89ee5c
--- /dev/null
+++ b/include/tgbot/types/BotName.h
@@ -0,0 +1,25 @@
+#ifndef TGBOT_BOTNAME_H
+#define TGBOT_BOTNAME_H
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents the bot's name.
+ *
+ * @ingroup types
+ */
+class BotName {
+public:
+ typedef std::shared_ptr<BotName> Ptr;
+
+ /**
+ * @brief The bot's name
+ */
+ std::string name;
+};
+}
+
+#endif //TGBOT_BOTNAME_H
diff --git a/include/tgbot/types/ChatMemberUpdated.h b/include/tgbot/types/ChatMemberUpdated.h
index 9d8ce2b..1d572e6 100644
--- a/include/tgbot/types/ChatMemberUpdated.h
+++ b/include/tgbot/types/ChatMemberUpdated.h
@@ -6,6 +6,7 @@
#include "tgbot/types/ChatMember.h"
#include "tgbot/types/ChatInviteLink.h"
+#include <cstdint>
#include <memory>
namespace TgBot {
@@ -33,7 +34,7 @@ public:
/**
* @brief Date the change was done in Unix time
*/
- std::uint32_t date;
+ std::uint64_t date;
/**
* @brief Previous information about the chat member
@@ -49,6 +50,11 @@ public:
* @brief Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only.
*/
ChatInviteLink::Ptr inviteLink;
+
+ /**
+ * @brief Optional. True, if the user joined the chat via a chat folder invite link
+ */
+ bool viaChatFolderInviteLink;
};
}
diff --git a/include/tgbot/types/InlineKeyboardButton.h b/include/tgbot/types/InlineKeyboardButton.h
index f216669..1f2e16f 100644
--- a/include/tgbot/types/InlineKeyboardButton.h
+++ b/include/tgbot/types/InlineKeyboardButton.h
@@ -3,6 +3,7 @@
#include "tgbot/types/WebAppInfo.h"
#include "tgbot/types/LoginUrl.h"
+#include "tgbot/types/SwitchInlineQueryChosenChat.h"
#include "tgbot/types/CallbackGame.h"
#include <memory>
@@ -67,6 +68,11 @@ public:
std::string switchInlineQueryCurrentChat;
/**
+ * @brief Optional. If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field
+ */
+ SwitchInlineQueryChosenChat::Ptr switchInlineQueryChosenChat;
+
+ /**
* @brief Optional. Description of the game that will be launched when the user presses the button.
*
* NOTE: This type of button must always be the first button in the first row.
diff --git a/include/tgbot/types/InlineQueryResultsButton.h b/include/tgbot/types/InlineQueryResultsButton.h
new file mode 100644
index 0000000..2343ff5
--- /dev/null
+++ b/include/tgbot/types/InlineQueryResultsButton.h
@@ -0,0 +1,44 @@
+#ifndef TGBOT_INLINEQUERYRESULTSBUTTON_H
+#define TGBOT_INLINEQUERYRESULTSBUTTON_H
+
+#include "tgbot/types/WebAppInfo.h"
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents a button to be shown above inline query results.
+ *
+ * You must use exactly one of the optional fields.
+ *
+ * @ingroup types
+ */
+class InlineQueryResultsButton {
+public:
+ typedef std::shared_ptr<InlineQueryResultsButton> Ptr;
+
+ /**
+ * @brief Label text on the button
+ */
+ std::string text;
+
+ /**
+ * @brief Optional. Description of the Web App (https://core.telegram.org/bots/webapps) that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method switchInlineQuery (https://core.telegram.org/bots/webapps#initializing-web-apps) inside the Web App.
+ */
+ WebAppInfo::Ptr webApp;
+
+ /**
+ * @brief Optional. Deep-linking (https://core.telegram.org/bots/features#deep-linking) parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.
+ *
+ * Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly.
+ * To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any.
+ * The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link.
+ * Once done, the bot can offer a switchInline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.
+ */
+ std::string startParameter;
+};
+}
+
+#endif //TGBOT_INLINEQUERYRESULTSBUTTON_H
diff --git a/include/tgbot/types/InputSticker.h b/include/tgbot/types/InputSticker.h
index f71107e..06dafd2 100644
--- a/include/tgbot/types/InputSticker.h
+++ b/include/tgbot/types/InputSticker.h
@@ -20,7 +20,7 @@ public:
/**
* @brief The added sticker.
- * Pass a fileId as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.
+ * Pass a fileId as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, upload a new one using multipart/form-data, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name.
* Animated and video stickers can't be uploaded via HTTP URL. https://core.telegram.org/bots/api#sending-files
*/
std::string sticker;
diff --git a/include/tgbot/types/KeyboardButtonRequestChat.h b/include/tgbot/types/KeyboardButtonRequestChat.h
index 9e446d8..92e858d 100644
--- a/include/tgbot/types/KeyboardButtonRequestChat.h
+++ b/include/tgbot/types/KeyboardButtonRequestChat.h
@@ -10,7 +10,9 @@ namespace TgBot {
/**
* @brief This object defines the criteria used to request a suitable chat.
+ *
* The identifier of the selected chat will be shared with the bot when the corresponding button is pressed.
+ * https://core.telegram.org/bots/features#chat-and-user-selection
*
* @ingroup types
*/
diff --git a/include/tgbot/types/KeyboardButtonRequestUser.h b/include/tgbot/types/KeyboardButtonRequestUser.h
index 3463e49..3ec6f16 100644
--- a/include/tgbot/types/KeyboardButtonRequestUser.h
+++ b/include/tgbot/types/KeyboardButtonRequestUser.h
@@ -8,7 +8,9 @@ namespace TgBot {
/**
* @brief This object defines the criteria used to request a suitable user.
+ *
* The identifier of the selected user will be shared with the bot when the corresponding button is pressed.
+ * https://core.telegram.org/bots/features#chat-and-user-selection
*
* @ingroup types
*/
diff --git a/include/tgbot/types/SwitchInlineQueryChosenChat.h b/include/tgbot/types/SwitchInlineQueryChosenChat.h
new file mode 100644
index 0000000..b0ecf2c
--- /dev/null
+++ b/include/tgbot/types/SwitchInlineQueryChosenChat.h
@@ -0,0 +1,46 @@
+#ifndef TGBOT_SWITCHINLINEQUERYCHOSENCHAT_H
+#define TGBOT_SWITCHINLINEQUERYCHOSENCHAT_H
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query.
+ *
+ * @ingroup types
+ */
+class SwitchInlineQueryChosenChat {
+
+public:
+ typedef std::shared_ptr<SwitchInlineQueryChosenChat> Ptr;
+
+ /**
+ * @brief Optional. The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted
+ */
+ std::string query;
+
+ /**
+ * @brief Optional. True, if private chats with users can be chosen
+ */
+ bool allowUserChats;
+
+ /**
+ * @brief Optional. True, if private chats with bots can be chosen
+ */
+ bool allowBotChats;
+
+ /**
+ * @brief Optional. True, if group and supergroup chats can be chosen
+ */
+ bool allowGroupChats;
+
+ /**
+ * @brief Optional. True, if channel chats can be chosen
+ */
+ bool allowChannelChats;
+};
+}
+
+#endif //TGBOT_SWITCHINLINEQUERYCHOSENCHAT_H
diff --git a/include/tgbot/types/WriteAccessAllowed.h b/include/tgbot/types/WriteAccessAllowed.h
index d01aa31..e3138df 100644
--- a/include/tgbot/types/WriteAccessAllowed.h
+++ b/include/tgbot/types/WriteAccessAllowed.h
@@ -2,19 +2,23 @@
#define TGBOT_WRITEACCESSALLOWED_H
#include <memory>
+#include <string>
namespace TgBot {
/**
- * @brief This object represents a service message about a user allowing a bot added to the attachment menu to write messages.
- *
- * Currently holds no information.
+ * @brief This object represents a service message about a user allowing a bot to write messages after adding the bot to the attachment menu or launching a Web App from a link.
*
* @ingroup types
*/
class WriteAccessAllowed {
public:
typedef std::shared_ptr<WriteAccessAllowed> Ptr;
+
+ /**
+ * @brief Optional. Name of the Web App which was launched from a link
+ */
+ std::string webAppName;
};
}
diff --git a/src/Api.cpp b/src/Api.cpp
index bb0ac45..8a91aee 100644
--- a/src/Api.cpp
+++ b/src/Api.cpp
@@ -1736,6 +1736,32 @@ std::vector<BotCommand::Ptr> Api::getMyCommands(BotCommandScope::Ptr scope,
return _tgTypeParser.parseJsonAndGetArray<BotCommand>(&TgTypeParser::parseJsonAndGetBotCommand, sendRequest("getMyCommands", args));
}
+bool Api::setMyName(const std::string& name,
+ const std::string& languageCode) const {
+ std::vector<HttpReqArg> args;
+ args.reserve(2);
+
+ if (!name.empty()) {
+ args.emplace_back("name", name);
+ }
+ if (!languageCode.empty()) {
+ args.emplace_back("language_code", languageCode);
+ }
+
+ return sendRequest("setMyName", args).get<bool>("", false);
+}
+
+BotName::Ptr Api::getMyName(const std::string& languageCode) const {
+ std::vector<HttpReqArg> args;
+ args.reserve(1);
+
+ if (!languageCode.empty()) {
+ args.emplace_back("language_code", languageCode);
+ }
+
+ return _tgTypeParser.parseJsonAndGetBotName(sendRequest("getMyName", args));
+}
+
bool Api::setMyDescription(const std::string& description,
const std::string& languageCode) const {
std::vector<HttpReqArg> args;
@@ -2271,27 +2297,23 @@ bool Api::answerInlineQuery(const std::string& inlineQueryId,
std::int32_t cacheTime,
bool isPersonal,
const std::string& nextOffset,
- const std::string& switchPmText,
- const std::string& switchPmParameter) const {
+ InlineQueryResultsButton::Ptr button) const {
std::vector<HttpReqArg> args;
- args.reserve(7);
+ args.reserve(6);
args.emplace_back("inline_query_id", inlineQueryId);
args.emplace_back("results", _tgTypeParser.parseArray<InlineQueryResult>(&TgTypeParser::parseInlineQueryResult, results));
- if (cacheTime) {
+ if (cacheTime != 300) {
args.emplace_back("cache_time", cacheTime);
}
- if (isPersonal) {
+ if (isPersonal != false) {
args.emplace_back("is_personal", isPersonal);
}
if (!nextOffset.empty()) {
args.emplace_back("next_offset", nextOffset);
}
- if (!switchPmText.empty()) {
- args.emplace_back("switch_pm_text", switchPmText);
- }
- if (!switchPmParameter.empty()) {
- args.emplace_back("switch_pm_parameter", switchPmParameter);
+ if (button != nullptr) {
+ args.emplace_back("button", _tgTypeParser.parseInlineQueryResultsButton(button));
}
return sendRequest("answerInlineQuery", args).get<bool>("", false);
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp
index efd1c08..76a4add 100644
--- a/src/TgTypeParser.cpp
+++ b/src/TgTypeParser.cpp
@@ -1109,6 +1109,7 @@ std::string TgTypeParser::parseChatShared(const ChatShared::Ptr& object) const {
WriteAccessAllowed::Ptr TgTypeParser::parseJsonAndGetWriteAccessAllowed(const boost::property_tree::ptree& data) const {
auto result(std::make_shared<WriteAccessAllowed>());
+ result->webAppName = data.get<std::string>("web_app_name", "");
return result;
}
@@ -1118,7 +1119,8 @@ std::string TgTypeParser::parseWriteAccessAllowed(const WriteAccessAllowed::Ptr&
}
std::string result;
result += '{';
- //removeLastComma(result);
+ appendToJson(result, "web_app_name", object->webAppName);
+ removeLastComma(result);
result += '}';
return result;
}
@@ -1456,10 +1458,12 @@ InlineKeyboardButton::Ptr TgTypeParser::parseJsonAndGetInlineKeyboardButton(cons
result->loginUrl = tryParseJson<LoginUrl>(&TgTypeParser::parseJsonAndGetLoginUrl, data, "login_url");
result->switchInlineQuery = data.get<std::string>("switch_inline_query", "");
result->switchInlineQueryCurrentChat = data.get<std::string>("switch_inline_query_current_chat", "");
+ result->switchInlineQueryChosenChat = tryParseJson<SwitchInlineQueryChosenChat>(&TgTypeParser::parseJsonAndGetSwitchInlineQueryChosenChat, data, "switch_inline_query_chosen_chat");
result->callbackGame = tryParseJson<CallbackGame>(&TgTypeParser::parseJsonAndGetCallbackGame, data, "callback_game");
result->pay = data.get<bool>("pay", false);
return result;
}
+
std::string TgTypeParser::parseInlineKeyboardButton(const InlineKeyboardButton::Ptr& object) const {
if (!object) {
return "";
@@ -1473,6 +1477,7 @@ std::string TgTypeParser::parseInlineKeyboardButton(const InlineKeyboardButton::
appendToJson(result, "login_url", parseLoginUrl(object->loginUrl));
appendToJson(result, "switch_inline_query", object->switchInlineQuery);
appendToJson(result, "switch_inline_query_current_chat", object->switchInlineQueryCurrentChat);
+ appendToJson(result, "switch_inline_query_chosen_chat", parseSwitchInlineQueryChosenChat(object->switchInlineQueryChosenChat));
appendToJson(result, "callback_game", parseCallbackGame(object->callbackGame));
appendToJson(result, "pay", object->pay);
removeLastComma(result);
@@ -1504,6 +1509,32 @@ std::string TgTypeParser::parseLoginUrl(const LoginUrl::Ptr& object) const {
return result;
}
+SwitchInlineQueryChosenChat::Ptr TgTypeParser::parseJsonAndGetSwitchInlineQueryChosenChat(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<SwitchInlineQueryChosenChat>());
+ result->query = data.get<std::string>("query", "");
+ result->allowUserChats = data.get<bool>("allow_user_chats", false);
+ result->allowBotChats = data.get<bool>("allow_bot_chats", false);
+ result->allowGroupChats = data.get<bool>("allow_group_chats", false);
+ result->allowChannelChats = data.get<bool>("allow_channel_chats", false);
+ return result;
+}
+
+std::string TgTypeParser::parseSwitchInlineQueryChosenChat(const SwitchInlineQueryChosenChat::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "query", object->query);
+ appendToJson(result, "allow_user_chats", object->allowUserChats);
+ appendToJson(result, "allow_bot_chats", object->allowBotChats);
+ appendToJson(result, "allow_group_chats", object->allowGroupChats);
+ appendToJson(result, "allow_channel_chats", object->allowChannelChats);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
CallbackQuery::Ptr TgTypeParser::parseJsonAndGetCallbackQuery(const boost::property_tree::ptree& data) const {
auto result(std::make_shared<CallbackQuery>());
result->id = data.get<std::string>("id");
@@ -1880,10 +1911,11 @@ ChatMemberUpdated::Ptr TgTypeParser::parseJsonAndGetChatMemberUpdated(const boos
auto result(std::make_shared<ChatMemberUpdated>());
result->chat = tryParseJson<Chat>(&TgTypeParser::parseJsonAndGetChat, data, "chat");
result->from = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "from");
- result->date = data.get<uint32_t>("date", 0);
+ result->date = data.get<std::uint64_t>("date", 0);
result->oldChatMember = tryParseJson<ChatMember>(&TgTypeParser::parseJsonAndGetChatMember, data, "old_chat_member");
result->newChatMember = tryParseJson<ChatMember>(&TgTypeParser::parseJsonAndGetChatMember, data, "new_chat_member");
result->inviteLink = tryParseJson<ChatInviteLink>(&TgTypeParser::parseJsonAndGetChatInviteLink, data, "invite_link");
+ result->viaChatFolderInviteLink = data.get<bool>("via_chat_folder_invite_link", false);
return result;
}
@@ -1899,6 +1931,7 @@ std::string TgTypeParser::parseChatMemberUpdated(const ChatMemberUpdated::Ptr& o
appendToJson(result, "old_chat_member", parseChatMember(object->oldChatMember));
appendToJson(result, "new_chat_member", parseChatMember(object->newChatMember));
appendToJson(result, "invite_link", parseChatInviteLink(object->inviteLink));
+ appendToJson(result, "via_chat_folder_invite_link", object->viaChatFolderInviteLink);
removeLastComma(result);
result += '}';
return result;
@@ -2220,6 +2253,21 @@ std::string TgTypeParser::parseBotCommandScopeChatMember(const BotCommandScopeCh
return result;
}
+BotName::Ptr TgTypeParser::parseJsonAndGetBotName(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<BotName>());
+ result->name = data.get<std::string>("name", "");
+ return result;
+}
+
+std::string TgTypeParser::parseBotName(const BotName::Ptr& object) const {
+ std::string result;
+ result += '{';
+ appendToJson(result, "name", object->name);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
BotDescription::Ptr TgTypeParser::parseJsonAndGetBotDescription(const boost::property_tree::ptree& data) const {
auto result(std::make_shared<BotDescription>());
result->description = data.get<std::string>("description", "");
@@ -2734,6 +2782,28 @@ std::string TgTypeParser::parseInlineQuery(const InlineQuery::Ptr& object) const
return result;
}
+InlineQueryResultsButton::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultsButton(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<InlineQueryResultsButton>());
+ result->text = data.get<std::string>("text", "");
+ result->webApp = tryParseJson<WebAppInfo>(&TgTypeParser::parseJsonAndGetWebAppInfo, data, "web_app");
+ result->startParameter = data.get<std::string>("start_parameter", "");
+ return result;
+}
+
+std::string TgTypeParser::parseInlineQueryResultsButton(const InlineQueryResultsButton::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "text", object->text);
+ appendToJson(result, "web_app", parseWebAppInfo(object->webApp));
+ appendToJson(result, "start_parameter", object->startParameter);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
InlineQueryResult::Ptr TgTypeParser::parseJsonAndGetInlineQueryResult(const boost::property_tree::ptree& data) const {
std::string type = data.get<std::string>("type", "");
InlineQueryResult::Ptr result;