From b5b5cd9e88fc5a87f196e54144b163b4729570d1 Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Sat, 20 Apr 2024 14:17:26 +0200 Subject: Update to Bot API 7.0 --- src/Api.cpp | 401 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 220 insertions(+), 181 deletions(-) (limited to 'src/Api.cpp') diff --git a/src/Api.cpp b/src/Api.cpp index 0d11295..cdd5ad7 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -112,17 +112,16 @@ bool Api::close() const { Message::Ptr Api::sendMessage(boost::variant chatId, const std::string& text, - bool disableWebPagePreview, - std::int32_t replyToMessageId, + LinkPreviewOptions::Ptr linkPreviewOptions, + ReplyParameters::Ptr replyParameters, GenericReply::Ptr replyMarkup, const std::string& parseMode, bool disableNotification, const std::vector& entities, - bool allowSendingWithoutReply, - bool protectContent, - std::int32_t messageThreadId) const { + std::int32_t messageThreadId, + bool protectContent) const { std::vector args; - args.reserve(11); + args.reserve(10); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -135,8 +134,8 @@ Message::Ptr Api::sendMessage(boost::variant chatId, if (!entities.empty()) { args.emplace_back("entities", _tgTypeParser.parseArray(&TgTypeParser::parseMessageEntity, entities)); } - if (disableWebPagePreview) { - args.emplace_back("disable_web_page_preview", disableWebPagePreview); + if (linkPreviewOptions != nullptr) { + args.emplace_back("link_preview_options", _tgTypeParser.parseLinkPreviewOptions(linkPreviewOptions)); } if (disableNotification) { args.emplace_back("disable_notification", disableNotification); @@ -144,11 +143,8 @@ Message::Ptr Api::sendMessage(boost::variant chatId, if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId != 0) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); @@ -182,6 +178,36 @@ Message::Ptr Api::forwardMessage(boost::variant chatI return _tgTypeParser.parseJsonAndGetMessage(sendRequest("forwardMessage", args)); } +std::vector Api::forwardMessages(boost::variant chatId, + boost::variant fromChatId, + const std::vector& messageIds, + std::int32_t messageThreadId, + bool disableNotification, + bool protectContent) const { + std::vector args; + args.reserve(6); + + args.emplace_back("chat_id", chatId); + args.emplace_back("from_chat_id", fromChatId); + if (!messageIds.empty()) { + args.emplace_back("message_ids", _tgTypeParser.parseArray( + [] (const std::int32_t& i)->std::int32_t { + return i; + }, messageIds)); + } + if (messageThreadId != 0) { + args.emplace_back("message_thread_id", messageThreadId); + } + if (disableNotification) { + args.emplace_back("disable_notification", disableNotification); + } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } + + return _tgTypeParser.parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetMessageId, sendRequest("forwardMessages", args)); +} + MessageId::Ptr Api::copyMessage(boost::variant chatId, boost::variant fromChatId, std::int32_t messageId, @@ -189,13 +215,12 @@ MessageId::Ptr Api::copyMessage(boost::variant chatId const std::string& parseMode, const std::vector& captionEntities, bool disableNotification, - std::int32_t replyToMessageId, - bool allowSendingWithoutReply, + ReplyParameters::Ptr replyParameters, GenericReply::Ptr replyMarkup, bool protectContent, std::int32_t messageThreadId) const { std::vector args; - args.reserve(12); + args.reserve(11); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -218,11 +243,8 @@ MessageId::Ptr Api::copyMessage(boost::variant chatId if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); @@ -231,20 +253,54 @@ MessageId::Ptr Api::copyMessage(boost::variant chatId return _tgTypeParser.parseJsonAndGetMessageId(sendRequest("copyMessage", args)); } +std::vector Api::copyMessages(boost::variant chatId, + boost::variant fromChatId, + const std::vector& messageIds, + std::int32_t messageThreadId, + bool disableNotification, + bool protectContent, + bool removeCaption) const { + std::vector args; + args.reserve(7); + + args.emplace_back("chat_id", chatId); + args.emplace_back("from_chat_id", fromChatId); + + if (!messageIds.empty()) { + args.emplace_back("message_ids", _tgTypeParser.parseArray( + [] (const std::int32_t& i)->std::int32_t { + return i; + }, messageIds)); + } + if (messageThreadId != 0) { + args.emplace_back("message_thread_id", messageThreadId); + } + if (disableNotification) { + args.emplace_back("disable_notification", disableNotification); + } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } + if (removeCaption) { + args.emplace_back("remove_caption", removeCaption); + } + + return _tgTypeParser.parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetMessageId, sendRequest("copyMessages", args)); +} + Message::Ptr Api::sendPhoto(boost::variant chatId, boost::variant photo, const std::string& caption, - std::int32_t replyToMessageId, + ReplyParameters::Ptr replyParameters, GenericReply::Ptr replyMarkup, const std::string& parseMode, bool disableNotification, const std::vector& captionEntities, - bool allowSendingWithoutReply, - bool protectContent, std::int32_t messageThreadId, + bool protectContent, bool hasSpoiler) const { std::vector args; - args.reserve(12); + args.reserve(11); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -274,11 +330,8 @@ Message::Ptr Api::sendPhoto(boost::variant chatId, if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId != 0) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup != nullptr) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); @@ -294,16 +347,15 @@ Message::Ptr Api::sendAudio(boost::variant chatId, const std::string& performer, const std::string& title, boost::variant thumbnail, - std::int32_t replyToMessageId, + ReplyParameters::Ptr replyParameters, GenericReply::Ptr replyMarkup, const std::string& parseMode, bool disableNotification, const std::vector& captionEntities, - bool allowSendingWithoutReply, - bool protectContent, - std::int32_t messageThreadId) const { + std::int32_t messageThreadId, + bool protectContent) const { std::vector args; - args.reserve(15); + args.reserve(14); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -348,11 +400,8 @@ Message::Ptr Api::sendAudio(boost::variant chatId, if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); @@ -365,17 +414,16 @@ Message::Ptr Api::sendDocument(boost::variant chatId, boost::variant document, boost::variant thumbnail, const std::string& caption, - std::int32_t replyToMessageId, + ReplyParameters::Ptr replyParameters, GenericReply::Ptr replyMarkup, const std::string& parseMode, bool disableNotification, const std::vector& captionEntities, bool disableContentTypeDetection, - bool allowSendingWithoutReply, - bool protectContent, - std::int32_t messageThreadId) const { + std::int32_t messageThreadId, + bool protectContent) const { std::vector args; - args.reserve(13); + args.reserve(12); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -414,11 +462,8 @@ Message::Ptr Api::sendDocument(boost::variant chatId, if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); @@ -435,17 +480,16 @@ Message::Ptr Api::sendVideo(boost::variant chatId, std::int32_t height, boost::variant thumbnail, const std::string& caption , - std::int32_t replyToMessageId, + ReplyParameters::Ptr replyParameters, GenericReply::Ptr replyMarkup, const std::string& parseMode, bool disableNotification, const std::vector& captionEntities, - bool allowSendingWithoutReply, - bool protectContent, std::int32_t messageThreadId, + bool protectContent, bool hasSpoiler) const { std::vector args; - args.reserve(17); + args.reserve(16); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -496,11 +540,8 @@ Message::Ptr Api::sendVideo(boost::variant chatId, if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId != 0) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup != nullptr) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); @@ -516,17 +557,16 @@ Message::Ptr Api::sendAnimation(boost::variant chatId std::int32_t height, boost::variant thumbnail, const std::string& caption, - std::int32_t replyToMessageId, + ReplyParameters::Ptr replyParameters, GenericReply::Ptr replyMarkup, const std::string& parseMode, bool disableNotification, const std::vector& captionEntities, - bool allowSendingWithoutReply, - bool protectContent, std::int32_t messageThreadId, - bool hasSpoiler ) const { + bool protectContent, + bool hasSpoiler) const { std::vector args; - args.reserve(16); + args.reserve(15); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -574,11 +614,8 @@ Message::Ptr Api::sendAnimation(boost::variant chatId if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId != 0) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup != nullptr) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); @@ -591,16 +628,15 @@ Message::Ptr Api::sendVoice(boost::variant chatId, boost::variant voice, const std::string& caption, std::int32_t duration, - std::int32_t replyToMessageId, + ReplyParameters::Ptr replyParameters, GenericReply::Ptr replyMarkup, const std::string& parseMode, bool disableNotification, const std::vector& captionEntities, - bool allowSendingWithoutReply, - bool protectContent, - std::int32_t messageThreadId) const { + std::int32_t messageThreadId, + bool protectContent) const { std::vector args; - args.reserve(12); + args.reserve(11); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -630,11 +666,8 @@ Message::Ptr Api::sendVoice(boost::variant chatId, if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); @@ -645,17 +678,16 @@ Message::Ptr Api::sendVoice(boost::variant chatId, Message::Ptr Api::sendVideoNote(boost::variant chatId, boost::variant videoNote, - std::int64_t replyToMessageId, + ReplyParameters::Ptr replyParameters, bool disableNotification, std::int32_t duration, std::int32_t length, boost::variant thumbnail, GenericReply::Ptr replyMarkup, - bool allowSendingWithoutReply, - bool protectContent, - std::int32_t messageThreadId) const { + std::int32_t messageThreadId, + bool protectContent) const { std::vector args; - args.reserve(11); + args.reserve(10); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -688,11 +720,8 @@ Message::Ptr Api::sendVideoNote(boost::variant chatId if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); @@ -704,12 +733,11 @@ Message::Ptr Api::sendVideoNote(boost::variant chatId std::vector Api::sendMediaGroup(boost::variant chatId, const std::vector& media, bool disableNotification, - std::int32_t replyToMessageId, - bool allowSendingWithoutReply, - bool protectContent, - std::int32_t messageThreadId) const { + ReplyParameters::Ptr replyParameters, + std::int32_t messageThreadId, + bool protectContent) const { std::vector args; - args.reserve(7); + args.reserve(6); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -722,11 +750,8 @@ std::vector Api::sendMediaGroup(boost::variant(&TgTypeParser::parseJsonAndGetMessage, sendRequest("sendMediaGroup", args)); @@ -736,17 +761,16 @@ Message::Ptr Api::sendLocation(boost::variant chatId, float latitude, float longitude, std::int32_t livePeriod, - std::int32_t replyToMessageId, + ReplyParameters::Ptr replyParameters, GenericReply::Ptr replyMarkup, bool disableNotification, float horizontalAccuracy, std::int32_t heading, std::int32_t proximityAlertRadius, - bool allowSendingWithoutReply, - bool protectContent, - std::int32_t messageThreadId) const { + std::int32_t messageThreadId, + bool protectContent) const { std::vector args; - args.reserve(13); + args.reserve(12); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -772,11 +796,8 @@ Message::Ptr Api::sendLocation(boost::variant chatId, if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); @@ -867,15 +888,14 @@ Message::Ptr Api::sendVenue(boost::variant chatId, const std::string& foursquareId, const std::string& foursquareType, bool disableNotification, - std::int32_t replyToMessageId, + ReplyParameters::Ptr replyParameters, GenericReply::Ptr replyMarkup, const std::string& googlePlaceId, const std::string& googlePlaceType, - bool allowSendingWithoutReply, - bool protectContent, - std::int32_t messageThreadId) const { + std::int32_t messageThreadId, + bool protectContent) const { std::vector args; - args.reserve(15); + args.reserve(14); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -903,11 +923,8 @@ Message::Ptr Api::sendVenue(boost::variant chatId, if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); @@ -922,13 +939,12 @@ Message::Ptr Api::sendContact(boost::variant chatId, const std::string& lastName , const std::string& vcard, bool disableNotification, - std::int32_t replyToMessageId, + ReplyParameters::Ptr replyParameters, GenericReply::Ptr replyMarkup, - bool allowSendingWithoutReply, - bool protectContent, - std::int32_t messageThreadId) const { + std::int32_t messageThreadId, + bool protectContent) const { std::vector args; - args.reserve(11); + args.reserve(10); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -948,11 +964,8 @@ Message::Ptr Api::sendContact(boost::variant chatId, if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); @@ -965,7 +978,7 @@ Message::Ptr Api::sendPoll(boost::variant chatId, const std::string& question, const std::vector& options, bool disableNotification, - std::int32_t replyToMessageId, + ReplyParameters::Ptr replyParameters, GenericReply::Ptr replyMarkup, bool isAnonymous, const std::string& type, @@ -977,11 +990,10 @@ Message::Ptr Api::sendPoll(boost::variant chatId, std::int32_t openPeriod, std::int32_t closeDate, bool isClosed, - bool allowSendingWithoutReply, - bool protectContent, - std::int32_t messageThreadId) const { + std::int32_t messageThreadId, + bool protectContent) const { std::vector args; - args.reserve(19); + args.reserve(18); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -1028,11 +1040,8 @@ Message::Ptr Api::sendPoll(boost::variant chatId, if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId != 0) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); @@ -1043,14 +1052,13 @@ Message::Ptr Api::sendPoll(boost::variant chatId, Message::Ptr Api::sendDice(boost::variant chatId, bool disableNotification, - std::int32_t replyToMessageId, + ReplyParameters::Ptr replyParameters, GenericReply::Ptr replyMarkup, const std::string& emoji, - bool allowSendingWithoutReply, - bool protectContent, - std::int32_t messageThreadId) const { + std::int32_t messageThreadId, + bool protectContent) const { std::vector args; - args.reserve(8); + args.reserve(7); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -1065,11 +1073,8 @@ Message::Ptr Api::sendDice(boost::variant chatId, if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId != 0) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); @@ -1078,6 +1083,25 @@ Message::Ptr Api::sendDice(boost::variant chatId, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendDice", args)); } +bool Api::setMessageReaction(boost::variant chatId, + std::int32_t messageId, + const std::vector& reaction, + bool isBig) const { + std::vector args; + args.reserve(4); + + args.emplace_back("chat_id", chatId); + args.emplace_back("message_id", messageId); + if (!reaction.empty()) { + args.emplace_back("reaction", _tgTypeParser.parseArray(&TgTypeParser::parseReactionType, reaction)); + } + if (isBig) { + args.emplace_back("is_big", isBig); + } + + return sendRequest("setMessageReaction", args).get("", false); +} + bool Api::sendChatAction(std::int64_t chatId, const std::string& action, std::int32_t messageThreadId) const { @@ -1710,6 +1734,17 @@ bool Api::answerCallbackQuery(const std::string& callbackQueryId, return sendRequest("answerCallbackQuery", args).get("", false); } +UserChatBoosts::Ptr Api::getUserChatBoosts(boost::variant chatId, + std::int32_t userId) const { + std::vector args; + args.reserve(2); + + args.emplace_back("chat_id", chatId); + args.emplace_back("user_id", userId); + + return _tgTypeParser.parseJsonAndGetUserChatBoosts(sendRequest("getUserChatBoosts", args)); +} + bool Api::setMyCommands(const std::vector& commands, BotCommandScope::Ptr scope, const std::string& languageCode) const { @@ -1892,7 +1927,7 @@ Message::Ptr Api::editMessageText(const std::string& text, std::int32_t messageId, const std::string& inlineMessageId, const std::string& parseMode, - bool disableWebPagePreview, + LinkPreviewOptions::Ptr linkPreviewOptions, InlineKeyboardMarkup::Ptr replyMarkup, const std::vector& entities) const { std::vector args; @@ -1920,8 +1955,8 @@ Message::Ptr Api::editMessageText(const std::string& text, if (!entities.empty()) { args.emplace_back("entities", _tgTypeParser.parseArray(&TgTypeParser::parseMessageEntity, entities)); } - if (disableWebPagePreview) { - args.emplace_back("disable_web_page_preview", disableWebPagePreview); + if (linkPreviewOptions) { + args.emplace_back("link_preview_options", _tgTypeParser.parseLinkPreviewOptions(linkPreviewOptions)); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseInlineKeyboardMarkup(replyMarkup)); @@ -2079,17 +2114,32 @@ bool Api::deleteMessage(boost::variant chatId, return sendRequest("deleteMessage", args).get("", false); } +bool Api::deleteMessages(boost::variant chatId, + const std::vector& messageIds) const { + std::vector args; + args.reserve(2); + + args.emplace_back("chat_id", chatId); + if (!messageIds.empty()) { + args.emplace_back("message_ids", _tgTypeParser.parseArray( + [] (const std::int32_t& i)->std::int32_t { + return i; + }, messageIds)); + } + + return sendRequest("deleteMessages", args).get("", false); +} + Message::Ptr Api::sendSticker(boost::variant chatId, boost::variant sticker, - std::int32_t replyToMessageId, + ReplyParameters::Ptr replyParameters, GenericReply::Ptr replyMarkup, bool disableNotification, - bool allowSendingWithoutReply, - bool protectContent, std::int32_t messageThreadId, + bool protectContent, const std::string& emoji) const { std::vector args; - args.reserve(9); + args.reserve(8); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -2110,11 +2160,8 @@ Message::Ptr Api::sendSticker(boost::variant chatId, if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); @@ -2370,17 +2417,16 @@ Message::Ptr Api::sendInvoice(boost::variant chatId, bool sendPhoneNumberToProvider, bool sendEmailToProvider, bool isFlexible, - std::int32_t replyToMessageId, + ReplyParameters::Ptr replyParameters, GenericReply::Ptr replyMarkup, bool disableNotification, - bool allowSendingWithoutReply, + std::int32_t messageThreadId, std::int32_t maxTipAmount, const std::vector& suggestedTipAmounts, const std::string& startParameter, - bool protectContent, - std::int32_t messageThreadId) const { + bool protectContent) const { std::vector args; - args.reserve(28); + args.reserve(27); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -2443,11 +2489,8 @@ Message::Ptr Api::sendInvoice(boost::variant chatId, if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); @@ -2578,14 +2621,13 @@ bool Api::setPassportDataErrors(std::int64_t userId, Message::Ptr Api::sendGame(std::int64_t chatId, const std::string& gameShortName, - std::int32_t replyToMessageId, + ReplyParameters::Ptr replyParameters, InlineKeyboardMarkup::Ptr replyMarkup, bool disableNotification, - bool allowSendingWithoutReply, - bool protectContent, - std::int32_t messageThreadId) const { + std::int32_t messageThreadId, + bool protectContent) const { std::vector args; - args.reserve(8); + args.reserve(7); args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { @@ -2598,11 +2640,8 @@ Message::Ptr Api::sendGame(std::int64_t chatId, if (protectContent) { args.emplace_back("protect_content", protectContent); } - if (replyToMessageId) { - args.emplace_back("reply_to_message_id", replyToMessageId); - } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (replyParameters != nullptr) { + args.emplace_back("reply_parameters", _tgTypeParser.parseReplyParameters(replyParameters)); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); -- cgit v1.2.3