From ed5065b35911a6d7d3dff30bd80600cc593901a3 Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Mon, 29 Aug 2022 21:30:37 +0200 Subject: Update to API 4.6 --- src/Api.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'src/Api.cpp') diff --git a/src/Api.cpp b/src/Api.cpp index b1a2f69..f1a1065 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -1155,24 +1155,42 @@ void Api::deleteMessage(std::int64_t chatId, std::int32_t messageId) const { sendRequest("deleteMessage", { HttpReqArg("chat_id", chatId), HttpReqArg("message_id", messageId) }); } -Message::Ptr Api::sendPoll(std::int64_t chatId, const std::string& question, const std::vector& options, bool disableNotification, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const { +Message::Ptr Api::sendPoll(std::int64_t chatId, const std::string& question, const std::vector& options, bool disableNotification, std::int32_t replyToMessageId, + const GenericReply::Ptr replyMarkup, bool isAnonymous, const std::string& type, bool allowsMultipleAnswers, + std::int32_t correctOptionId, bool isClosed) const { vector args; - args.reserve(6); + args.reserve(11); args.emplace_back("chat_id", chatId); args.emplace_back("question", question); args.emplace_back("options", _tgTypeParser.parseArray([] (const std::string& option) -> std::string { return StringTools::urlEncode(option); }, options)); - if (disableNotification){ + if (!isAnonymous) { + args.emplace_back("is_anonymous", isAnonymous); + } + if (!type.empty()) { + args.emplace_back("type", type); + } + if (allowsMultipleAnswers) { + args.emplace_back("allows_multiple_answers", allowsMultipleAnswers); + } + if (correctOptionId != 0) { + args.emplace_back("correct_option_id", correctOptionId); + } + if (isClosed) { + args.emplace_back("is_closed", isClosed); + } + if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } - if (replyToMessageId != 0){ + if (replyToMessageId != 0) { args.emplace_back("reply_to_message_id", replyToMessageId); } - if (replyMarkup){ + if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); } + return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendPoll", args)); } -- cgit v1.2.3