diff options
author | Oleg Morozenkov <m@oleg.rocks> | 2019-12-05 00:50:28 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-05 00:50:28 +0300 |
commit | d873b1ec87c70449fffba336b2aeabb259885b21 (patch) | |
tree | 87ac36248432558291c1dece547b7f220ea8da96 /include/tgbot | |
parent | 9148563cb333bb6a3127138541de2fc086ff743b (diff) | |
parent | 2318c534d4286436a668c5a33220dfc8d5b85686 (diff) |
Merge pull request #114 from YJBeetle/master
fix #113 InlineQueryResult json parse bug
Diffstat (limited to 'include/tgbot')
-rw-r--r-- | include/tgbot/Api.h | 5 | ||||
-rw-r--r-- | include/tgbot/TgTypeParser.h | 18 |
2 files changed, 20 insertions, 3 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index 84a6c9b..ec9edf8 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -251,13 +251,12 @@ public: * @brief Use this method to add a new sticker to a set created by the bot. * @param userId User identifier of created sticker set owner. * @param name Sticker set name. - * @param title Sticker set title, 1-64 characters. * @param pngSticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. * @param emojis One or more emoji corresponding to the sticker. * @param maskPosition Optional. A JSON-serialized object for position where the mask should be placed on faces. * @return Returns True on success. */ - bool addStickerToSet(int32_t userId, const std::string& name, const std::string& title, + bool addStickerToSet(int32_t userId, const std::string& name, boost::variant<InputFile::Ptr, std::string> pngSticker, const std::string& emojis, MaskPosition::Ptr maskPosition = nullptr) const; /** @@ -273,7 +272,7 @@ public: * @param stickers File identifier of the sticker. * @return Returns True on success. */ - bool deleteStickerPositionInSet(const std::string& sticker) const; + bool deleteStickerFromSet(const std::string& sticker) const; /** * @brief Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h index dbfa27e..979ba55 100644 --- a/include/tgbot/TgTypeParser.h +++ b/include/tgbot/TgTypeParser.h @@ -468,6 +468,24 @@ private: json += ','; } + template<typename T> + inline void appendToJsonNumber(std::string& json, const std::string& varName, const T& value) const { + json += '"'; + json += varName; + json += R"(":)"; + json += std::to_string(value); + json += ','; + } + inline void appendToJson(std::string &json, const std::string &varName, const int &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const long &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const long long &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const unsigned &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const unsigned long &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const unsigned long long &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const float &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const double &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const long double &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string& json, const std::string& varName, const bool& value) const { json += '"'; json += varName; |