From d2baea74a0ac09db992ab36a861d09caccdab697 Mon Sep 17 00:00:00 2001 From: Andrea Giove Date: Sun, 27 Mar 2016 16:31:11 +0200 Subject: Add answerInlineQuery method --- src/Api.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/Api.cpp') diff --git a/src/Api.cpp b/src/Api.cpp index 2e27e1d..47c7882 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -255,6 +255,17 @@ void Api::setWebhook(const string& url) const { sendRequest("setWebhook", args); } +void Api::answerInlineQuery(const std::string inlineQueryId, const std::vector results, + int32_t cacheTime=300, bool isPersonal=false, const std::string& nextOffset=""){ + vector args; + args.push_back(HttpReqArg("inline_query_id", inlineQueryId)); + args.push_back(HttpReqArg("results", results, TgTypeParser::getInstance().parseInlineQueryResult)); + args.push_back(HttpReqArg("cache_time", cacheTime)); + args.push_back(HttpReqArg("is_personal", isPersonal)); + args.push_back(HttpReqArg("next_offset", nextOffset)); + sendRequest("answerInlineQuery", args); +} + ptree Api::sendRequest(const string& method, const vector& args) const { string url = "https://api.telegram.org/bot"; -- cgit v1.2.3 From 405d973af3460ee2860d01c7169cf6749fa98b07 Mon Sep 17 00:00:00 2001 From: Andrea Giove Date: Sun, 27 Mar 2016 18:24:03 +0200 Subject: Fixed compilation errors --- src/Api.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Api.cpp') diff --git a/src/Api.cpp b/src/Api.cpp index 47c7882..325978f 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -255,11 +255,12 @@ void Api::setWebhook(const string& url) const { sendRequest("setWebhook", args); } -void Api::answerInlineQuery(const std::string inlineQueryId, const std::vector results, - int32_t cacheTime=300, bool isPersonal=false, const std::string& nextOffset=""){ +void Api::answerInlineQuery(const std::string& inlineQueryId, const std::vector& results, + int32_t cacheTime, bool isPersonal, const std::string& nextOffset){ vector args; args.push_back(HttpReqArg("inline_query_id", inlineQueryId)); - args.push_back(HttpReqArg("results", results, TgTypeParser::getInstance().parseInlineQueryResult)); + string resultsJson = TgTypeParser::getInstance().parseArray(&TgTypeParser::parseInlineQueryResult, results); + args.push_back(HttpReqArg("results", resultsJson)); args.push_back(HttpReqArg("cache_time", cacheTime)); args.push_back(HttpReqArg("is_personal", isPersonal)); args.push_back(HttpReqArg("next_offset", nextOffset)); -- cgit v1.2.3 From de33e2e08049c3698920789f769b7f361414f4b0 Mon Sep 17 00:00:00 2001 From: Andrea Giove Date: Tue, 29 Mar 2016 17:13:38 +0200 Subject: Edited answerInlineQuery --- src/Api.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Api.cpp') diff --git a/src/Api.cpp b/src/Api.cpp index 325978f..ed06d27 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -256,7 +256,7 @@ void Api::setWebhook(const string& url) const { } void Api::answerInlineQuery(const std::string& inlineQueryId, const std::vector& results, - int32_t cacheTime, bool isPersonal, const std::string& nextOffset){ + int32_t cacheTime, bool isPersonal, const std::string& nextOffset) const { vector args; args.push_back(HttpReqArg("inline_query_id", inlineQueryId)); string resultsJson = TgTypeParser::getInstance().parseArray(&TgTypeParser::parseInlineQueryResult, results); -- cgit v1.2.3