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/Api.cpp | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'src/Api.cpp') 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 Api::getMyCommands(BotCommandScope::Ptr scope, return _tgTypeParser.parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetBotCommand, sendRequest("getMyCommands", args)); } +bool Api::setMyName(const std::string& name, + const std::string& languageCode) const { + std::vector 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("", false); +} + +BotName::Ptr Api::getMyName(const std::string& languageCode) const { + std::vector 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 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 args; - args.reserve(7); + args.reserve(6); args.emplace_back("inline_query_id", inlineQueryId); args.emplace_back("results", _tgTypeParser.parseArray(&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("", false); -- cgit v1.2.3