From 349a54107d23ab58cff9afccad27741fa3ad8937 Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Fri, 9 Sep 2022 16:57:08 +0200 Subject: Update to API 5.6 --- src/Api.cpp | 342 ++++++++++++++++++++++++++++++++------------------- src/TgTypeParser.cpp | 8 +- 2 files changed, 222 insertions(+), 128 deletions(-) (limited to 'src') diff --git a/src/Api.cpp b/src/Api.cpp index c1c86d2..bb63721 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -109,9 +109,10 @@ Message::Ptr Api::sendMessage(boost::variant c const std::string& parseMode, bool disableNotification, const std::vector& entities, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector args; - args.reserve(9); + args.reserve(10); args.emplace_back("chat_id", chatId); args.emplace_back("text", text); @@ -127,6 +128,9 @@ Message::Ptr Api::sendMessage(boost::variant c if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } @@ -140,24 +144,40 @@ Message::Ptr Api::sendMessage(boost::variant c return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendMessage", args)); } -Message::Ptr Api::forwardMessage(std::int64_t chatId, std::int64_t fromChatId, std::int32_t messageId, bool disableNotification) const { +Message::Ptr Api::forwardMessage(boost::variant chatId, + boost::variant fromChatId, + std::int32_t messageId, + bool disableNotification, + bool protectContent) const { vector args; - args.reserve(4); + args.reserve(5); + args.emplace_back("chat_id", chatId); args.emplace_back("from_chat_id", fromChatId); - args.emplace_back("message_id", messageId); if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } + args.emplace_back("message_id", messageId); + return _tgTypeParser.parseJsonAndGetMessage(sendRequest("forwardMessage", args)); } -MessageId::Ptr Api::copyMessage(std::int64_t chatId, std::int64_t fromChatId, std::int32_t messageId, - const std::string& caption, const std::string& parseMode, const std::vector& captionEntities, - bool disableNotification, std::int32_t replyToMessageId, bool allowSendingWithoutReply, - GenericReply::Ptr replyMarkup) const { +MessageId::Ptr Api::copyMessage(boost::variant chatId, + boost::variant fromChatId, + std::int32_t messageId, + const std::string& caption, + const std::string& parseMode, + const std::vector& captionEntities, + bool disableNotification, + std::int32_t replyToMessageId, + bool allowSendingWithoutReply, + GenericReply::Ptr replyMarkup, + bool protectContent) const { vector args; - args.reserve(10); + args.reserve(11); args.emplace_back("chat_id", chatId); args.emplace_back("from_chat_id", fromChatId); @@ -174,6 +194,9 @@ MessageId::Ptr Api::copyMessage(std::int64_t chatId, std::int64_t fromChatId, st if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } @@ -187,24 +210,25 @@ MessageId::Ptr Api::copyMessage(std::int64_t chatId, std::int64_t fromChatId, st return _tgTypeParser.parseJsonAndGetMessageId(sendRequest("copyMessage", args)); } -Message::Ptr Api::sendPhoto(std::int64_t chatId, - boost::variant photo, +Message::Ptr Api::sendPhoto(boost::variant chatId, + boost::variant photo, const std::string& caption, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const std::string& parseMode, bool disableNotification, const std::vector& captionEntities, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector args; - args.reserve(9); + args.reserve(10); args.emplace_back("chat_id", chatId); - if (photo.which() == 0 /* InputFile::Ptr */) { + if (photo.which() == 0) { // InputFile::Ptr auto file = boost::get(photo); args.emplace_back("photo", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("photo", boost::get(photo)); + } else { // const std::string& + args.emplace_back("photo", boost::get(photo)); } if (!caption.empty()) { args.emplace_back("caption", caption); @@ -218,6 +242,9 @@ Message::Ptr Api::sendPhoto(std::int64_t chatId, if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } @@ -231,28 +258,29 @@ Message::Ptr Api::sendPhoto(std::int64_t chatId, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendPhoto", args)); } -Message::Ptr Api::sendAudio(std::int64_t chatId, - boost::variant audio, +Message::Ptr Api::sendAudio(boost::variant chatId, + boost::variant audio, const std::string& caption, std::int32_t duration, const std::string& performer, const std::string& title, - boost::variant thumb, + boost::variant thumb, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const std::string& parseMode, bool disableNotification, const std::vector& captionEntities, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector args; - args.reserve(13); + args.reserve(14); args.emplace_back("chat_id", chatId); - if (audio.which() == 0 /* InputFile::Ptr */) { + if (audio.which() == 0) { // InputFile::Ptr auto file = boost::get(audio); args.emplace_back("audio", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("audio", boost::get(audio)); + } else { // const std::string& + args.emplace_back("audio", boost::get(audio)); } if (!caption.empty()) { args.emplace_back("caption", caption); @@ -272,11 +300,11 @@ Message::Ptr Api::sendAudio(std::int64_t chatId, if (!title.empty()) { args.emplace_back("title", title); } - if (thumb.which() == 0 /* InputFile::Ptr */) { + if (thumb.which() == 0) { // InputFile::Ptr auto file = boost::get(thumb); args.emplace_back("thumb", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - auto thumbStr = boost::get(thumb); + } else { // const std::string& + auto thumbStr = boost::get(thumb); if (!thumbStr.empty()) { args.emplace_back("thumb", thumbStr); } @@ -284,6 +312,9 @@ Message::Ptr Api::sendAudio(std::int64_t chatId, if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } @@ -297,9 +328,9 @@ Message::Ptr Api::sendAudio(std::int64_t chatId, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendAudio", args)); } -Message::Ptr Api::sendDocument(std::int64_t chatId, - boost::variant document, - boost::variant thumb, +Message::Ptr Api::sendDocument(boost::variant chatId, + boost::variant document, + boost::variant thumb, const std::string& caption, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, @@ -307,22 +338,23 @@ Message::Ptr Api::sendDocument(std::int64_t chatId, bool disableNotification, const std::vector& captionEntities, bool disableContentTypeDetection, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector args; - args.reserve(11); + args.reserve(12); args.emplace_back("chat_id", chatId); - if (document.which() == 0 /* InputFile::Ptr */) { + if (document.which() == 0) { // InputFile::Ptr auto file = boost::get(document); args.emplace_back("document", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("document", boost::get(document)); + } else { // const std::string& + args.emplace_back("document", boost::get(document)); } - if (thumb.which() == 0 /* InputFile::Ptr */) { + if (thumb.which() == 0) { // InputFile::Ptr auto file = boost::get(thumb); args.emplace_back("thumb", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - auto thumbStr = boost::get(thumb); + } else { // const std::string& + auto thumbStr = boost::get(thumb); if (!thumbStr.empty()) { args.emplace_back("thumb", thumbStr); } @@ -342,6 +374,9 @@ Message::Ptr Api::sendDocument(std::int64_t chatId, if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } @@ -355,29 +390,30 @@ Message::Ptr Api::sendDocument(std::int64_t chatId, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendDocument", args)); } -Message::Ptr Api::sendVideo(std::int64_t chatId, - boost::variant video, +Message::Ptr Api::sendVideo(boost::variant chatId, + boost::variant video, bool supportsStreaming, std::int32_t duration, std::int32_t width, std::int32_t height, - boost::variant thumb, - const std::string& caption, + boost::variant thumb, + const std::string& caption , std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const std::string& parseMode, bool disableNotification, const std::vector& captionEntities, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector args; - args.reserve(14); + args.reserve(15); args.emplace_back("chat_id", chatId); - if (video.which() == 0 /* InputFile::Ptr */) { + if (video.which() == 0) { // InputFile::Ptr auto file = boost::get(video); args.emplace_back("video", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("video", boost::get(video)); + } else { // const std::string& + args.emplace_back("video", boost::get(video)); } if (duration) { args.emplace_back("duration", duration); @@ -388,11 +424,11 @@ Message::Ptr Api::sendVideo(std::int64_t chatId, if (height) { args.emplace_back("height", height); } - if (thumb.which() == 0 /* InputFile::Ptr */) { + if (thumb.which() == 0) { // InputFile::Ptr auto file = boost::get(thumb); args.emplace_back("thumb", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - auto thumbStr = boost::get(thumb); + } else { // const std::string& + auto thumbStr = boost::get(thumb); if (!thumbStr.empty()) { args.emplace_back("thumb", thumbStr); } @@ -412,6 +448,9 @@ Message::Ptr Api::sendVideo(std::int64_t chatId, if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } @@ -425,28 +464,29 @@ Message::Ptr Api::sendVideo(std::int64_t chatId, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVideo", args)); } -Message::Ptr Api::sendAnimation(std::int64_t chatId, - boost::variant animation, +Message::Ptr Api::sendAnimation(boost::variant chatId, + boost::variant animation, std::int32_t duration, std::int32_t width, std::int32_t height, - boost::variant thumb, + boost::variant thumb, const std::string& caption, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const std::string& parseMode, bool disableNotification, const std::vector& captionEntities, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector args; - args.reserve(13); + args.reserve(14); args.emplace_back("chat_id", chatId); - if (animation.which() == 0 /* InputFile::Ptr */) { + if (animation.which() == 0) { // InputFile::Ptr auto file = boost::get(animation); args.emplace_back("animation", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("animation", boost::get(animation)); + } else { // const std::string& + args.emplace_back("animation", boost::get(animation)); } if (duration) { args.emplace_back("duration", duration); @@ -457,11 +497,11 @@ Message::Ptr Api::sendAnimation(std::int64_t chatId, if (height) { args.emplace_back("height", height); } - if (thumb.which() == 0 /* InputFile::Ptr */) { + if (thumb.which() == 0) { // InputFile::Ptr auto file = boost::get(thumb); args.emplace_back("thumb", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - auto thumbStr = boost::get(thumb); + } else { // const std::string& + auto thumbStr = boost::get(thumb); if (!thumbStr.empty()) { args.emplace_back("thumb", thumbStr); } @@ -478,6 +518,9 @@ Message::Ptr Api::sendAnimation(std::int64_t chatId, if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } @@ -491,8 +534,8 @@ Message::Ptr Api::sendAnimation(std::int64_t chatId, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendAnimation", args)); } -Message::Ptr Api::sendVoice(std::int64_t chatId, - boost::variant voice, +Message::Ptr Api::sendVoice(boost::variant chatId, + boost::variant voice, const std::string& caption, std::int32_t duration, std::int32_t replyToMessageId, @@ -500,16 +543,17 @@ Message::Ptr Api::sendVoice(std::int64_t chatId, const std::string& parseMode, bool disableNotification, const std::vector& captionEntities, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector args; - args.reserve(10); + args.reserve(11); args.emplace_back("chat_id", chatId); - if (voice.which() == 0 /* InputFile::Ptr */) { + if (voice.which() == 0) { // InputFile::Ptr auto file = boost::get(voice); args.emplace_back("voice", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("voice", boost::get(voice)); + } else { // const std::string& + args.emplace_back("voice", boost::get(voice)); } if (!caption.empty()) { args.emplace_back("caption", caption); @@ -526,6 +570,9 @@ Message::Ptr Api::sendVoice(std::int64_t chatId, if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } @@ -539,24 +586,25 @@ Message::Ptr Api::sendVoice(std::int64_t chatId, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVoice", args)); } -Message::Ptr Api::sendVideoNote(std::int64_t chatId, - boost::variant videoNote, +Message::Ptr Api::sendVideoNote(boost::variant chatId, + boost::variant videoNote, std::int64_t replyToMessageId, bool disableNotification, std::int32_t duration, std::int32_t length, - boost::variant thumb, + boost::variant thumb, GenericReply::Ptr replyMarkup, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector args; - args.reserve(9); + args.reserve(10); args.emplace_back("chat_id", chatId); - if (videoNote.which() == 0 /* InputFile::Ptr */) { + if (videoNote.which() == 0) { // InputFile::Ptr auto file = boost::get(videoNote); args.emplace_back("video_note", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("video_note", boost::get(videoNote)); + } else { // const std::string& + args.emplace_back("video_note", boost::get(videoNote)); } if (duration) { args.emplace_back("duration", duration); @@ -564,11 +612,11 @@ Message::Ptr Api::sendVideoNote(std::int64_t chatId, if (length) { args.emplace_back("length", length); } - if (thumb.which() == 0 /* InputFile::Ptr */) { + if (thumb.which() == 0) { // InputFile::Ptr auto file = boost::get(thumb); args.emplace_back("thumb", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - auto thumbStr = boost::get(thumb); + } else { // const std::string& + auto thumbStr = boost::get(thumb); if (!thumbStr.empty()) { args.emplace_back("thumb", thumbStr); } @@ -576,6 +624,9 @@ Message::Ptr Api::sendVideoNote(std::int64_t chatId, if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } @@ -589,16 +640,23 @@ Message::Ptr Api::sendVideoNote(std::int64_t chatId, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVideoNote", args)); } -vector Api::sendMediaGroup(std::int64_t chatId, const std::vector& media, bool disableNotification, - std::int32_t replyToMessageId, bool allowSendingWithoutReply) const { +vector Api::sendMediaGroup(boost::variant chatId, + const std::vector& media, + bool disableNotification, + std::int32_t replyToMessageId, + bool allowSendingWithoutReply, + bool protectContent) const { vector args; - args.reserve(5); + args.reserve(6); args.emplace_back("chat_id", chatId); args.emplace_back("media", _tgTypeParser.parseArray(&TgTypeParser::parseInputMedia, media)); if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId != 0) { args.emplace_back("reply_to_message_id", replyToMessageId); } @@ -609,19 +667,20 @@ vector Api::sendMediaGroup(std::int64_t chatId, const std::vector< return _tgTypeParser.parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetMessage, sendRequest("sendMediaGroup", args)); } -Message::Ptr Api::sendLocation(std::int64_t chatId, +Message::Ptr Api::sendLocation(boost::variant chatId, float latitude, float longitude, - std::uint32_t livePeriod, + std::int32_t livePeriod, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, bool disableNotification, float horizontalAccuracy, - std::uint32_t heading, - std::uint32_t proximityAlertRadius, - bool allowSendingWithoutReply) const { + std::int32_t heading, + std::int32_t proximityAlertRadius, + bool allowSendingWithoutReply, + bool protectContent) const { vector args; - args.reserve(11); + args.reserve(12); args.emplace_back("chat_id", chatId); args.emplace_back("latitude", latitude); @@ -641,6 +700,9 @@ Message::Ptr Api::sendLocation(std::int64_t chatId, if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } @@ -711,7 +773,7 @@ Message::Ptr Api::stopMessageLiveLocation(std::int64_t chatId, std::int32_t mess return _tgTypeParser.parseJsonAndGetMessage(sendRequest("editMessageLiveLocation", args)); } -Message::Ptr Api::sendVenue(std::int64_t chatId, +Message::Ptr Api::sendVenue(boost::variant chatId, float latitude, float longitude, const std::string& title, @@ -723,9 +785,10 @@ Message::Ptr Api::sendVenue(std::int64_t chatId, GenericReply::Ptr replyMarkup, const std::string& googlePlaceId, const std::string& googlePlaceType, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector args; - args.reserve(13); + args.reserve(14); args.emplace_back("chat_id", chatId); args.emplace_back("latitude", latitude); @@ -747,6 +810,9 @@ Message::Ptr Api::sendVenue(std::int64_t chatId, if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } @@ -760,17 +826,18 @@ Message::Ptr Api::sendVenue(std::int64_t chatId, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVenue", args)); } -Message::Ptr Api::sendContact(std::int64_t chatId, - const std::string& phoneNumber, - const std::string& firstName, - const std::string& lastName, - const std::string& vcard, - bool disableNotification, - std::int32_t replyToMessageId, - GenericReply::Ptr replyMarkup, - bool allowSendingWithoutReply) const { +Message::Ptr Api::sendContact(boost::variant chatId, + const std::string& phoneNumber, + const std::string& firstName, + const std::string& lastName , + const std::string& vcard, + bool disableNotification, + std::int32_t replyToMessageId, + GenericReply::Ptr replyMarkup, + bool allowSendingWithoutReply, + bool protectContent) const { vector args; - args.reserve(9); + args.reserve(10); args.emplace_back("chat_id", chatId); args.emplace_back("phone_number", phoneNumber); @@ -784,6 +851,9 @@ Message::Ptr Api::sendContact(std::int64_t chatId, if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } @@ -797,7 +867,7 @@ Message::Ptr Api::sendContact(std::int64_t chatId, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendContact", args)); } -Message::Ptr Api::sendPoll(std::int64_t chatId, +Message::Ptr Api::sendPoll(boost::variant chatId, const std::string& question, const std::vector& options, bool disableNotification, @@ -813,9 +883,10 @@ Message::Ptr Api::sendPoll(std::int64_t chatId, std::int32_t openPeriod, std::int32_t closeDate, bool isClosed, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector args; - args.reserve(17); + args.reserve(18); args.emplace_back("chat_id", chatId); args.emplace_back("question", question); @@ -855,6 +926,9 @@ Message::Ptr Api::sendPoll(std::int64_t chatId, if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId != 0) { args.emplace_back("reply_to_message_id", replyToMessageId); } @@ -868,24 +942,32 @@ Message::Ptr Api::sendPoll(std::int64_t chatId, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendPoll", args)); } -Message::Ptr Api::sendDice(std::int64_t chatId, +Message::Ptr Api::sendDice(boost::variant chatId, bool disableNotification, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const std::string& emoji, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector args; - args.reserve(6); + args.reserve(7); args.emplace_back("chat_id", chatId); if (!emoji.empty()) { args.emplace_back("emoji", emoji); } - args.emplace_back("disable_notification", disableNotification); + if (disableNotification) { + args.emplace_back("disable_notification", disableNotification); + } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId != 0) { args.emplace_back("reply_to_message_id", replyToMessageId); } - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); } @@ -1104,7 +1186,7 @@ ChatInviteLink::Ptr Api::createChatInviteLink(std::int64_t chatId, } ChatInviteLink::Ptr Api::editChatInviteLink(std::int64_t chatId, - std::string inviteLink, + const std::string& inviteLink, std::int32_t expireDate, std::int32_t memberLimit, const std::string& name, @@ -1131,7 +1213,7 @@ ChatInviteLink::Ptr Api::editChatInviteLink(std::int64_t chatId, } ChatInviteLink::Ptr Api::revokeChatInviteLink(std::int64_t chatId, - std::string inviteLink) const { + const std::string& inviteLink) const { vector args; args.reserve(2); @@ -1493,25 +1575,29 @@ 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::sendSticker(std::int64_t chatId, - boost::variant sticker, +Message::Ptr Api::sendSticker(boost::variant chatId, + boost::variant sticker, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, bool disableNotification, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector args; - args.reserve(6); + args.reserve(7); args.emplace_back("chat_id", chatId); - if (sticker.which() == 0 /* InputFile::Ptr */) { + if (sticker.which() == 0) { // InputFile::Ptr auto file = boost::get(sticker); args.emplace_back("sticker", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("sticker", boost::get(sticker)); + } else { // const std::string& + args.emplace_back("sticker", boost::get(sticker)); } if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } @@ -1666,7 +1752,7 @@ bool Api::answerInlineQuery(const string& inlineQueryId, const std::vector("", false); } -Message::Ptr Api::sendInvoice(std::int64_t chatId, +Message::Ptr Api::sendInvoice(boost::variant chatId, const std::string& title, const std::string& description, const std::string& payload, @@ -1691,9 +1777,10 @@ Message::Ptr Api::sendInvoice(std::int64_t chatId, bool allowSendingWithoutReply, std::int32_t maxTipAmount, const std::vector& suggestedTipAmounts, - const std::string& startParameter) const { + const std::string& startParameter, + bool protectContent) const { vector args; - args.reserve(26); + args.reserve(27); args.emplace_back("chat_id", chatId); args.emplace_back("title", title); @@ -1750,6 +1837,9 @@ Message::Ptr Api::sendInvoice(std::int64_t chatId, if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } @@ -1803,15 +1893,19 @@ Message::Ptr Api::sendGame(std::int64_t chatId, std::int32_t replyToMessageId, InlineKeyboardMarkup::Ptr replyMarkup, bool disableNotification, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector args; - args.reserve(6); + args.reserve(7); args.emplace_back("chat_id", chatId); args.emplace_back("game_short_name", gameShortName); if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (protectContent) { + args.emplace_back("protect_content", protectContent); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp index e8a81d7..85b44e8 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -1519,7 +1519,7 @@ ChatMemberRestricted::Ptr TgTypeParser::parseJsonAndGetChatMemberRestricted(cons result->canSendPolls = data.get("can_send_polls", false); result->canSendOtherMessages = data.get("can_send_other_messages", false); result->canAddWebPagePreviews = data.get("can_add_web_page_previews", false); - result->untilDate = data.get("until_date", 0); + result->untilDate = data.get("until_date", 0); return result; } @@ -1666,9 +1666,9 @@ ChatInviteLink::Ptr TgTypeParser::parseJsonAndGetChatInviteLink(const boost::pro result->isPrimary = data.get("is_primary", false); result->isRevoked = data.get("is_revoked", false); result->name = data.get("name", ""); - result->expireDate = data.get("expire_date", 0); - result->memberLimit = data.get("member_limit", 0); - result->pendingJoinRequestCount = data.get("pending_join_request_count", 0); + result->expireDate = data.get("expire_date", 0); + result->memberLimit = data.get("member_limit", 0); + result->pendingJoinRequestCount = data.get("pending_join_request_count", 0); return result; } -- cgit v1.2.3