diff options
author | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2022-08-30 00:25:15 +0200 |
---|---|---|
committer | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2022-08-30 00:25:15 +0200 |
commit | 76a362631705d9adcc2709e6d8f9b327112ae306 (patch) | |
tree | fb14421e54a844bb9b698b5049339323085de343 /src/Api.cpp | |
parent | ed5065b35911a6d7d3dff30bd80600cc593901a3 (diff) |
Update to API 4.7
Diffstat (limited to 'src/Api.cpp')
-rw-r--r-- | src/Api.cpp | 64 |
1 files changed, 56 insertions, 8 deletions
diff --git a/src/Api.cpp b/src/Api.cpp index f1a1065..22115c2 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -320,19 +320,28 @@ File::Ptr Api::uploadStickerFile(std::int64_t userId, const InputFile::Ptr pngSt return _tgTypeParser.parseJsonAndGetFile(sendRequest("uploadStickerFile", args)); } -bool Api::createNewStickerSet(std::int64_t userId, const string& name, const string& title, boost::variant<InputFile::Ptr, std::string> pngSticker, const string& emojis, bool containsMasks, MaskPosition::Ptr maskPosition) const { +bool Api::createNewStickerSet(std::int64_t userId, const std::string& name, const std::string& title, const std::string& emojis, + boost::variant<InputFile::Ptr, std::string> pngSticker, boost::variant<InputFile::Ptr, std::string> tgsSticker, + bool containsMasks, MaskPosition::Ptr maskPosition) const { vector<HttpReqArg> args; - args.reserve(7); + args.reserve(8); args.emplace_back("user_id", userId); args.emplace_back("name", name); args.emplace_back("title", title); + args.emplace_back("emojis", emojis); + if (pngSticker.which() == 0 /* InputFile::Ptr */) { auto file = boost::get<InputFile::Ptr>(pngSticker); args.emplace_back("png_sticker", file->data, true, file->mimeType, file->fileName); } else /* std::string */ { args.emplace_back("png_sticker", boost::get<std::string>(pngSticker)); } - args.emplace_back("emojis", emojis); + if (tgsSticker.which() == 0 /* InputFile::Ptr */) { + auto file = boost::get<InputFile::Ptr>(tgsSticker); + args.emplace_back("tgs_sticker", file->data, true, file->mimeType, file->fileName); + } else /* std::string */ { + args.emplace_back("tgs_sticker", boost::get<std::string>(tgsSticker)); + } if (containsMasks) { args.emplace_back("contains_mask", containsMasks); } @@ -342,18 +351,27 @@ bool Api::createNewStickerSet(std::int64_t userId, const string& name, const str return sendRequest("createNewStickerSet", args).get<bool>("", false); } -bool Api::addStickerToSet(std::int64_t userId, const string& name, boost::variant<InputFile::Ptr, std::string> pngSticker, const string& emojis, MaskPosition::Ptr maskPosition) const { +bool Api::addStickerToSet(std::int64_t userId, const std::string& name, const std::string& emojis, + boost::variant<InputFile::Ptr, std::string> pngSticker, boost::variant<InputFile::Ptr, std::string> tgsSticker, + MaskPosition::Ptr maskPosition) const { vector<HttpReqArg> args; args.reserve(6); args.emplace_back("user_id", userId); args.emplace_back("name", name); + args.emplace_back("emojis", emojis); + if (pngSticker.which() == 0 /* InputFile::Ptr */) { auto file = boost::get<InputFile::Ptr>(pngSticker); args.emplace_back("png_sticker", file->data, true, file->mimeType, file->fileName); } else /* std::string */ { args.emplace_back("png_sticker", boost::get<std::string>(pngSticker)); } - args.emplace_back("emojis", emojis); + if (tgsSticker.which() == 0 /* InputFile::Ptr */) { + auto file = boost::get<InputFile::Ptr>(tgsSticker); + args.emplace_back("tgs_sticker", file->data, true, file->mimeType, file->fileName); + } else /* std::string */ { + args.emplace_back("tgs_sticker", boost::get<std::string>(tgsSticker)); + } if (maskPosition != nullptr) { args.emplace_back("mask_position", _tgTypeParser.parseMaskPosition(maskPosition)); } @@ -375,6 +393,20 @@ bool Api::deleteStickerFromSet(const string& sticker) const { return sendRequest("deleteStickerFromSet", args).get<bool>("", false); } +bool Api::setStickerSetThumb(const std::string& name, std::int64_t userId, boost::variant<InputFile::Ptr, std::string> thumb) const { + vector<HttpReqArg> args; + args.reserve(3); + args.emplace_back("name", name); + args.emplace_back("user_id", userId); + if (thumb.which() == 0 /* InputFile::Ptr */) { + auto file = boost::get<InputFile::Ptr>(thumb); + args.emplace_back("thumb", file->data, true, file->mimeType, file->fileName); + } else /* std::string */ { + args.emplace_back("thumb", boost::get<std::string>(thumb)); + } + return sendRequest("setStickerSetThumb", args).get<bool>("", false); +} + Message::Ptr Api::sendVideo(std::int64_t chatId, boost::variant<InputFile::Ptr, std::string> video, bool supportsStreaming, std::int32_t duration, std::int32_t width, std::int32_t height, boost::variant<InputFile::Ptr, std::string> thumb, const string &caption, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { vector<HttpReqArg> args; args.reserve(12); @@ -1194,6 +1226,24 @@ Message::Ptr Api::sendPoll(std::int64_t chatId, const std::string& question, con return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendPoll", args)); } +Message::Ptr Api::sendDice(std::int64_t chatId, bool disableNotification, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup) const { + vector<HttpReqArg> args; + args.reserve(4); + args.emplace_back("chat_id", chatId); + + if (disableNotification) { + args.emplace_back("disable_notification", disableNotification); + } + if (replyToMessageId != 0) { + args.emplace_back("reply_to_message_id", replyToMessageId); + } + if (replyMarkup) { + args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); + } + + return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendDice", args)); +} + Poll::Ptr Api::stopPoll(std::int64_t chatId, std::int64_t messageId, const InlineKeyboardMarkup::Ptr replyMarkup) const { vector<HttpReqArg> args; args.reserve(3); @@ -1206,7 +1256,6 @@ Poll::Ptr Api::stopPoll(std::int64_t chatId, std::int64_t messageId, const Inlin } bool Api::setMyCommands(const std::vector<BotCommand::Ptr>& commands) const { - vector<HttpReqArg> args; args.reserve(5); @@ -1216,8 +1265,7 @@ bool Api::setMyCommands(const std::vector<BotCommand::Ptr>& commands) const { return sendRequest("setMyCommands",args).get<bool>("",false); } -std::vector<BotCommand::Ptr> Api::getMyCommands() const -{ +std::vector<BotCommand::Ptr> Api::getMyCommands() const { return _tgTypeParser.parseJsonAndGetArray<BotCommand>(&TgTypeParser::parseJsonAndGetBotCommand, sendRequest("getMyCommands")); } |