From fbeb025e21fad2fa1fb6cd5ae186eabf9a349091 Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Mon, 15 Apr 2024 01:24:12 +0200 Subject: Update to Bot API 6.7 --- src/TgTypeParser.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-) (limited to 'src/TgTypeParser.cpp') 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()); + result->webAppName = data.get("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(&TgTypeParser::parseJsonAndGetLoginUrl, data, "login_url"); result->switchInlineQuery = data.get("switch_inline_query", ""); result->switchInlineQueryCurrentChat = data.get("switch_inline_query_current_chat", ""); + result->switchInlineQueryChosenChat = tryParseJson(&TgTypeParser::parseJsonAndGetSwitchInlineQueryChosenChat, data, "switch_inline_query_chosen_chat"); result->callbackGame = tryParseJson(&TgTypeParser::parseJsonAndGetCallbackGame, data, "callback_game"); result->pay = data.get("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()); + result->query = data.get("query", ""); + result->allowUserChats = data.get("allow_user_chats", false); + result->allowBotChats = data.get("allow_bot_chats", false); + result->allowGroupChats = data.get("allow_group_chats", false); + result->allowChannelChats = data.get("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()); result->id = data.get("id"); @@ -1880,10 +1911,11 @@ ChatMemberUpdated::Ptr TgTypeParser::parseJsonAndGetChatMemberUpdated(const boos auto result(std::make_shared()); result->chat = tryParseJson(&TgTypeParser::parseJsonAndGetChat, data, "chat"); result->from = tryParseJson(&TgTypeParser::parseJsonAndGetUser, data, "from"); - result->date = data.get("date", 0); + result->date = data.get("date", 0); result->oldChatMember = tryParseJson(&TgTypeParser::parseJsonAndGetChatMember, data, "old_chat_member"); result->newChatMember = tryParseJson(&TgTypeParser::parseJsonAndGetChatMember, data, "new_chat_member"); result->inviteLink = tryParseJson(&TgTypeParser::parseJsonAndGetChatInviteLink, data, "invite_link"); + result->viaChatFolderInviteLink = data.get("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()); + result->name = data.get("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()); result->description = data.get("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()); + result->text = data.get("text", ""); + result->webApp = tryParseJson(&TgTypeParser::parseJsonAndGetWebAppInfo, data, "web_app"); + result->startParameter = data.get("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("type", ""); InlineQueryResult::Ptr result; -- cgit v1.2.3