summaryrefslogtreecommitdiff
path: root/src/Api.cpp
diff options
context:
space:
mode:
authorOleg Morozenkov <m@oleg.rocks>2020-08-21 01:41:36 +0300
committerGitHub <noreply@github.com>2020-08-21 01:41:36 +0300
commit4009b7ea603dcd7f21c6e852497daba7b0a1a6b3 (patch)
tree6dd10e3c92accb9aa250bc30862a59f6f7d9067b /src/Api.cpp
parent3230b1b5d84a7a948324949eb607082dc40fe01e (diff)
parentffc3c38882d669ea6b2abeea5c0f7c7b322fa6e7 (diff)
Merge pull request #143 from sebest06/master
* add SetMyCommand to the api
Diffstat (limited to 'src/Api.cpp')
-rw-r--r--src/Api.cpp18
1 files changed, 18 insertions, 0 deletions
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<BotCommand::Ptr>& commands) const {
+
+ vector<HttpReqArg> args;
+ args.reserve(5);
+
+ string commandsJson = _tgTypeParser.parseArray<BotCommand>(&TgTypeParser::parseBotCommand, commands);
+ args.emplace_back("commands", commandsJson);
+
+ return sendRequest("setMyCommands",args).get<bool>("",false);
+}
+
+std::vector<BotCommand::Ptr> Api::getMyCommands() const
+{
+ return _tgTypeParser.parseJsonAndGetArray<BotCommand>(&TgTypeParser::parseJsonAndGetBotCommand, sendRequest("getMyCommands"));
+}
+
ptree Api::sendRequest(const string& method, const vector<HttpReqArg>& args) const {
string url = "https://api.telegram.org/bot";
url += _token;
@@ -1189,4 +1205,6 @@ string Api::downloadFile(const string& filePath, const std::vector<HttpReqArg>&
return serverResponse;
}
+
+
}