From 156c087f3eeeeffb949ae6a572dd7b52815eb0e5 Mon Sep 17 00:00:00 2001 From: kukin-konstantin Date: Mon, 20 Mar 2017 19:55:17 +0300 Subject: add function download file --- include/tgbot/Api.h | 2 ++ src/Api.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index bddcd87..0710f17 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -475,6 +475,8 @@ public: */ bool unbanChatMember(int64_t chatId, int32_t userId) const; + std::string downloadFile(const std::string& filePath, const std::vector& args = std::vector()) const; + private: boost::property_tree::ptree sendRequest(const std::string& method, const std::vector& args = std::vector()) const; diff --git a/src/Api.cpp b/src/Api.cpp index 6fd86c2..b7a53c1 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -681,4 +681,15 @@ ptree Api::sendRequest(const string& method, const vector& args) con } } +std::string Api::downloadFile(const std::string& filePath, const std::vector& args) const { + string url = "https://api.telegram.org/file/bot"; + url += _token; + url += "/"; + url += filePath; + + string serverResponse = HttpClient::getInstance().makeRequest(url, args); + + return serverResponse; +} + } -- cgit v1.2.3