From ffc3c38882d669ea6b2abeea5c0f7c7b322fa6e7 Mon Sep 17 00:00:00 2001 From: sebest Date: Mon, 25 May 2020 15:49:44 -0300 Subject: * add SetMyCommand to the api --- src/Api.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/Api.cpp') diff --git a/src/Api.cpp b/src/Api.cpp index 6e01807..0a08353 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -1155,6 +1155,22 @@ Poll::Ptr Api::stopPoll(std::int64_t chatId, std::int64_t messageId, const Inlin return _tgTypeParser.parseJsonAndGetPoll(sendRequest("stopPoll", args)); } +bool Api::setMyCommands(const std::vector& commands) const { + + vector args; + args.reserve(5); + + string commandsJson = _tgTypeParser.parseArray(&TgTypeParser::parseBotCommand, commands); + args.emplace_back("commands", commandsJson); + + return sendRequest("setMyCommands",args).get("",false); +} + +std::vector Api::getMyCommands() const +{ + return _tgTypeParser.parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetBotCommand, sendRequest("getMyCommands")); +} + ptree Api::sendRequest(const string& method, const vector& args) const { string url = "https://api.telegram.org/bot"; url += _token; @@ -1189,4 +1205,6 @@ string Api::downloadFile(const string& filePath, const std::vector& return serverResponse; } + + } -- cgit v1.2.3