From c17ab6fb6574bdea6fc9011be0651dc74aa6a53e Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Sat, 3 Sep 2022 22:41:05 +0200 Subject: Update to API 5.0 --- src/Api.cpp | 660 ++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 514 insertions(+), 146 deletions(-) (limited to 'src/Api.cpp') diff --git a/src/Api.cpp b/src/Api.cpp index 070d72e..86d573b 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -40,15 +40,18 @@ vector Api::getUpdates(std::int32_t offset, std::int32_t limit, std return _tgTypeParser.parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetUpdate, sendRequest("getUpdates", args)); } -void Api::setWebhook(const string& url, const InputFile::Ptr certificate, std::int32_t maxConnection, const StringArrayPtr& allowedUpdates) const { +bool Api::setWebhook(const std::string& url, InputFile::Ptr certificate, const std::string& ipAddress, + std::int32_t maxConnection, const StringArrayPtr& allowedUpdates, bool dropPendingUpdates) const { vector args; - args.reserve(4); - if (!url.empty()) { - args.emplace_back("url", url); - } + args.reserve(6); + + args.emplace_back("url", url); if (certificate != nullptr) { args.emplace_back("certificate", certificate->data, true, certificate->mimeType, certificate->fileName); } + if (!ipAddress.empty()) { + args.emplace_back("ip_address", ipAddress); + } if (maxConnection != 40) { args.emplace_back("max_connections", maxConnection); } @@ -59,11 +62,21 @@ void Api::setWebhook(const string& url, const InputFile::Ptr certificate, std::i }, *allowedUpdates); args.emplace_back("allowed_updates", allowedUpdatesJson); } + if (dropPendingUpdates) { + args.emplace_back("drop_pending_updates", dropPendingUpdates); + } - sendRequest("setWebhook", args); + return sendRequest("setWebhook").get("", false); } -bool Api::deleteWebhook() const { +bool Api::deleteWebhook(bool dropPendingUpdates) const { + vector args; + args.reserve(1); + + if (dropPendingUpdates) { + args.emplace_back("drop_pending_updates", dropPendingUpdates); + } + return sendRequest("deleteWebhook").get("", false); } @@ -84,17 +97,20 @@ User::Ptr Api::getMe() const { return _tgTypeParser.parseJsonAndGetUser(sendRequest("getMe")); } -Message::Ptr Api::sendMessage(boost::variant chatId, const std::string& text, bool disableWebPagePreview, - std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const std::string& parseMode, - bool disableNotification) const { +Message::Ptr Api::sendMessage(boost::variant chatId, const std::string& text, const std::string& parseMode, + const std::vector& entities, bool disableWebPagePreview, bool disableNotification, + std::int32_t replyToMessageId, bool allowSendingWithoutReply, GenericReply::Ptr replyMarkup) const { vector args; - args.reserve(7); + args.reserve(9); args.emplace_back("chat_id", chatId); args.emplace_back("text", text); if (!parseMode.empty()) { args.emplace_back("parse_mode", parseMode); } + if (!entities.empty()) { + args.emplace_back("entities", _tgTypeParser.parseArray(&TgTypeParser::parseMessageEntity, entities)); + } if (disableWebPagePreview) { args.emplace_back("disable_web_page_preview", disableWebPagePreview); } @@ -104,6 +120,9 @@ Message::Ptr Api::sendMessage(boost::variant c if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); } @@ -123,37 +142,95 @@ Message::Ptr Api::forwardMessage(std::int64_t chatId, std::int64_t fromChatId, s return _tgTypeParser.parseJsonAndGetMessage(sendRequest("forwardMessage", args)); } -Message::Ptr Api::sendPhoto(std::int64_t chatId, boost::variant photo, const string& caption, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { +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 { vector args; - args.reserve(7); + args.reserve(10); + args.emplace_back("chat_id", chatId); - 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)); - } + args.emplace_back("from_chat_id", fromChatId); + args.emplace_back("message_id", messageId); if (!caption.empty()) { args.emplace_back("caption", caption); } + if (!parseMode.empty()) { + args.emplace_back("parse_mode", parseMode); + } + if (!captionEntities.empty()) { + args.emplace_back("caption_entities", _tgTypeParser.parseArray(&TgTypeParser::parseMessageEntity, captionEntities)); + } + if (disableNotification) { + args.emplace_back("disable_notification", disableNotification); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); } + + return _tgTypeParser.parseJsonAndGetMessageId(sendRequest("copyMessage", args)); +} + +Message::Ptr Api::sendPhoto(std::int64_t chatId, boost::variant photo, const std::string& caption, + const std::string& parseMode, const std::vector& captionEntities, bool disableNotification, + std::int32_t replyToMessageId, bool allowSendingWithoutReply, GenericReply::Ptr replyMarkup) const { + vector args; + args.reserve(9); + + args.emplace_back("chat_id", chatId); + 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)); + } + if (!caption.empty()) { + args.emplace_back("caption", caption); + } if (!parseMode.empty()) { args.emplace_back("parse_mode", parseMode); } + if (!captionEntities.empty()) { + args.emplace_back("caption_entities", _tgTypeParser.parseArray(&TgTypeParser::parseMessageEntity, captionEntities)); + } if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (replyToMessageId) { + args.emplace_back("reply_to_message_id", replyToMessageId); + } + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } + if (replyMarkup) { + args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); + } + return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendPhoto", args)); } -Message::Ptr Api::sendAudio(std::int64_t chatId, boost::variant audio, const string& caption, std::int32_t duration, const string& performer, const string& title, boost::variant thumb, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { +Message::Ptr Api::sendAudio(std::int64_t chatId, + boost::variant audio, + const std::string& caption, + const std::string& parseMode, + const std::vector& captionEntities, + std::int32_t duration, + const std::string& performer, + const std::string& title, + boost::variant thumb, + bool disableNotification, + std::int32_t replyToMessageId, + bool allowSendingWithoutReply, + GenericReply::Ptr replyMarkup) const { vector args; - args.reserve(11); + args.reserve(13); + args.emplace_back("chat_id", chatId); if (audio.which() == 0 /* InputFile::Ptr */) { auto file = boost::get(audio); @@ -164,6 +241,12 @@ Message::Ptr Api::sendAudio(std::int64_t chatId, boost::variant(&TgTypeParser::parseMessageEntity, captionEntities)); + } if (duration) { args.emplace_back("duration", duration); } @@ -182,24 +265,36 @@ Message::Ptr Api::sendAudio(std::int64_t chatId, boost::variant document, boost::variant thumb, const string& caption, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { +Message::Ptr Api::sendDocument(std::int64_t chatId, + boost::variant document, + boost::variant thumb, + const std::string& caption, + const std::string& parseMode, + const std::vector& captionEntities, + bool disableContentTypeDetection, + bool disableNotification, + std::int32_t replyToMessageId, + bool allowSendingWithoutReply, + GenericReply::Ptr replyMarkup) const { vector args; - args.reserve(8); + args.reserve(11); + args.emplace_back("chat_id", chatId); if (document.which() == 0 /* InputFile::Ptr */) { auto file = boost::get(document); @@ -219,24 +314,48 @@ Message::Ptr Api::sendDocument(std::int64_t chatId, boost::variant(&TgTypeParser::parseMessageEntity, captionEntities)); + } + if (disableContentTypeDetection) { + args.emplace_back("disable_content_type_detection", disableContentTypeDetection); + } if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (replyToMessageId) { + args.emplace_back("reply_to_message_id", replyToMessageId); + } + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } + if (replyMarkup) { + args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); + } + return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendDocument", args)); } -Message::Ptr Api::sendVideo(std::int64_t chatId, boost::variant video, bool supportsStreaming, std::int32_t duration, std::int32_t width, std::int32_t height, boost::variant thumb, const string& caption, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { +Message::Ptr Api::sendVideo(std::int64_t chatId, + boost::variant video, + std::int32_t duration, + std::int32_t width, + std::int32_t height, + boost::variant thumb, + const std::string& caption, + const std::string& parseMode, + const std::vector& captionEntities, + bool supportsStreaming, + bool disableNotification, + std::int32_t replyToMessageId, + bool allowSendingWithoutReply, + GenericReply::Ptr replyMarkup) const { vector args; - args.reserve(12); + args.reserve(14); + args.emplace_back("chat_id", chatId); if (video.which() == 0 /* InputFile::Ptr */) { auto file = boost::get(video); @@ -244,9 +363,6 @@ Message::Ptr Api::sendVideo(std::int64_t chatId, boost::variant(video)); } - if (supportsStreaming) { - args.emplace_back("supports_streaming", supportsStreaming); - } if (duration) { args.emplace_back("duration", duration); } @@ -268,24 +384,47 @@ Message::Ptr Api::sendVideo(std::int64_t chatId, boost::variant(&TgTypeParser::parseMessageEntity, captionEntities)); + } + if (supportsStreaming) { + args.emplace_back("supports_streaming", supportsStreaming); + } if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (replyToMessageId) { + args.emplace_back("reply_to_message_id", replyToMessageId); + } + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } + if (replyMarkup) { + args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); + } + return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVideo", args)); } -Message::Ptr Api::sendAnimation(std::int64_t chatId, boost::variant animation, std::int32_t duration, std::int32_t width, std::int32_t height, boost::variant thumb, const string& caption, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { +Message::Ptr Api::sendAnimation(std::int64_t chatId, + boost::variant animation, + std::int32_t duration, + std::int32_t width, + std::int32_t height, + boost::variant thumb, + const std::string& caption, + const std::string& parseMode, + const std::vector& captionEntities, + bool disableNotification, + std::int32_t replyToMessageId, + bool allowSendingWithoutReply, + GenericReply::Ptr replyMarkup) const { vector args; - args.reserve(11); + args.reserve(13); + args.emplace_back("chat_id", chatId); if (animation.which() == 0 /* InputFile::Ptr */) { auto file = boost::get(animation); @@ -314,24 +453,41 @@ Message::Ptr Api::sendAnimation(std::int64_t chatId, boost::variant(&TgTypeParser::parseMessageEntity, captionEntities)); + } if (disableNotification) { args.emplace_back("disable_notification", disableNotification); } + if (replyToMessageId) { + args.emplace_back("reply_to_message_id", replyToMessageId); + } + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } + if (replyMarkup) { + args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); + } + return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendAnimation", args)); } -Message::Ptr Api::sendVoice(std::int64_t chatId, boost::variant voice, const string& caption, int duration, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { +Message::Ptr Api::sendVoice(std::int64_t chatId, + boost::variant voice, + const std::string& caption, + const std::string& parseMode, + const std::vector& captionEntities, + std::int32_t duration, + bool disableNotification, + std::int32_t replyToMessageId, + bool allowSendingWithoutReply, + GenericReply::Ptr replyMarkup) const { vector args; - args.reserve(8); + args.reserve(10); + args.emplace_back("chat_id", chatId); if (voice.which() == 0 /* InputFile::Ptr */) { auto file = boost::get(voice); @@ -342,27 +498,43 @@ Message::Ptr Api::sendVoice(std::int64_t chatId, boost::variant(&TgTypeParser::parseMessageEntity, captionEntities)); + } if (duration) { args.emplace_back("duration", duration); } + if (disableNotification) { + args.emplace_back("disable_notification", disableNotification); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); } - if (!parseMode.empty()) { - args.emplace_back("parse_mode", parseMode); - } - if (disableNotification) { - args.emplace_back("disable_notification", disableNotification); - } + return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVoice", args)); } -Message::Ptr Api::sendVideoNote(std::int64_t chatId, boost::variant videoNote, std::int64_t replyToMessageId, bool disableNotification, std::int32_t duration, std::int32_t length, boost::variant thumb, const GenericReply::Ptr replyMarkup) const { +Message::Ptr Api::sendVideoNote(std::int64_t chatId, + boost::variant videoNote, + std::int32_t duration, + std::int32_t length, + boost::variant thumb, + bool disableNotification, + std::int32_t replyToMessageId, + bool allowSendingWithoutReply, + GenericReply::Ptr replyMarkup) const { vector args; - args.reserve(8); + args.reserve(9); + args.emplace_back("chat_id", chatId); if (videoNote.which() == 0 /* InputFile::Ptr */) { auto file = boost::get(videoNote); @@ -370,9 +542,6 @@ Message::Ptr Api::sendVideoNote(std::int64_t chatId, boost::variant(videoNote)); } - if (disableNotification) { - args.emplace_back("disable_notification", disableNotification); - } if (duration) { args.emplace_back("duration", duration); } @@ -388,52 +557,86 @@ Message::Ptr Api::sendVideoNote(std::int64_t chatId, boost::variant Api::sendMediaGroup(std::int64_t chatId, const vector& media, bool disableNotification, std::int32_t replyToMessageId) const { +vector Api::sendMediaGroup(std::int64_t chatId, const std::vector& media, bool disableNotification, + std::int32_t replyToMessageId, bool allowSendingWithoutReply) const { vector args; - args.reserve(4); + args.reserve(5); + args.emplace_back("chat_id", chatId); - string mediaJson = _tgTypeParser.parseArray(&TgTypeParser::parseInputMedia, media); - args.emplace_back("media", mediaJson); - args.emplace_back("disable_notification", disableNotification); - args.emplace_back("reply_to_message_id", replyToMessageId); + args.emplace_back("media", _tgTypeParser.parseArray(&TgTypeParser::parseInputMedia, media)); + if (disableNotification) { + args.emplace_back("disable_notification", disableNotification); + } + if (replyToMessageId != 0) { + args.emplace_back("reply_to_message_id", replyToMessageId); + } + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } + return _tgTypeParser.parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetMessage, sendRequest("sendMediaGroup", args)); } -Message::Ptr Api::sendLocation(std::int64_t chatId, float latitude, float longitude, std::uint32_t livePeriod, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const { +Message::Ptr Api::sendLocation(std::int64_t chatId, float latitude, float longitude, + float horizontalAccuracy, std::uint32_t livePeriod, std::uint32_t heading, + std::uint32_t proximityAlertRadius, bool disableNotification, std::int32_t replyToMessageId, + bool allowSendingWithoutReply, GenericReply::Ptr replyMarkup) const { vector args; - args.reserve(7); + args.reserve(11); + args.emplace_back("chat_id", chatId); args.emplace_back("latitude", latitude); args.emplace_back("longitude", longitude); + if (horizontalAccuracy) { + args.emplace_back("horizontal_accuracy", horizontalAccuracy); + } if (livePeriod) { args.emplace_back("live_period", livePeriod); } + if (heading) { + args.emplace_back("heading", heading); + } + if (proximityAlertRadius) { + args.emplace_back("proximity_alert_radius", proximityAlertRadius); + } + if (disableNotification) { + args.emplace_back("disable_notification", disableNotification); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); } - if (disableNotification) { - args.emplace_back("disable_notification", disableNotification); - } + return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendLocation", args)); } -Message::Ptr Api::editMessageLiveLocation(float latitude, float longitude, std::int64_t chatId, std::int32_t messageId, std::int32_t inlineMessageId, const InlineKeyboardMarkup::Ptr replyMarkup) const { +Message::Ptr Api::editMessageLiveLocation(float latitude, float longitude, std::int64_t chatId, + std::int32_t messageId, std::int32_t inlineMessageId, float horizontalAccuracy, + std::int32_t heading, std::int32_t proximityAlertRadius, InlineKeyboardMarkup::Ptr replyMarkup) const { vector args; - args.reserve(6); - args.emplace_back("latitude", latitude); - args.emplace_back("longitude", longitude); + args.reserve(9); + if (chatId) { args.emplace_back("chat_id", chatId); } @@ -443,9 +646,21 @@ Message::Ptr Api::editMessageLiveLocation(float latitude, float longitude, std:: if (inlineMessageId) { args.emplace_back("inline_message_id", inlineMessageId); } + args.emplace_back("latitude", latitude); + args.emplace_back("longitude", longitude); + if (horizontalAccuracy) { + args.emplace_back("horizontal_accuracy", horizontalAccuracy); + } + if (heading) { + args.emplace_back("heading", heading); + } + if (proximityAlertRadius) { + args.emplace_back("proximity_alert_radius", proximityAlertRadius); + } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseInlineKeyboardMarkup(replyMarkup)); } + return _tgTypeParser.parseJsonAndGetMessage(sendRequest("editMessageLiveLocation", args)); } @@ -467,9 +682,22 @@ 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, float latitude, float longitude, const string& title, const string& address, const string& foursquareId, const string& foursquareType, bool disableNotification, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const { +Message::Ptr Api::sendVenue(std::int64_t chatId, + float latitude, + float longitude, + const std::string& title, + const std::string& address, + const std::string& foursquareId, + const std::string& foursquareType, + const std::string& googlePlaceId, + const std::string& googlePlaceType, + bool disableNotification, + std::int32_t replyToMessageId, + bool allowSendingWithoutReply, + GenericReply::Ptr replyMarkup) const { vector args; - args.reserve(10); + args.reserve(13); + args.emplace_back("chat_id", chatId); args.emplace_back("latitude", latitude); args.emplace_back("longitude", longitude); @@ -481,21 +709,40 @@ Message::Ptr Api::sendVenue(std::int64_t chatId, float latitude, float longitude if (!foursquareType.empty()) { args.emplace_back("foursquare_type", foursquareType); } + if (!googlePlaceId.empty()) { + args.emplace_back("google_place_id", googlePlaceId); + } + if (!googlePlaceType.empty()) { + args.emplace_back("google_place_type", googlePlaceType); + } + if (disableNotification) { + args.emplace_back("disable_notification", disableNotification); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); } - if (disableNotification) { - args.emplace_back("disable_notification", disableNotification); - } + return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVenue", args)); } -Message::Ptr Api::sendContact(std::int64_t chatId, const string& phoneNumber, const string& firstName, const string& lastName, const string& vcard, bool disableNotification, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const { +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, + bool allowSendingWithoutReply, + GenericReply::Ptr replyMarkup) const { vector args; - args.reserve(8); + args.reserve(9); + args.emplace_back("chat_id", chatId); args.emplace_back("phone_number", phoneNumber); args.emplace_back("first_name", firstName); @@ -505,25 +752,41 @@ Message::Ptr Api::sendContact(std::int64_t chatId, const string& phoneNumber, co if (!vcard.empty()) { args.emplace_back("vcard", vcard); } + if (disableNotification) { + args.emplace_back("disable_notification", disableNotification); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); } - if (disableNotification) { - args.emplace_back("disable_notification", disableNotification); - } + return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendContact", args)); } -Message::Ptr Api::sendPoll(std::int64_t chatId, const std::string& question, const std::vector& options, - bool isAnonymous, const std::string& type, bool allowsMultipleAnswers, - std::int32_t correctOptionId, const std::string& explanation, const std::string& explanationParseMode, - std::int32_t openPeriod, std::int64_t closeDate, bool isClosed, - bool disableNotification, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup) const { - vector args; - args.reserve(15); +Message::Ptr Api::sendPoll(std::int64_t chatId, + const std::string& question, + const std::vector& options, + bool isAnonymous, + const std::string& type, + bool allowsMultipleAnswers, + std::int32_t correctOptionId, + const std::string& explanation, + const std::string& explanationParseMode, + const std::vector& explanationEntities, + std::int32_t openPeriod, + std::int32_t closeDate, + bool isClosed, + bool disableNotification, + std::int32_t replyToMessageId, + bool allowSendingWithoutReply, + GenericReply::Ptr replyMarkup) const { + vector args; + args.reserve(17); args.emplace_back("chat_id", chatId); args.emplace_back("question", question); @@ -548,6 +811,9 @@ Message::Ptr Api::sendPoll(std::int64_t chatId, const std::string& question, con if (!explanationParseMode.empty()) { args.emplace_back("explanation_parse_mode", explanationParseMode); } + if (!explanationEntities.empty()) { + args.emplace_back("explanation_entities", _tgTypeParser.parseArray(&TgTypeParser::parseMessageEntity, explanationEntities)); + } if (openPeriod != 0) { args.emplace_back("open_period", openPeriod); } @@ -563,6 +829,9 @@ Message::Ptr Api::sendPoll(std::int64_t chatId, const std::string& question, con if (replyToMessageId != 0) { args.emplace_back("reply_to_message_id", replyToMessageId); } + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); } @@ -570,21 +839,28 @@ 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, const std::string& emoji, bool disableNotification, - std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup) const { +Message::Ptr Api::sendDice(std::int64_t chatId, + const std::string& emoji, + bool disableNotification, + std::int32_t replyToMessageId, + bool allowSendingWithoutReply, + GenericReply::Ptr replyMarkup) const { vector args; - args.reserve(5); + args.reserve(6); args.emplace_back("chat_id", chatId); - if (disableNotification) { - args.emplace_back("disable_notification", disableNotification); - } if (!emoji.empty()) { args.emplace_back("emoji", emoji); } + if (disableNotification) { + args.emplace_back("disable_notification", disableNotification); + } if (replyToMessageId != 0) { args.emplace_back("reply_to_message_id", replyToMessageId); } + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); } @@ -642,11 +918,14 @@ bool Api::kickChatMember(std::int64_t chatId, std::int64_t userId, std::uint64_t return sendRequest("kickChatMember", args).get("", false); } -bool Api::unbanChatMember(std::int64_t chatId, std::int64_t userId) const { +bool Api::unbanChatMember(std::int64_t chatId, std::int64_t userId, bool onlyIfBanned) const { vector args; - args.reserve(2); + args.reserve(3); + args.emplace_back("chat_id", chatId); args.emplace_back("user_id", userId); + args.emplace_back("only_if_banned", onlyIfBanned); + return sendRequest("unbanChatMember", args).get("", false); } @@ -664,12 +943,18 @@ bool Api::restrictChatMember(std::int64_t chatId, std::int64_t userId, TgBot::Ch return sendRequest("restrictChatMember", args).get("", false); } -bool Api::promoteChatMember(std::int64_t chatId, std::int64_t userId, bool canChangeInfo, bool canPostMessages, - bool canEditMessages, bool canDeleteMessages, bool canInviteUsers, bool canPinMessages, bool canPromoteMembers) const { +bool Api::promoteChatMember(std::int64_t chatId, std::int64_t userId, bool isAnonymous, + bool canChangeInfo, bool canPostMessages, bool canEditMessages, + bool canDeleteMessages, bool canInviteUsers, bool canRestrictMembers, + bool canPinMessages, bool canPromoteMembers) const { vector args; - args.reserve(9); + args.reserve(11); + args.emplace_back("chat_id", chatId); args.emplace_back("user_id", userId); + if (isAnonymous) { + args.emplace_back("is_anonymous", isAnonymous); + } if (canChangeInfo) { args.emplace_back("can_change_info", canChangeInfo); } @@ -685,12 +970,16 @@ bool Api::promoteChatMember(std::int64_t chatId, std::int64_t userId, bool canCh if (canInviteUsers) { args.emplace_back("can_invite_users", canInviteUsers); } + if (canRestrictMembers) { + args.emplace_back("can_restrict_members", canRestrictMembers); + } if (canPinMessages) { args.emplace_back("can_pin_messages", canPinMessages); } if (canPromoteMembers) { args.emplace_back("can_promote_members", canPromoteMembers); } + return sendRequest("promoteChatMember", args).get("", false); } @@ -762,13 +1051,25 @@ bool Api::pinChatMessage(std::int64_t chatId, std::int32_t messageId, bool disab return sendRequest("pinChatMessage", args).get("", false); } -bool Api::unpinChatMessage(std::int64_t chatId) const { +bool Api::unpinChatMessage(std::int64_t chatId, std::int32_t messageId) const { vector args; - args.reserve(1); + args.reserve(2); + args.emplace_back("chat_id", chatId); + args.emplace_back("message_id", messageId); + return sendRequest("unpinChatMessage", args).get("", false); } +bool Api::unpinAllChatMessages(std::int64_t chatId) const { + vector args; + args.reserve(1); + + args.emplace_back("chat_id", chatId); + + return sendRequest("unpinAllChatMessages", args).get("", false); +} + bool Api::leaveChat(std::int64_t chatId) const { vector args; args.reserve(1); @@ -779,7 +1080,9 @@ bool Api::leaveChat(std::int64_t chatId) const { Chat::Ptr Api::getChat(std::int64_t chatId) const { vector args; args.reserve(1); + args.emplace_back("chat_id", chatId); + return _tgTypeParser.parseJsonAndGetChat(sendRequest("getChat", args)); } @@ -853,12 +1156,17 @@ std::vector Api::getMyCommands() const { return _tgTypeParser.parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetBotCommand, sendRequest("getMyCommands")); } -Message::Ptr Api::editMessageText(const string& text, std::int64_t chatId, std::int32_t messageId, const string& inlineMessageId, - const string& parseMode, bool disableWebPagePreview, const GenericReply::Ptr replyMarkup) const { - +Message::Ptr Api::editMessageText(const std::string& text, + std::int64_t chatId, + std::int32_t messageId, + const std::string& inlineMessageId, + const std::string& parseMode, + const std::vector& entities, + bool disableWebPagePreview, + GenericReply::Ptr replyMarkup) const { vector args; - args.reserve(7); - args.emplace_back("text", text); + args.reserve(8); + if (chatId) { args.emplace_back("chat_id", chatId); } @@ -868,15 +1176,20 @@ Message::Ptr Api::editMessageText(const string& text, std::int64_t chatId, std:: if (!inlineMessageId.empty()) { args.emplace_back("inline_message_id", inlineMessageId); } + args.emplace_back("text", text); if (!parseMode.empty()) { args.emplace_back("parse_mode", parseMode); } + if (!entities.empty()) { + args.emplace_back("entities", _tgTypeParser.parseArray(&TgTypeParser::parseMessageEntity, entities)); + } if (disableWebPagePreview) { args.emplace_back("disable_web_page_preview", disableWebPagePreview); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); } + ptree p = sendRequest("editMessageText", args); if (p.get_child_optional("message_id")) { return _tgTypeParser.parseJsonAndGetMessage(p); @@ -885,25 +1198,38 @@ Message::Ptr Api::editMessageText(const string& text, std::int64_t chatId, std:: } } -Message::Ptr Api::editMessageCaption(std::int64_t chatId, std::int32_t messageId, const string& caption, - const string& inlineMessageId, const GenericReply::Ptr replyMarkup) const { +Message::Ptr Api::editMessageCaption(std::int64_t chatId, + std::int32_t messageId, + const std::string& inlineMessageId, + const std::string& caption, + const std::string& parseMode, + const std::vector& captionEntities, + GenericReply::Ptr replyMarkup) const { vector args; - args.reserve(5); + args.reserve(7); + if (chatId) { args.emplace_back("chat_id", chatId); } if (messageId) { args.emplace_back("message_id", messageId); } + if (!inlineMessageId.empty()) { + args.emplace_back("inline_message_id", inlineMessageId); + } if (!caption.empty()) { args.emplace_back("caption", caption); } - if (!inlineMessageId.empty()) { - args.emplace_back("inline_message_id", inlineMessageId); + if (!parseMode.empty()) { + args.emplace_back("parse_mode", parseMode); + } + if (!captionEntities.empty()) { + args.emplace_back("caption_entities", _tgTypeParser.parseArray(&TgTypeParser::parseMessageEntity, captionEntities)); } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); } + ptree p = sendRequest("editMessageCaption", args); if (p.get_child_optional("message_id")) { return _tgTypeParser.parseJsonAndGetMessage(p); @@ -978,9 +1304,15 @@ 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, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const { +Message::Ptr Api::sendSticker(std::int64_t chatId, + boost::variant sticker, + bool disableNotification, + std::int32_t replyToMessageId, + bool allowSendingWithoutReply, + GenericReply::Ptr replyMarkup) const { vector args; - args.reserve(5); + args.reserve(6); + args.emplace_back("chat_id", chatId); if (sticker.which() == 0 /* InputFile::Ptr */) { auto file = boost::get(sticker); @@ -988,15 +1320,19 @@ Message::Ptr Api::sendSticker(std::int64_t chatId, boost::variant(sticker)); } + if (disableNotification) { + args.emplace_back("disable_notification", disableNotification); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); } - if (disableNotification) { - args.emplace_back("disable_notification", disableNotification); - } + return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendSticker", args)); } @@ -1130,15 +1466,33 @@ bool Api::answerInlineQuery(const string& inlineQueryId, const std::vector("", false); } -Message::Ptr Api::sendInvoice(std::int64_t chatId, const std::string& title, const std::string& description, const std::string& payload, - const std::string& providerToken, const std::string& startParameter, const std::string& currency, const std::vector& prices, - const std::string& providerData, const std::string& photoUrl, std::int32_t photoSize, - std::int32_t photoWidth, std::int32_t photoHeight, bool needName, - bool needPhoneNumber, bool needEmail, bool needShippingAddress, - bool sendPhoneNumberToProvider, bool sendEmailToProvider, bool isFlexible, - std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const { - vector args; - args.reserve(23); +Message::Ptr Api::sendInvoice(std::int64_t chatId, + const std::string& title, + const std::string& description, + const std::string& payload, + const std::string& providerToken, + const std::string& startParameter, + const std::string& currency, + const std::vector& prices, + const std::string& providerData, + const std::string& photoUrl, + std::int32_t photoSize, + std::int32_t photoWidth, + std::int32_t photoHeight, + bool needName, + bool needPhoneNumber, + bool needEmail, + bool needShippingAddress, + bool sendPhoneNumberToProvider, + bool sendEmailToProvider, + bool isFlexible, + bool disableNotification, + std::int32_t replyToMessageId, + bool allowSendingWithoutReply, + GenericReply::Ptr replyMarkup) const { + vector args; + args.reserve(24); + args.emplace_back("chat_id", chatId); args.emplace_back("title", title); args.emplace_back("description", description); @@ -1183,15 +1537,19 @@ Message::Ptr Api::sendInvoice(std::int64_t chatId, const std::string& title, con if (isFlexible) { args.emplace_back("is_flexible", isFlexible); } + if (disableNotification) { + args.emplace_back("disable_notification", disableNotification); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); } - if (disableNotification) { - args.emplace_back("disable_notification", disableNotification); - } + return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendInvoice", args)); } @@ -1230,20 +1588,30 @@ bool Api::setPassportDataErrors(std::int64_t userId, const std::vector("", false); } -Message::Ptr Api::sendGame(std::int64_t chatId, const std::string& gameShortName, std::int32_t replyToMessageId, const InlineKeyboardMarkup::Ptr replyMarkup, bool disableNotification) const { +Message::Ptr Api::sendGame(std::int64_t chatId, + const std::string& gameShortName, + bool disableNotification, + std::int32_t replyToMessageId, + bool allowSendingWithoutReply, + InlineKeyboardMarkup::Ptr replyMarkup) const { vector args; - args.reserve(5); + args.reserve(6); + args.emplace_back("chat_id", chatId); args.emplace_back("game_short_name", gameShortName); + if (disableNotification) { + args.emplace_back("disable_notification", disableNotification); + } if (replyToMessageId) { args.emplace_back("reply_to_message_id", replyToMessageId); } + if (allowSendingWithoutReply) { + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); + } if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); } - if (disableNotification) { - args.emplace_back("disable_notification", disableNotification); - } + return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendGame", args)); } -- cgit v1.2.3 From bfa7b0c67a3df3848eb7f9bccdf7c158ce4c9d07 Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Sun, 4 Sep 2022 13:45:21 +0200 Subject: Update to API 5.1 --- src/Api.cpp | 108 +++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 85 insertions(+), 23 deletions(-) (limited to 'src/Api.cpp') diff --git a/src/Api.cpp b/src/Api.cpp index 86d573b..a67aafb 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -852,15 +852,11 @@ Message::Ptr Api::sendDice(std::int64_t chatId, if (!emoji.empty()) { args.emplace_back("emoji", emoji); } - if (disableNotification) { - args.emplace_back("disable_notification", disableNotification); - } + args.emplace_back("disable_notification", disableNotification); if (replyToMessageId != 0) { args.emplace_back("reply_to_message_id", replyToMessageId); } - if (allowSendingWithoutReply) { - args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); - } + args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply); if (replyMarkup) { args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup)); } @@ -907,14 +903,18 @@ string Api::downloadFile(const string& filePath, const std::vector& return serverResponse; } -bool Api::kickChatMember(std::int64_t chatId, std::int64_t userId, std::uint64_t untilDate) const { +bool Api::kickChatMember(std::int64_t chatId, + std::int64_t userId, + std::uint64_t untilDate, + bool revokeMessages) const { vector args; - args.reserve(3); + args.reserve(4); + args.emplace_back("chat_id", chatId); args.emplace_back("user_id", userId); - if (untilDate) { - args.emplace_back("until_date", untilDate); - } + args.emplace_back("until_date", untilDate); + args.emplace_back("revoke_messages", revokeMessages); + return sendRequest("kickChatMember", args).get("", false); } @@ -943,20 +943,29 @@ bool Api::restrictChatMember(std::int64_t chatId, std::int64_t userId, TgBot::Ch return sendRequest("restrictChatMember", args).get("", false); } -bool Api::promoteChatMember(std::int64_t chatId, std::int64_t userId, bool isAnonymous, - bool canChangeInfo, bool canPostMessages, bool canEditMessages, - bool canDeleteMessages, bool canInviteUsers, bool canRestrictMembers, - bool canPinMessages, bool canPromoteMembers) const { +bool Api::promoteChatMember(std::int64_t chatId, + std::int64_t userId, + bool isAnonymous, + bool canManageChat, + bool canPostMessages, + bool canEditMessages, + bool canDeleteMessages, + bool canManageVoiceChats, + bool canRestrictMembers, + bool canPromoteMembers, + bool canChangeInfo, + bool canInviteUsers, + bool canPinMessages) const { vector args; - args.reserve(11); + args.reserve(13); args.emplace_back("chat_id", chatId); args.emplace_back("user_id", userId); if (isAnonymous) { args.emplace_back("is_anonymous", isAnonymous); } - if (canChangeInfo) { - args.emplace_back("can_change_info", canChangeInfo); + if (canManageChat) { + args.emplace_back("can_manage_chat", canManageChat); } if (canPostMessages) { args.emplace_back("can_post_messages", canPostMessages); @@ -967,18 +976,24 @@ bool Api::promoteChatMember(std::int64_t chatId, std::int64_t userId, bool isAno if (canDeleteMessages) { args.emplace_back("can_delete_messages", canDeleteMessages); } - if (canInviteUsers) { - args.emplace_back("can_invite_users", canInviteUsers); + if (canManageVoiceChats) { + args.emplace_back("can_manage_voice_chats", canManageVoiceChats); } if (canRestrictMembers) { args.emplace_back("can_restrict_members", canRestrictMembers); } - if (canPinMessages) { - args.emplace_back("can_pin_messages", canPinMessages); - } if (canPromoteMembers) { args.emplace_back("can_promote_members", canPromoteMembers); } + if (canChangeInfo) { + args.emplace_back("can_change_info", canChangeInfo); + } + if (canInviteUsers) { + args.emplace_back("can_invite_users", canInviteUsers); + } + if (canPinMessages) { + args.emplace_back("can_pin_messages", canPinMessages); + } return sendRequest("promoteChatMember", args).get("", false); } @@ -1009,6 +1024,53 @@ string Api::exportChatInviteLink(std::int64_t chatId) const { return sendRequest("exportChatInviteLink", args).get("", ""); } +ChatInviteLink::Ptr Api::createChatInviteLink(std::int64_t chatId, + std::int32_t expireDate, + std::int32_t memberLimit) const { + vector args; + args.reserve(3); + + args.emplace_back("chat_id", chatId); + if (expireDate != 0) { + args.emplace_back("expire_date", expireDate); + } + if (memberLimit != 0) { + args.emplace_back("member_limit", memberLimit); + } + + return _tgTypeParser.parseJsonAndGetChatInviteLink(sendRequest("createChatInviteLink", args)); +} + +ChatInviteLink::Ptr Api::editChatInviteLink(std::int64_t chatId, + std::string inviteLink, + std::int32_t expireDate, + std::int32_t memberLimit) const { + vector args; + args.reserve(4); + + args.emplace_back("chat_id", chatId); + args.emplace_back("invite_link", inviteLink); + if (expireDate != 0) { + args.emplace_back("expire_date", expireDate); + } + if (memberLimit != 0) { + args.emplace_back("member_limit", memberLimit); + } + + return _tgTypeParser.parseJsonAndGetChatInviteLink(sendRequest("editChatInviteLink", args)); +} + +ChatInviteLink::Ptr Api::revokeChatInviteLink(std::int64_t chatId, + std::string inviteLink) const { + vector args; + args.reserve(2); + + args.emplace_back("chat_id", chatId); + args.emplace_back("invite_link", inviteLink); + + return _tgTypeParser.parseJsonAndGetChatInviteLink(sendRequest("revokeChatInviteLink", args)); +} + bool Api::setChatPhoto(std::int64_t chatId, const InputFile::Ptr photo) const { vector args; args.reserve(2); -- cgit v1.2.3 From b540a9cc139b0c428cd51030f8071056dfe44d79 Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Sun, 4 Sep 2022 15:41:16 +0200 Subject: Optimise backward compatibility --- src/Api.cpp | 218 +++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 128 insertions(+), 90 deletions(-) (limited to 'src/Api.cpp') diff --git a/src/Api.cpp b/src/Api.cpp index a67aafb..bcb711c 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -40,8 +40,12 @@ vector Api::getUpdates(std::int32_t offset, std::int32_t limit, std return _tgTypeParser.parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetUpdate, sendRequest("getUpdates", args)); } -bool Api::setWebhook(const std::string& url, InputFile::Ptr certificate, const std::string& ipAddress, - std::int32_t maxConnection, const StringArrayPtr& allowedUpdates, bool dropPendingUpdates) const { +bool Api::setWebhook(const std::string& url, + InputFile::Ptr certificate, + std::int32_t maxConnection, + const StringArrayPtr& allowedUpdates, + const std::string& ipAddress, + bool dropPendingUpdates) const { vector args; args.reserve(6); @@ -97,9 +101,15 @@ User::Ptr Api::getMe() const { return _tgTypeParser.parseJsonAndGetUser(sendRequest("getMe")); } -Message::Ptr Api::sendMessage(boost::variant chatId, const std::string& text, const std::string& parseMode, - const std::vector& entities, bool disableWebPagePreview, bool disableNotification, - std::int32_t replyToMessageId, bool allowSendingWithoutReply, GenericReply::Ptr replyMarkup) const { +Message::Ptr Api::sendMessage(boost::variant chatId, + const std::string& text, + bool disableWebPagePreview, + std::int32_t replyToMessageId, + GenericReply::Ptr replyMarkup, + const std::string& parseMode, + bool disableNotification, + const std::vector& entities, + bool allowSendingWithoutReply) const { vector args; args.reserve(9); @@ -177,9 +187,15 @@ 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, const std::string& caption, - const std::string& parseMode, const std::vector& captionEntities, bool disableNotification, - std::int32_t replyToMessageId, bool allowSendingWithoutReply, GenericReply::Ptr replyMarkup) const { +Message::Ptr Api::sendPhoto(std::int64_t 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 { vector args; args.reserve(9); @@ -218,16 +234,16 @@ Message::Ptr Api::sendPhoto(std::int64_t chatId, boost::variant audio, const std::string& caption, - const std::string& parseMode, - const std::vector& captionEntities, std::int32_t duration, const std::string& performer, const std::string& title, boost::variant thumb, - bool disableNotification, std::int32_t replyToMessageId, - bool allowSendingWithoutReply, - GenericReply::Ptr replyMarkup) const { + GenericReply::Ptr replyMarkup, + const std::string& parseMode, + bool disableNotification, + const std::vector& captionEntities, + bool allowSendingWithoutReply) const { vector args; args.reserve(13); @@ -285,13 +301,13 @@ Message::Ptr Api::sendDocument(std::int64_t chatId, boost::variant document, 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 disableContentTypeDetection, - bool disableNotification, - std::int32_t replyToMessageId, - bool allowSendingWithoutReply, - GenericReply::Ptr replyMarkup) const { + bool allowSendingWithoutReply) const { vector args; args.reserve(11); @@ -341,18 +357,18 @@ Message::Ptr Api::sendDocument(std::int64_t chatId, Message::Ptr Api::sendVideo(std::int64_t 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, + std::int32_t replyToMessageId, + GenericReply::Ptr replyMarkup, const std::string& parseMode, - const std::vector& captionEntities, - bool supportsStreaming, bool disableNotification, - std::int32_t replyToMessageId, - bool allowSendingWithoutReply, - GenericReply::Ptr replyMarkup) const { + const std::vector& captionEntities, + bool allowSendingWithoutReply) const { vector args; args.reserve(14); @@ -416,12 +432,12 @@ Message::Ptr Api::sendAnimation(std::int64_t chatId, std::int32_t height, boost::variant thumb, const std::string& caption, + std::int32_t replyToMessageId, + GenericReply::Ptr replyMarkup, const std::string& parseMode, - const std::vector& captionEntities, bool disableNotification, - std::int32_t replyToMessageId, - bool allowSendingWithoutReply, - GenericReply::Ptr replyMarkup) const { + const std::vector& captionEntities, + bool allowSendingWithoutReply) const { vector args; args.reserve(13); @@ -478,13 +494,13 @@ Message::Ptr Api::sendAnimation(std::int64_t chatId, Message::Ptr Api::sendVoice(std::int64_t chatId, boost::variant voice, const std::string& caption, - const std::string& parseMode, - const std::vector& captionEntities, std::int32_t duration, - bool disableNotification, std::int32_t replyToMessageId, - bool allowSendingWithoutReply, - GenericReply::Ptr replyMarkup) const { + GenericReply::Ptr replyMarkup, + const std::string& parseMode, + bool disableNotification, + const std::vector& captionEntities, + bool allowSendingWithoutReply) const { vector args; args.reserve(10); @@ -525,13 +541,13 @@ Message::Ptr Api::sendVoice(std::int64_t chatId, Message::Ptr Api::sendVideoNote(std::int64_t chatId, boost::variant videoNote, + std::int64_t replyToMessageId, + bool disableNotification, std::int32_t duration, std::int32_t length, boost::variant thumb, - bool disableNotification, - std::int32_t replyToMessageId, - bool allowSendingWithoutReply, - GenericReply::Ptr replyMarkup) const { + GenericReply::Ptr replyMarkup, + bool allowSendingWithoutReply) const { vector args; args.reserve(9); @@ -593,10 +609,17 @@ 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, float latitude, float longitude, - float horizontalAccuracy, std::uint32_t livePeriod, std::uint32_t heading, - std::uint32_t proximityAlertRadius, bool disableNotification, std::int32_t replyToMessageId, - bool allowSendingWithoutReply, GenericReply::Ptr replyMarkup) const { +Message::Ptr Api::sendLocation(std::int64_t chatId, + float latitude, + float longitude, + std::uint32_t livePeriod, + std::int32_t replyToMessageId, + GenericReply::Ptr replyMarkup, + bool disableNotification, + float horizontalAccuracy, + std::uint32_t heading, + std::uint32_t proximityAlertRadius, + bool allowSendingWithoutReply) const { vector args; args.reserve(11); @@ -631,9 +654,15 @@ Message::Ptr Api::sendLocation(std::int64_t chatId, float latitude, float longit return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendLocation", args)); } -Message::Ptr Api::editMessageLiveLocation(float latitude, float longitude, std::int64_t chatId, - std::int32_t messageId, std::int32_t inlineMessageId, float horizontalAccuracy, - std::int32_t heading, std::int32_t proximityAlertRadius, InlineKeyboardMarkup::Ptr replyMarkup) const { +Message::Ptr Api::editMessageLiveLocation(float latitude, + float longitude, + std::int64_t chatId, + std::int32_t messageId, + std::int32_t inlineMessageId, + InlineKeyboardMarkup::Ptr replyMarkup, + float horizontalAccuracy, + std::int32_t heading, + std::int32_t proximityAlertRadius) const { vector args; args.reserve(9); @@ -689,12 +718,12 @@ Message::Ptr Api::sendVenue(std::int64_t chatId, const std::string& address, const std::string& foursquareId, const std::string& foursquareType, - const std::string& googlePlaceId, - const std::string& googlePlaceType, bool disableNotification, std::int32_t replyToMessageId, - bool allowSendingWithoutReply, - GenericReply::Ptr replyMarkup) const { + GenericReply::Ptr replyMarkup, + const std::string& googlePlaceId, + const std::string& googlePlaceType, + bool allowSendingWithoutReply) const { vector args; args.reserve(13); @@ -738,8 +767,8 @@ Message::Ptr Api::sendContact(std::int64_t chatId, const std::string& vcard, bool disableNotification, std::int32_t replyToMessageId, - bool allowSendingWithoutReply, - GenericReply::Ptr replyMarkup) const { + GenericReply::Ptr replyMarkup, + bool allowSendingWithoutReply) const { vector args; args.reserve(9); @@ -771,6 +800,9 @@ Message::Ptr Api::sendContact(std::int64_t chatId, Message::Ptr Api::sendPoll(std::int64_t chatId, const std::string& question, const std::vector& options, + bool disableNotification, + std::int32_t replyToMessageId, + GenericReply::Ptr replyMarkup, bool isAnonymous, const std::string& type, bool allowsMultipleAnswers, @@ -781,10 +813,7 @@ Message::Ptr Api::sendPoll(std::int64_t chatId, std::int32_t openPeriod, std::int32_t closeDate, bool isClosed, - bool disableNotification, - std::int32_t replyToMessageId, - bool allowSendingWithoutReply, - GenericReply::Ptr replyMarkup) const { + bool allowSendingWithoutReply) const { vector args; args.reserve(17); @@ -840,11 +869,11 @@ Message::Ptr Api::sendPoll(std::int64_t chatId, } Message::Ptr Api::sendDice(std::int64_t chatId, - const std::string& emoji, bool disableNotification, std::int32_t replyToMessageId, - bool allowSendingWithoutReply, - GenericReply::Ptr replyMarkup) const { + GenericReply::Ptr replyMarkup, + const std::string& emoji, + bool allowSendingWithoutReply) const { vector args; args.reserve(6); @@ -945,17 +974,17 @@ bool Api::restrictChatMember(std::int64_t chatId, std::int64_t userId, TgBot::Ch bool Api::promoteChatMember(std::int64_t chatId, std::int64_t userId, - bool isAnonymous, - bool canManageChat, + bool canChangeInfo, bool canPostMessages, bool canEditMessages, bool canDeleteMessages, - bool canManageVoiceChats, - bool canRestrictMembers, - bool canPromoteMembers, - bool canChangeInfo, bool canInviteUsers, - bool canPinMessages) const { + bool canPinMessages, + bool canPromoteMembers, + bool isAnonymous, + bool canManageChat, + bool canManageVoiceChats, + bool canRestrictMembers) const { vector args; args.reserve(13); @@ -1223,9 +1252,9 @@ Message::Ptr Api::editMessageText(const std::string& text, std::int32_t messageId, const std::string& inlineMessageId, const std::string& parseMode, - const std::vector& entities, bool disableWebPagePreview, - GenericReply::Ptr replyMarkup) const { + GenericReply::Ptr replyMarkup, + const std::vector& entities) const { vector args; args.reserve(8); @@ -1262,11 +1291,11 @@ Message::Ptr Api::editMessageText(const std::string& text, Message::Ptr Api::editMessageCaption(std::int64_t chatId, std::int32_t messageId, - const std::string& inlineMessageId, const std::string& caption, + const std::string& inlineMessageId, + GenericReply::Ptr replyMarkup, const std::string& parseMode, - const std::vector& captionEntities, - GenericReply::Ptr replyMarkup) const { + const std::vector& captionEntities) const { vector args; args.reserve(7); @@ -1368,10 +1397,10 @@ void Api::deleteMessage(std::int64_t chatId, std::int32_t messageId) const { Message::Ptr Api::sendSticker(std::int64_t chatId, boost::variant sticker, - bool disableNotification, std::int32_t replyToMessageId, - bool allowSendingWithoutReply, - GenericReply::Ptr replyMarkup) const { + GenericReply::Ptr replyMarkup, + bool disableNotification, + bool allowSendingWithoutReply) const { vector args; args.reserve(6); @@ -1401,7 +1430,9 @@ Message::Ptr Api::sendSticker(std::int64_t chatId, StickerSet::Ptr Api::getStickerSet(const string& name) const { vector args; args.reserve(1); + args.emplace_back("name", name); + return _tgTypeParser.parseJsonAndGetStickerSet(sendRequest("getStickerSet", args)); } @@ -1413,9 +1444,14 @@ 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 std::string& name, const std::string& title, - const std::string& emojis, boost::variant pngSticker, boost::variant tgsSticker, - 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, + bool containsMasks, + MaskPosition::Ptr maskPosition, + boost::variant pngSticker, + boost::variant tgsSticker) const { vector args; args.reserve(8); @@ -1445,8 +1481,12 @@ bool Api::createNewStickerSet(std::int64_t userId, const std::string& name, cons return sendRequest("createNewStickerSet", args).get("", false); } -bool Api::addStickerToSet(std::int64_t userId, const std::string& name, const std::string& emojis, - boost::variant pngSticker, boost::variant tgsSticker, MaskPosition::Ptr maskPosition) const { +bool Api::addStickerToSet(std::int64_t userId, + const std::string& name, + const std::string& emojis, + MaskPosition::Ptr maskPosition, + boost::variant pngSticker, + boost::variant tgsSticker) const { vector args; args.reserve(6); @@ -1548,10 +1588,10 @@ Message::Ptr Api::sendInvoice(std::int64_t chatId, bool sendPhoneNumberToProvider, bool sendEmailToProvider, bool isFlexible, - bool disableNotification, std::int32_t replyToMessageId, - bool allowSendingWithoutReply, - GenericReply::Ptr replyMarkup) const { + GenericReply::Ptr replyMarkup, + bool disableNotification, + bool allowSendingWithoutReply) const { vector args; args.reserve(24); @@ -1652,10 +1692,10 @@ bool Api::setPassportDataErrors(std::int64_t userId, const std::vector args; args.reserve(6); @@ -1700,17 +1740,14 @@ Message::Ptr Api::setGameScore(std::int64_t userId, std::int32_t score, bool for return _tgTypeParser.parseJsonAndGetMessage(sendRequest("setGameScore", args)); } -vector Api::getGameHighScores(std::int64_t userId, std::int32_t score, bool force, bool disableEditMessage, std::int64_t chatId, std::int32_t messageId, const std::string& inlineMessageId) const { +vector Api::getGameHighScores(std::int64_t userId, + std::int64_t chatId, + std::int32_t messageId, + const std::string& inlineMessageId) const { vector args; - args.reserve(7); + args.reserve(4); + args.emplace_back("user_id", userId); - args.emplace_back("score", score); - if (force) { - args.emplace_back("force", force); - } - if (disableEditMessage) { - args.emplace_back("disable_edit_message", disableEditMessage); - } if (chatId) { args.emplace_back("chat_id", chatId); } @@ -1720,6 +1757,7 @@ vector Api::getGameHighScores(std::int64_t userId, std::int3 if (!inlineMessageId.empty()) { args.emplace_back("inline_message_id", inlineMessageId); } + return _tgTypeParser.parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetGameHighScore, sendRequest("getGameHighScores", args)); } -- cgit v1.2.3 From 38f8755a35e696c52c3bae6aceb19513b73d41af Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Sun, 4 Sep 2022 17:16:56 +0200 Subject: Update to API 5.2 --- src/Api.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'src/Api.cpp') diff --git a/src/Api.cpp b/src/Api.cpp index bcb711c..5cdab54 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -893,12 +893,15 @@ Message::Ptr Api::sendDice(std::int64_t chatId, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendDice", args)); } -void Api::sendChatAction(std::int64_t chatId, const string& action) const { +bool Api::sendChatAction(std::int64_t chatId, + const std::string& action) const { vector args; args.reserve(2); + args.emplace_back("chat_id", chatId); args.emplace_back("action", action); - sendRequest("sendChatAction", args); + + return sendRequest("sendChatAction", args).get("", false); } UserProfilePhotos::Ptr Api::getUserProfilePhotos(std::int64_t userId, std::int32_t offset, std::int32_t limit) const { @@ -1573,7 +1576,6 @@ Message::Ptr Api::sendInvoice(std::int64_t chatId, const std::string& description, const std::string& payload, const std::string& providerToken, - const std::string& startParameter, const std::string& currency, const std::vector& prices, const std::string& providerData, @@ -1591,18 +1593,29 @@ Message::Ptr Api::sendInvoice(std::int64_t chatId, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, bool disableNotification, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + std::int32_t maxTipAmount, + const std::vector& suggestedTipAmounts, + const std::string& startParameter) const { vector args; - args.reserve(24); + args.reserve(26); args.emplace_back("chat_id", chatId); args.emplace_back("title", title); args.emplace_back("description", description); args.emplace_back("payload", payload); args.emplace_back("provider_token", providerToken); - args.emplace_back("start_parameter", startParameter); args.emplace_back("currency", currency); args.emplace_back("prices", _tgTypeParser.parseArray(&TgTypeParser::parseLabeledPrice, prices)); + args.emplace_back("max_tip_amount", maxTipAmount); + if (!suggestedTipAmounts.empty()) { + args.emplace_back("suggested_tip_amounts", _tgTypeParser.parseArray([] (const std::int32_t& option) -> std::int32_t { + return option; + }, suggestedTipAmounts)); + } + if (!startParameter.empty()) { + args.emplace_back("start_parameter", startParameter); + } if (!providerData.empty()) { args.emplace_back("provider_data", providerData); } -- cgit v1.2.3 From 5492d26d21d09dc9cc3551f32a8eab7a2e783e3c Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Sun, 4 Sep 2022 20:33:21 +0200 Subject: Update to API 5.3 --- src/Api.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 13 deletions(-) (limited to 'src/Api.cpp') diff --git a/src/Api.cpp b/src/Api.cpp index 5cdab54..9fdf290 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -935,10 +935,10 @@ string Api::downloadFile(const string& filePath, const std::vector& return serverResponse; } -bool Api::kickChatMember(std::int64_t chatId, - std::int64_t userId, - std::uint64_t untilDate, - bool revokeMessages) const { +bool Api::banChatMember(std::int64_t chatId, + std::int64_t userId, + std::uint64_t untilDate, + bool revokeMessages) const { vector args; args.reserve(4); @@ -947,7 +947,7 @@ bool Api::kickChatMember(std::int64_t chatId, args.emplace_back("until_date", untilDate); args.emplace_back("revoke_messages", revokeMessages); - return sendRequest("kickChatMember", args).get("", false); + return sendRequest("banChatMember", args).get("", false); } bool Api::unbanChatMember(std::int64_t chatId, std::int64_t userId, bool onlyIfBanned) const { @@ -1187,11 +1187,13 @@ vector Api::getChatAdministrators(std::int64_t chatId) const { return _tgTypeParser.parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetChatMember, sendRequest("getChatAdministrators", args)); } -int32_t Api::getChatMembersCount(std::int64_t chatId) const { +int32_t Api::getChatMemberCount(std::int64_t chatId) const { vector args; args.reserve(1); + args.emplace_back("chat_id", chatId); - return sendRequest("getChatMembersCount", args).get("", 0); + + return sendRequest("getChatMemberCount", args).get("", 0); } ChatMember::Ptr Api::getChatMember(std::int64_t chatId, std::int64_t userId) const { @@ -1236,18 +1238,51 @@ bool Api::answerCallbackQuery(const string& callbackQueryId, const string& text, return sendRequest("answerCallbackQuery", args).get("", false); } -bool Api::setMyCommands(const std::vector& commands) const { +bool Api::setMyCommands(const std::vector& commands, + BotCommandScope::Ptr scope, + const std::string& languageCode) const { vector args; - args.reserve(5); + args.reserve(3); - string commandsJson = _tgTypeParser.parseArray(&TgTypeParser::parseBotCommand, commands); - args.emplace_back("commands", commandsJson); + args.emplace_back("commands", _tgTypeParser.parseArray(&TgTypeParser::parseBotCommand, commands)); + if (scope != nullptr) { + args.emplace_back("scope", _tgTypeParser.parseBotCommandScope(scope)); + } + if (!languageCode.empty()) { + args.emplace_back("language_code", languageCode); + } return sendRequest("setMyCommands", args).get("", false); } -std::vector Api::getMyCommands() const { - return _tgTypeParser.parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetBotCommand, sendRequest("getMyCommands")); +bool Api::deleteMyCommands(BotCommandScope::Ptr scope, + const std::string& languageCode) const { + vector args; + args.reserve(2); + + if (scope != nullptr) { + args.emplace_back("scope", _tgTypeParser.parseBotCommandScope(scope)); + } + if (!languageCode.empty()) { + args.emplace_back("language_code", languageCode); + } + + return sendRequest("deleteMyCommands", args).get("", false); +} + +std::vector Api::getMyCommands(BotCommandScope::Ptr scope, + const std::string& languageCode) const { + vector args; + args.reserve(2); +; + if (scope != nullptr) { + args.emplace_back("scope", _tgTypeParser.parseBotCommandScope(scope)); + } + if (!languageCode.empty()) { + args.emplace_back("language_code", languageCode); + } + + return _tgTypeParser.parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetBotCommand, sendRequest("getMyCommands", args)); } Message::Ptr Api::editMessageText(const std::string& text, -- cgit v1.2.3 From 5a72b4b1fc89d9b6033f929d9bf4f6e30d7f9698 Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Sun, 4 Sep 2022 20:59:46 +0200 Subject: Update to API 5.4 --- src/Api.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) (limited to 'src/Api.cpp') diff --git a/src/Api.cpp b/src/Api.cpp index 9fdf290..ad9f544 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -1058,36 +1058,52 @@ string Api::exportChatInviteLink(std::int64_t chatId) const { ChatInviteLink::Ptr Api::createChatInviteLink(std::int64_t chatId, std::int32_t expireDate, - std::int32_t memberLimit) const { + std::int32_t memberLimit, + const std::string& name, + bool createsJoinRequest) const { vector args; - args.reserve(3); + args.reserve(5); args.emplace_back("chat_id", chatId); + if (!name.empty()) { + args.emplace_back("name", name); + } if (expireDate != 0) { args.emplace_back("expire_date", expireDate); } if (memberLimit != 0) { args.emplace_back("member_limit", memberLimit); } + if (createsJoinRequest) { + args.emplace_back("createsJoinRequest", createsJoinRequest); + } return _tgTypeParser.parseJsonAndGetChatInviteLink(sendRequest("createChatInviteLink", args)); } ChatInviteLink::Ptr Api::editChatInviteLink(std::int64_t chatId, - std::string inviteLink, - std::int32_t expireDate, - std::int32_t memberLimit) const { + std::string inviteLink, + std::int32_t expireDate, + std::int32_t memberLimit, + const std::string& name, + bool createsJoinRequest) const { vector args; - args.reserve(4); + args.reserve(6); args.emplace_back("chat_id", chatId); args.emplace_back("invite_link", inviteLink); + if (!name.empty()) { + args.emplace_back("name", name); + } if (expireDate != 0) { args.emplace_back("expire_date", expireDate); } if (memberLimit != 0) { args.emplace_back("member_limit", memberLimit); } + if (createsJoinRequest) { + args.emplace_back("createsJoinRequest", createsJoinRequest); + } return _tgTypeParser.parseJsonAndGetChatInviteLink(sendRequest("editChatInviteLink", args)); } @@ -1103,6 +1119,28 @@ ChatInviteLink::Ptr Api::revokeChatInviteLink(std::int64_t chatId, return _tgTypeParser.parseJsonAndGetChatInviteLink(sendRequest("revokeChatInviteLink", args)); } +bool Api::approveChatJoinRequest(std::int64_t chatId, + std::int64_t userId) const { + vector args; + args.reserve(2); + + args.emplace_back("chat_id", chatId); + args.emplace_back("user_id", userId); + + return sendRequest("approveChatJoinRequest", args).get("", false); +} + +bool Api::declineChatJoinRequest(std::int64_t chatId, + std::int64_t userId) const { + vector args; + args.reserve(2); + + args.emplace_back("chat_id", chatId); + args.emplace_back("user_id", userId); + + return sendRequest("declineChatJoinRequest", args).get("", false); +} + bool Api::setChatPhoto(std::int64_t chatId, const InputFile::Ptr photo) const { vector args; args.reserve(2); -- cgit v1.2.3 From 5c9062ab3c3bff1fa1fb5b5288dda0cf5d0acf54 Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Sun, 4 Sep 2022 21:18:17 +0200 Subject: Update to API 5.5 --- src/Api.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/Api.cpp') diff --git a/src/Api.cpp b/src/Api.cpp index ad9f544..c1c86d2 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -1041,6 +1041,28 @@ bool Api::setChatAdministratorCustomTitle(std::int64_t chatId, std::int64_t user return sendRequest("setChatAdministratorCustomTitle", args).get("", false); } +bool Api::banChatSenderChat(std::int64_t chatId, + std::int64_t senderChatId) const { + vector args; + args.reserve(2); + + args.emplace_back("chat_id", chatId); + args.emplace_back("sender_chat_id", senderChatId); + + return sendRequest("banChatSenderChat", args).get("", false); +} + +bool Api::unbanChatSenderChat(std::int64_t chatId, + std::int64_t senderChatId) const { + vector args; + args.reserve(2); + + args.emplace_back("chat_id", chatId); + args.emplace_back("sender_chat_id", senderChatId); + + return sendRequest("unbanChatSenderChat", args).get("", false); +} + bool Api::setChatPermissions(std::int64_t chatId, ChatPermissions::Ptr permissions) const { vector args; args.reserve(2); -- cgit v1.2.3