diff options
author | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2022-09-09 16:57:08 +0200 |
---|---|---|
committer | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2022-09-09 16:57:08 +0200 |
commit | 349a54107d23ab58cff9afccad27741fa3ad8937 (patch) | |
tree | c9afbddb9796f446b136600780e7817963d815c1 | |
parent | c82fa054194126e400e7e87dabbdaf20d847703c (diff) |
Update to API 5.6
-rw-r--r-- | README.md | 194 | ||||
-rw-r--r-- | include/tgbot/Api.h | 217 | ||||
-rw-r--r-- | include/tgbot/types/ChatMemberBanned.h | 2 | ||||
-rw-r--r-- | include/tgbot/types/ChatMemberRestricted.h | 2 | ||||
-rw-r--r-- | include/tgbot/types/MessageEntity.h | 109 | ||||
-rw-r--r-- | src/Api.cpp | 342 | ||||
-rw-r--r-- | src/TgTypeParser.cpp | 8 |
7 files changed, 515 insertions, 359 deletions
@@ -1,98 +1,98 @@ -# tgbot-cpp - -[![Travis build Status](https://travis-ci.org/reo7sp/tgbot-cpp.svg?branch=master)](https://travis-ci.org/reo7sp/tgbot-cpp) -<br> -[![GitHub contributors](https://img.shields.io/github/contributors/reo7sp/tgbot-cpp.svg)](https://github.com/reo7sp/tgbot-cpp/graphs/contributors) - -C++14 library for Telegram bot API. - -Documentation is located [here](http://reo7sp.github.io/tgbot-cpp). - - -## State - -- [x] Bot API 3.0 ~ 3.6 +# tgbot-cpp
+
+[![Travis build Status](https://travis-ci.org/reo7sp/tgbot-cpp.svg?branch=master)](https://travis-ci.org/reo7sp/tgbot-cpp)
+<br>
+[![GitHub contributors](https://img.shields.io/github/contributors/reo7sp/tgbot-cpp.svg)](https://github.com/reo7sp/tgbot-cpp/graphs/contributors)
+
+C++14 library for Telegram bot API.
+
+Documentation is located [here](http://reo7sp.github.io/tgbot-cpp).
+
+
+## State
+
+- [x] Bot API 3.0 ~ 3.6
- [x] Bot API 4.0 ~ 4.9 -- [x] Bot API 5.0 ~ 5.5 (Implemented all APIs except 'Run Your Own Bot API Server') - - -## Sample - -Simple echo bot which sends everything it receives: -```cpp -#include <stdio.h> -#include <tgbot/tgbot.h> - -int main() { - TgBot::Bot bot("PLACE YOUR TOKEN HERE"); - bot.getEvents().onCommand("start", [&bot](TgBot::Message::Ptr message) { - bot.getApi().sendMessage(message->chat->id, "Hi!"); - }); - bot.getEvents().onAnyMessage([&bot](TgBot::Message::Ptr message) { - printf("User wrote %s\n", message->text.c_str()); - if (StringTools::startsWith(message->text, "/start")) { - return; - } - bot.getApi().sendMessage(message->chat->id, "Your message is: " + message->text); - }); - try { - printf("Bot username: %s\n", bot.getApi().getMe()->username.c_str()); - TgBot::TgLongPoll longPoll(bot); - while (true) { - printf("Long poll started\n"); - longPoll.start(); - } - } catch (TgBot::TgException& e) { - printf("error: %s\n", e.what()); - } - return 0; -} -``` - -All other samples are located [here](samples). - - -## Dependencies - -Firstly you need to install some dependencies such as Boost and build tools such as CMake. On Debian-based distibutives you can do it with these commands: -```sh -sudo apt-get install g++ make binutils cmake libssl-dev libboost-system-dev zlib1g-dev -``` -If you want to use curl-based http client `CurlHttpClient`, you also need to install `libcurl4-openssl-dev` package. - -## Library installation - -If you want to install the library system-wide: -```sh -git clone https://github.com/reo7sp/tgbot-cpp -cd tgbot-cpp -cmake . -make -j4 -sudo make install -``` - -You can treat this repository as a submodule of your project, for example, see [echobot-submodule](samples/echobot-submodule/CMakeLists.txt) - -You can use Docker to build and run your bot. Set the base image of your's Dockerfile to [reo7sp/tgbot-cpp](https://hub.docker.com/r/reo7sp/tgbot-cpp/). - - -## Bot compilation - -### With CMake -[Example CMakeLists.txt](samples/echobot/CMakeLists.txt) - -### Without CMake -```sh -g++ telegram_bot.cpp -o telegram_bot --std=c++14 -I/usr/local/include -lTgBot -lboost_system -lssl -lcrypto -lpthread -``` - -### Build options -``` --DTGBOT_DISABLE_NAGLES_ALGORITHM # Disable 'Nagle's algorithm' --DTGBOT_CHANGE_SOCKET_BUFFER_SIZE # Socket Buffer Size Expansion --DTGBOT_CHANGE_READ_BUFFER_SIZE # Read Buffer Size Expansion -``` - - -## Licence -[The MIT License](https://github.com/reo7sp/tgbot-cpp/blob/master/LICENSE). +- [x] Bot API 5.0 ~ 5.6 (Implemented all APIs except 'Run Your Own Bot API Server')
+
+
+## Sample
+
+Simple echo bot which sends everything it receives:
+```cpp
+#include <stdio.h>
+#include <tgbot/tgbot.h>
+
+int main() {
+ TgBot::Bot bot("PLACE YOUR TOKEN HERE");
+ bot.getEvents().onCommand("start", [&bot](TgBot::Message::Ptr message) {
+ bot.getApi().sendMessage(message->chat->id, "Hi!");
+ });
+ bot.getEvents().onAnyMessage([&bot](TgBot::Message::Ptr message) {
+ printf("User wrote %s\n", message->text.c_str());
+ if (StringTools::startsWith(message->text, "/start")) {
+ return;
+ }
+ bot.getApi().sendMessage(message->chat->id, "Your message is: " + message->text);
+ });
+ try {
+ printf("Bot username: %s\n", bot.getApi().getMe()->username.c_str());
+ TgBot::TgLongPoll longPoll(bot);
+ while (true) {
+ printf("Long poll started\n");
+ longPoll.start();
+ }
+ } catch (TgBot::TgException& e) {
+ printf("error: %s\n", e.what());
+ }
+ return 0;
+}
+```
+
+All other samples are located [here](samples).
+
+
+## Dependencies
+
+Firstly you need to install some dependencies such as Boost and build tools such as CMake. On Debian-based distibutives you can do it with these commands:
+```sh
+sudo apt-get install g++ make binutils cmake libssl-dev libboost-system-dev zlib1g-dev
+```
+If you want to use curl-based http client `CurlHttpClient`, you also need to install `libcurl4-openssl-dev` package.
+
+## Library installation
+
+If you want to install the library system-wide:
+```sh
+git clone https://github.com/reo7sp/tgbot-cpp
+cd tgbot-cpp
+cmake .
+make -j4
+sudo make install
+```
+
+You can treat this repository as a submodule of your project, for example, see [echobot-submodule](samples/echobot-submodule/CMakeLists.txt)
+
+You can use Docker to build and run your bot. Set the base image of your's Dockerfile to [reo7sp/tgbot-cpp](https://hub.docker.com/r/reo7sp/tgbot-cpp/).
+
+
+## Bot compilation
+
+### With CMake
+[Example CMakeLists.txt](samples/echobot/CMakeLists.txt)
+
+### Without CMake
+```sh
+g++ telegram_bot.cpp -o telegram_bot --std=c++14 -I/usr/local/include -lTgBot -lboost_system -lssl -lcrypto -lpthread
+```
+
+### Build options
+```
+-DTGBOT_DISABLE_NAGLES_ALGORITHM # Disable 'Nagle's algorithm'
+-DTGBOT_CHANGE_SOCKET_BUFFER_SIZE # Socket Buffer Size Expansion
+-DTGBOT_CHANGE_READ_BUFFER_SIZE # Read Buffer Size Expansion
+```
+
+
+## Licence
+[The MIT License](https://github.com/reo7sp/tgbot-cpp/blob/master/LICENSE).
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index 87c6c11..e0c69ec 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -135,11 +135,13 @@ public: * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. * @param parseMode Optional. Mode for parsing entities in the message text. See https://core.telegram.org/bots/api#formatting-options for more details. * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. - * @param entities Optional. List of special entities that appear in message text, which can be specified instead of parseMode + * @param entities Optional. A JSON-serialized list of special entities that appear in message text, which can be specified instead of parseMode * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found + * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * * @return On success, the sent Message is returned. */ + Message::Ptr sendMessage(boost::variant<std::int64_t, const std::string&> chatId, const std::string& text, bool disableWebPagePreview = false, @@ -148,67 +150,90 @@ public: const std::string& parseMode = "", bool disableNotification = false, const std::vector<MessageEntity::Ptr>& entities = std::vector<MessageEntity::Ptr>(), - bool allowSendingWithoutReply = false) const; + bool allowSendingWithoutReply = false, + bool protectContent = false) const; /** * @brief Use this method to forward messages of any kind. - * @param chatId Unique identifier for the target chat. - * @param fromChatId Unique identifier for the chat where the original message was sent — User or GroupChat id. - * @param messageId Unique message identifier. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. + * + * Service messages can't be forwarded. + * + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) + * @param messageId Message identifier in the chat specified in fromChatId + * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. + * @param protectContent Optional. Protects the contents of the forwarded message from forwarding and saving + * + * @return On success, the sent Message is returned. */ - Message::Ptr forwardMessage(std::int64_t chatId, std::int64_t fromChatId, std::int32_t messageId, bool disableNotification = false) const; + Message::Ptr forwardMessage(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<std::int64_t, const std::string&> fromChatId, + std::int32_t messageId, + bool disableNotification = false, + bool protectContent = false) const; /** * @brief Use this method to copy messages of any kind. - * The method is analogous to the method Api::forwardMessages, but the copied message doesn't have a link to the original message. + * + * Service messages and invoice messages can't be copied. + * The method is analogous to the method Api::forwardMessage, but the copied message doesn't have a link to the original message. * * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) * @param messageId Message identifier in the chat specified in fromChatId * @param caption Optional. New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept * @param parseMode Optional. Mode for parsing entities in the new caption. See https://core.telegram.org/bots/api#formatting-options for more details. - * @param captionEntities Optional. List of special entities that appear in the new caption, which can be specified instead of parseMode + * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the new caption, which can be specified instead of parseMode * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. * @param replyToMessageId Optional. If the message is a reply, ID of the original message * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. + * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * - * @return the MessageId of the sent message on success. + * @return Returns the MessageId of the sent message on success. */ - MessageId::Ptr copyMessage(std::int64_t chatId, std::int64_t fromChatId, std::int32_t messageId, - const std::string& caption = "", const std::string& parseMode = "", const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(), - bool disableNotification = false, std::int32_t replyToMessageId = 0, bool allowSendingWithoutReply = false, - GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const; + MessageId::Ptr copyMessage(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<std::int64_t, const std::string&> fromChatId, + std::int32_t messageId, + const std::string& caption = "", + const std::string& parseMode = "", + const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(), + bool disableNotification = false, + std::int32_t replyToMessageId = 0, + bool allowSendingWithoutReply = false, + GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), + bool protectContent = false) const; /** * @brief Use this method to send photos. * * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) - * @param photo Photo to send. Pass a fileId as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. https://core.telegram.org/bots/api#sending-files + * @param photo Photo to send. Pass a fileId as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. https://core.telegram.org/bots/api#sending-files * @param caption Optional. Photo caption (may also be used when resending photos by fileId), 0-1024 characters after entities parsing * @param replyToMessageId Optional. If the message is a reply, ID of the original message * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. * @param parseMode Optional. Mode for parsing entities in the photo caption. See https://core.telegram.org/bots/api#formatting-options for more details. - * @param disableNotification Optional.Sends the message silently. Users will receive a notification with no sound. - * @param captionEntities Optional. List of special entities that appear in the caption, which can be specified instead of parseMode + * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. + * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found + * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * * @return On success, the sent Message is returned. */ - Message::Ptr sendPhoto(std::int64_t chatId, - boost::variant<InputFile::Ptr, std::string> photo, + Message::Ptr sendPhoto(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<InputFile::Ptr, const std::string&> photo, const std::string& caption = "", std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false, const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(), - bool allowSendingWithoutReply = false) const; + bool allowSendingWithoutReply = false, + bool protectContent = false) const; /** - * @brief Use this method to send audio files, if you want Telegram clients to display them in the music player. + * @brief Use this method to send audio files, if you want Telegram clients to display them in the music player. + * * Your audio must be in the .MP3 or .M4A format. * Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. * @@ -225,27 +250,30 @@ public: * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. * @param parseMode Optional. Mode for parsing entities in the audio caption. See https://core.telegram.org/bots/api#formatting-options for more details. * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. - * @param captionEntities Optional. List of special entities that appear in the caption, which can be specified instead of parseMode + * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found + * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * * @return On success, the sent Message is returned. */ - Message::Ptr sendAudio(std::int64_t chatId, - boost::variant<InputFile::Ptr, std::string> audio, + Message::Ptr sendAudio(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<InputFile::Ptr, const std::string&> audio, const std::string& caption = "", std::int32_t duration = 0, const std::string& performer = "", const std::string& title = "", - boost::variant<InputFile::Ptr, std::string> thumb = "", + boost::variant<InputFile::Ptr, const std::string&> thumb = "", std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false, const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(), - bool allowSendingWithoutReply = false) const; + bool allowSendingWithoutReply = false, + bool protectContent = false) const; /** * @brief Use this method to send general files. + * * Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. * * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) @@ -256,15 +284,16 @@ public: * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. * @param parseMode Optional. Mode for parsing entities in the document caption. See https://core.telegram.org/bots/api#formatting-options for more details. * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. - * @param captionEntities Optional. List of special entities that appear in the caption, which can be specified instead of parseMode + * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode * @param disableContentTypeDetection Optional. Disables automatic server-side content type detection for files uploaded using multipart/form-data * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found + * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * * @return On success, the sent Message is returned. */ - Message::Ptr sendDocument(std::int64_t chatId, - boost::variant<InputFile::Ptr, std::string> document, - boost::variant<InputFile::Ptr, std::string> thumb = "", + Message::Ptr sendDocument(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<InputFile::Ptr, const std::string&> document, + boost::variant<InputFile::Ptr, const std::string&> thumb = "", const std::string& caption = "", std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), @@ -272,10 +301,12 @@ public: bool disableNotification = false, const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(), bool disableContentTypeDetection = false, - bool allowSendingWithoutReply = false) const; + bool allowSendingWithoutReply = false, + bool protectContent = false) const; /** * @brief Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). + * * Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future. * * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) @@ -284,34 +315,37 @@ public: * @param duration Optional. Duration of sent video in seconds * @param width Optional. Video width * @param height Optional. Video height - * @param thumb Optional Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. https://core.telegram.org/bots/api#sending-files + * @param thumb Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. https://core.telegram.org/bots/api#sending-files * @param caption Optional. Video caption (may also be used when resending videos by fileId), 0-1024 characters after entities parsing * @param replyToMessageId Optional. If the message is a reply, ID of the original message * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. * @param parseMode Optional. Mode for parsing entities in the video caption. See https://core.telegram.org/bots/api#formatting-options for more details. * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. - * @param captionEntities Optional. List of special entities that appear in the caption, which can be specified instead of parseMode + * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found + * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * * @return On success, the sent Message is returned. */ - Message::Ptr sendVideo(std::int64_t chatId, - boost::variant<InputFile::Ptr, std::string> video, + Message::Ptr sendVideo(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<InputFile::Ptr, const std::string&> video, bool supportsStreaming = false, std::int32_t duration = 0, std::int32_t width = 0, std::int32_t height = 0, - boost::variant<InputFile::Ptr, std::string> thumb = "", + boost::variant<InputFile::Ptr, const std::string&> thumb = "", const std::string& caption = "", std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false, const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(), - bool allowSendingWithoutReply = false) const; + bool allowSendingWithoutReply = false, + bool protectContent = false) const; /** * @brief Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). + * * Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. * * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) @@ -325,27 +359,30 @@ public: * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. * @param parseMode Optional. Mode for parsing entities in the animation caption. See https://core.telegram.org/bots/api#formatting-options for more details. * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. - * @param captionEntities Optional. List of special entities that appear in the caption, which can be specified instead of parseMode + * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found + * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * * @return On success, the sent Message is returned. */ - Message::Ptr sendAnimation(std::int64_t chatId, - boost::variant<InputFile::Ptr, std::string> animation, + Message::Ptr sendAnimation(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<InputFile::Ptr, const std::string&> animation, std::int32_t duration = 0, std::int32_t width = 0, std::int32_t height = 0, - boost::variant<InputFile::Ptr, std::string> thumb = "", + boost::variant<InputFile::Ptr, const std::string&> thumb = "", const std::string& caption = "", std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false, const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(), - bool allowSendingWithoutReply = false) const; + bool allowSendingWithoutReply = false, + bool protectContent = false) const; /** * @brief Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. + * * For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). * Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. * @@ -357,13 +394,14 @@ public: * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. * @param parseMode Optional. Mode for parsing entities in the voice message caption. See https://core.telegram.org/bots/api#formatting-options for more details. * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. - * @param captionEntities Optional. List of special entities that appear in the caption, which can be specified instead of parseMode + * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found + * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * * @return On success, the sent Message is returned. */ - Message::Ptr sendVoice(std::int64_t chatId, - boost::variant<InputFile::Ptr, std::string> voice, + Message::Ptr sendVoice(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<InputFile::Ptr, const std::string&> voice, const std::string& caption = "", std::int32_t duration = 0, std::int32_t replyToMessageId = 0, @@ -371,11 +409,13 @@ public: const std::string& parseMode = "", bool disableNotification = false, const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(), - bool allowSendingWithoutReply = false) const; + bool allowSendingWithoutReply = false, + bool protectContent = false) const; /** - * @brief As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. - * Use this method to send video messages. + * @brief Use this method to send video messages. + * + * As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. * * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param videoNote Video note to send. Pass a fileId as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. Sending video notes by a URL is currently unsupported. https://core.telegram.org/bots/api#sending-files @@ -386,21 +426,24 @@ public: * @param thumb Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. https://core.telegram.org/bots/api#sending-files * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found + * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * * @return On success, the sent Message is returned. */ - Message::Ptr sendVideoNote(std::int64_t chatId, - boost::variant<InputFile::Ptr, std::string> videoNote, + Message::Ptr sendVideoNote(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<InputFile::Ptr, const std::string&> videoNote, std::int64_t replyToMessageId = 0, bool disableNotification = false, std::int32_t duration = 0, std::int32_t length = 0, - boost::variant<InputFile::Ptr, std::string> thumb = "", + boost::variant<InputFile::Ptr, const std::string&> thumb = "", GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), - bool allowSendingWithoutReply = false) const; + bool allowSendingWithoutReply = false, + bool protectContent = false) const; /** * @brief Use this method to send a group of photos, videos, documents or audios as an album. + * * Documents and audio files can be only group in an album with messages of the same type. * * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) @@ -408,14 +451,16 @@ public: * @param disableNotification Optional. Sends messages silently. Users will receive a notification with no sound. * @param replyToMessageId Optional. If the messages are a reply, ID of the original message * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found + * @param protectContent Optional. Protects the contents of the sent messages from forwarding and saving * * @return On success, an array of Messages that were sent is returned. */ - std::vector<Message::Ptr> sendMediaGroup(std::int64_t chatId, + std::vector<Message::Ptr> sendMediaGroup(boost::variant<std::int64_t, const std::string&> chatId, const std::vector<InputMedia::Ptr>& media, bool disableNotification = false, std::int32_t replyToMessageId = 0, - bool allowSendingWithoutReply = false) const; + bool allowSendingWithoutReply = false, + bool protectContent = false) const; /** * @brief Use this method to send point on the map. @@ -423,7 +468,7 @@ public: * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param latitude Latitude of the location * @param longitude Longitude of the location - * @param livePeriod Optional. Period in seconds for which the location will be updated (see Live Locations, should be between 60 and 86400. + * @param livePeriod Optional. Period in seconds for which the location will be updated (see https://telegram.org/blog/live-locations, should be between 60 and 86400. * @param replyToMessageId Optional. If the message is a reply, ID of the original message * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. @@ -431,20 +476,22 @@ public: * @param heading Optional. For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. * @param proximityAlertRadius Optional. For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified. * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found + * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * * @return On success, the sent Message is returned. */ - Message::Ptr sendLocation(std::int64_t chatId, + Message::Ptr sendLocation(boost::variant<std::int64_t, const std::string&> chatId, float latitude, float longitude, - std::uint32_t livePeriod = 0, + std::int32_t livePeriod = 0, std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false, float horizontalAccuracy = 0, - std::uint32_t heading = 0, - std::uint32_t proximityAlertRadius = 0, - bool allowSendingWithoutReply = false) const; + std::int32_t heading = 0, + std::int32_t proximityAlertRadius = 0, + bool allowSendingWithoutReply = false, + bool protectContent = false) const; /** * @brief Use this method to edit live location messages. @@ -499,10 +546,11 @@ public: * @param googlePlaceId Optional. Google Places identifier of the venue * @param googlePlaceType Optional. Google Places type of the venue. (See https://developers.google.com/places/web-service/supported_types) * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found + * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * * @return On success, the sent Message is returned. */ - Message::Ptr sendVenue(std::int64_t chatId, + Message::Ptr sendVenue(boost::variant<std::int64_t, const std::string&> chatId, float latitude, float longitude, const std::string& title, @@ -514,7 +562,8 @@ public: GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& googlePlaceId = "", const std::string& googlePlaceType = "", - bool allowSendingWithoutReply = false) const; + bool allowSendingWithoutReply = false, + bool protectContent = false) const; /** * @brief Use this method to send phone contacts. @@ -528,10 +577,11 @@ public: * @param replyToMessageId Optional. If the message is a reply, ID of the original message * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove keyboard or to force a reply from the user. * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found + * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * * @return On success, the sent Message is returned. */ - Message::Ptr sendContact(std::int64_t chatId, + Message::Ptr sendContact(boost::variant<std::int64_t, const std::string&> chatId, const std::string& phoneNumber, const std::string& firstName, const std::string& lastName = "", @@ -539,7 +589,8 @@ public: bool disableNotification = false, std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), - bool allowSendingWithoutReply = false) const; + bool allowSendingWithoutReply = false, + bool protectContent = false) const; /** * @brief Use this method to send a native poll. @@ -561,10 +612,11 @@ public: * @param closeDate Optional. Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can't be used together with openPeriod. * @param isClosed Optional. Pass True, if the poll needs to be immediately closed. This can be useful for poll preview. * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found + * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * * @return On success, the sent Message is returned. */ - Message::Ptr sendPoll(std::int64_t chatId, + Message::Ptr sendPoll(boost::variant<std::int64_t, const std::string&> chatId, const std::string& question, const std::vector<std::string>& options, bool disableNotification = false, @@ -580,7 +632,8 @@ public: std::int32_t openPeriod = 0, std::int32_t closeDate = 0, bool isClosed = false, - bool allowSendingWithoutReply = false) const; + bool allowSendingWithoutReply = false, + bool protectContent = false) const; /** * @brief Use this method to send an animated emoji that will display a random value. @@ -591,15 +644,17 @@ public: * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. * @param emoji Optional. Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲” * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found + * @param protectContent Optional. Protects the contents of the sent message from forwarding * * @return On success, the sent Message is returned. */ - Message::Ptr sendDice(std::int64_t chatId, + Message::Ptr sendDice(boost::variant<std::int64_t, const std::string&> chatId, bool disableNotification = false, std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& emoji = "", - bool allowSendingWithoutReply = false) const; + bool allowSendingWithoutReply = false, + bool protectContent = false) const; /** * @brief Use this method when you need to tell the user that something is happening on the bot's side. @@ -813,7 +868,7 @@ public: * @return the edited invite link as a ChatInviteLink object. */ ChatInviteLink::Ptr editChatInviteLink(std::int64_t chatId, - std::string inviteLink, + const std::string& inviteLink, std::int32_t expireDate = 0, std::int32_t memberLimit = 0, const std::string& name = "", @@ -830,7 +885,7 @@ public: * @return the revoked invite link as ChatInviteLink object. */ ChatInviteLink::Ptr revokeChatInviteLink(std::int64_t chatId, - std::string inviteLink) const; + const std::string& inviteLink) const; /** * @brief Use this method to approve a chat join request. @@ -1129,15 +1184,17 @@ public: * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found + * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * * @return On success, the sent Message is returned. */ - Message::Ptr sendSticker(std::int64_t chatId, - boost::variant<InputFile::Ptr, std::string> sticker, + Message::Ptr sendSticker(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<InputFile::Ptr, const std::string&> sticker, std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false, - bool allowSendingWithoutReply = false) const; + bool allowSendingWithoutReply = false, + bool protectContent = false) const; /** * @brief Use this method to get a sticker set. @@ -1273,10 +1330,11 @@ public: * @param maxTipAmount Optional. The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in https://core.telegram.org/bots/payments/currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0 * @param suggestedTipAmounts Optional. A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed maxTipAmount. * @param startParameter Optional. Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter + * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * * @return On success, the sent Message is returned. */ - Message::Ptr sendInvoice(std::int64_t chatId, + Message::Ptr sendInvoice(boost::variant<std::int64_t, const std::string&> chatId, const std::string& title, const std::string& description, const std::string& payload, @@ -1301,7 +1359,8 @@ public: bool allowSendingWithoutReply = false, std::int32_t maxTipAmount = 0, const std::vector<std::int32_t>& suggestedTipAmounts = std::vector<std::int32_t>(), - const std::string& startParameter = "") const; + const std::string& startParameter = "", + bool protectContent = false) const; /** * @brief Use this method to reply to shipping queries. @@ -1350,9 +1409,10 @@ public: * @param chatId Unique identifier for the target chat * @param gameShortName Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather. * @param replyToMessageId Optional. If the message is a reply, ID of the original message - * @param replyMarkup Optional. A JSON-serialized object for an inline keyboard. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game. + * @param replyMarkup Optional. A JSON-serialized object for an inline keyboard. If empty, one 'Play gameTitle' button will be shown. If not empty, the first button must launch the game. * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found + * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * * @return On success, the sent Message is returned. */ @@ -1361,7 +1421,8 @@ public: std::int32_t replyToMessageId = 0, InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>(), bool disableNotification = false, - bool allowSendingWithoutReply = false) const; + bool allowSendingWithoutReply = false, + bool protectContent = false) const; /** * @brief Use this method to set the score of the specified user in a game. diff --git a/include/tgbot/types/ChatMemberBanned.h b/include/tgbot/types/ChatMemberBanned.h index c54385e..90ae93e 100644 --- a/include/tgbot/types/ChatMemberBanned.h +++ b/include/tgbot/types/ChatMemberBanned.h @@ -26,7 +26,7 @@ public: /** * @brief Date when restrictions will be lifted for this user; unix time */ - std::int32_t untilDate; + std::uint32_t untilDate; }; } diff --git a/include/tgbot/types/ChatMemberRestricted.h b/include/tgbot/types/ChatMemberRestricted.h index 76a9cd7..d64c849 100644 --- a/include/tgbot/types/ChatMemberRestricted.h +++ b/include/tgbot/types/ChatMemberRestricted.h @@ -72,7 +72,7 @@ public: /** * @brief Date when restrictions will be lifted for this user; unix time */ - std::int32_t untilDate; + std::uint32_t untilDate; }; } diff --git a/include/tgbot/types/MessageEntity.h b/include/tgbot/types/MessageEntity.h index 6cf42f5..d1384e7 100644 --- a/include/tgbot/types/MessageEntity.h +++ b/include/tgbot/types/MessageEntity.h @@ -1,54 +1,55 @@ -#ifndef TGBOT_MESSAGEENTITY_H -#define TGBOT_MESSAGEENTITY_H - -#include "tgbot/types/User.h" - -#include <cstdint> -#include <memory> -#include <string> - -namespace TgBot { - -/** - * @brief This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc. - * - * @ingroup types - */ -class MessageEntity { -public: - typedef std::shared_ptr<MessageEntity> Ptr; - - /** - * @brief Type of the entity. - * Can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames) - */ - std::string type; - - /** - * @brief Offset in UTF-16 code units to the start of the entity - */ - std::int32_t offset; - - /** - * @brief Length of the entity in UTF-16 code units - */ - std::int32_t length; - - /** - * @brief Optional. For “text_link” only, url that will be opened after user taps on the text - */ - std::string url; - - /** - * @brief Optional. For “text_mention” only, the mentioned user - */ - User::Ptr user; - - /** - * @brief Optional. For “pre” only, the programming language of the entity text - */ - std::string language; -}; -} - -#endif //TGBOT_MESSAGEENTITY_H +#ifndef TGBOT_MESSAGEENTITY_H
+#define TGBOT_MESSAGEENTITY_H
+
+#include "tgbot/types/User.h"
+
+#include <cstdint>
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents one special entity in a text message.
+ * For example, hashtags, usernames, URLs, etc.
+ *
+ * @ingroup types
+ */
+class MessageEntity {
+public:
+ typedef std::shared_ptr<MessageEntity> Ptr;
+
+ /**
+ * @brief Type of the entity.
+ * Currently, can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames)
+ */
+ std::string type;
+
+ /**
+ * @brief Offset in UTF-16 code units to the start of the entity
+ */
+ std::int32_t offset;
+
+ /**
+ * @brief Length of the entity in UTF-16 code units
+ */
+ std::int32_t length;
+
+ /**
+ * @brief Optional. For “text_link” only, url that will be opened after user taps on the text
+ */
+ std::string url;
+
+ /**
+ * @brief Optional. For “text_mention” only, the mentioned user
+ */
+ User::Ptr user;
+
+ /**
+ * @brief Optional. For “pre” only, the programming language of the entity text
+ */
+ std::string language;
+};
+}
+
+#endif //TGBOT_MESSAGEENTITY_H
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<std::int64_t, const std::string&> c const std::string& parseMode, bool disableNotification, const std::vector<MessageEntity::Ptr>& entities, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector<HttpReqArg> 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<std::int64_t, const std::string&> 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<std::int64_t, const std::string&> 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<std::int64_t, const std::string&> chatId, + boost::variant<std::int64_t, const std::string&> fromChatId, + std::int32_t messageId, + bool disableNotification, + bool protectContent) const { vector<HttpReqArg> 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<MessageEntity::Ptr>& captionEntities, - bool disableNotification, std::int32_t replyToMessageId, bool allowSendingWithoutReply, - GenericReply::Ptr replyMarkup) const { +MessageId::Ptr Api::copyMessage(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<std::int64_t, const std::string&> fromChatId, + std::int32_t messageId, + const std::string& caption, + const std::string& parseMode, + const std::vector<MessageEntity::Ptr>& captionEntities, + bool disableNotification, + std::int32_t replyToMessageId, + bool allowSendingWithoutReply, + GenericReply::Ptr replyMarkup, + bool protectContent) const { vector<HttpReqArg> 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<InputFile::Ptr, std::string> photo, +Message::Ptr Api::sendPhoto(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<InputFile::Ptr, const std::string&> photo, const std::string& caption, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const std::string& parseMode, bool disableNotification, const std::vector<MessageEntity::Ptr>& captionEntities, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector<HttpReqArg> 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<InputFile::Ptr>(photo); args.emplace_back("photo", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("photo", boost::get<std::string>(photo)); + } else { // const std::string& + args.emplace_back("photo", boost::get<const std::string&>(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<InputFile::Ptr, std::string> audio, +Message::Ptr Api::sendAudio(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<InputFile::Ptr, const std::string&> audio, const std::string& caption, std::int32_t duration, const std::string& performer, const std::string& title, - boost::variant<InputFile::Ptr, std::string> thumb, + boost::variant<InputFile::Ptr, const std::string&> thumb, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const std::string& parseMode, bool disableNotification, const std::vector<MessageEntity::Ptr>& captionEntities, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector<HttpReqArg> 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<InputFile::Ptr>(audio); args.emplace_back("audio", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("audio", boost::get<std::string>(audio)); + } else { // const std::string& + args.emplace_back("audio", boost::get<const std::string&>(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<InputFile::Ptr>(thumb); args.emplace_back("thumb", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - auto thumbStr = boost::get<std::string>(thumb); + } else { // const std::string& + auto thumbStr = boost::get<const std::string&>(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<InputFile::Ptr, std::string> document, - boost::variant<InputFile::Ptr, std::string> thumb, +Message::Ptr Api::sendDocument(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<InputFile::Ptr, const std::string&> document, + boost::variant<InputFile::Ptr, const std::string&> 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<MessageEntity::Ptr>& captionEntities, bool disableContentTypeDetection, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector<HttpReqArg> 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<InputFile::Ptr>(document); args.emplace_back("document", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("document", boost::get<std::string>(document)); + } else { // const std::string& + args.emplace_back("document", boost::get<const std::string&>(document)); } - if (thumb.which() == 0 /* InputFile::Ptr */) { + if (thumb.which() == 0) { // InputFile::Ptr auto file = boost::get<InputFile::Ptr>(thumb); args.emplace_back("thumb", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - auto thumbStr = boost::get<std::string>(thumb); + } else { // const std::string& + auto thumbStr = boost::get<const std::string&>(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<InputFile::Ptr, std::string> video, +Message::Ptr Api::sendVideo(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<InputFile::Ptr, const std::string&> video, bool supportsStreaming, std::int32_t duration, std::int32_t width, std::int32_t height, - boost::variant<InputFile::Ptr, std::string> thumb, - const std::string& caption, + boost::variant<InputFile::Ptr, const std::string&> thumb, + const std::string& caption , std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const std::string& parseMode, bool disableNotification, const std::vector<MessageEntity::Ptr>& captionEntities, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector<HttpReqArg> 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<InputFile::Ptr>(video); args.emplace_back("video", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("video", boost::get<std::string>(video)); + } else { // const std::string& + args.emplace_back("video", boost::get<const std::string&>(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<InputFile::Ptr>(thumb); args.emplace_back("thumb", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - auto thumbStr = boost::get<std::string>(thumb); + } else { // const std::string& + auto thumbStr = boost::get<const std::string&>(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<InputFile::Ptr, std::string> animation, +Message::Ptr Api::sendAnimation(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<InputFile::Ptr, const std::string&> animation, std::int32_t duration, std::int32_t width, std::int32_t height, - boost::variant<InputFile::Ptr, std::string> thumb, + boost::variant<InputFile::Ptr, const std::string&> thumb, const std::string& caption, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const std::string& parseMode, bool disableNotification, const std::vector<MessageEntity::Ptr>& captionEntities, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector<HttpReqArg> 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<InputFile::Ptr>(animation); args.emplace_back("animation", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("animation", boost::get<std::string>(animation)); + } else { // const std::string& + args.emplace_back("animation", boost::get<const std::string&>(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<InputFile::Ptr>(thumb); args.emplace_back("thumb", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - auto thumbStr = boost::get<std::string>(thumb); + } else { // const std::string& + auto thumbStr = boost::get<const std::string&>(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<InputFile::Ptr, std::string> voice, +Message::Ptr Api::sendVoice(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<InputFile::Ptr, const std::string&> 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<MessageEntity::Ptr>& captionEntities, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector<HttpReqArg> 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<InputFile::Ptr>(voice); args.emplace_back("voice", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("voice", boost::get<std::string>(voice)); + } else { // const std::string& + args.emplace_back("voice", boost::get<const std::string&>(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<InputFile::Ptr, std::string> videoNote, +Message::Ptr Api::sendVideoNote(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<InputFile::Ptr, const std::string&> videoNote, std::int64_t replyToMessageId, bool disableNotification, std::int32_t duration, std::int32_t length, - boost::variant<InputFile::Ptr, std::string> thumb, + boost::variant<InputFile::Ptr, const std::string&> thumb, GenericReply::Ptr replyMarkup, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector<HttpReqArg> 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<InputFile::Ptr>(videoNote); args.emplace_back("video_note", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("video_note", boost::get<std::string>(videoNote)); + } else { // const std::string& + args.emplace_back("video_note", boost::get<const std::string&>(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<InputFile::Ptr>(thumb); args.emplace_back("thumb", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - auto thumbStr = boost::get<std::string>(thumb); + } else { // const std::string& + auto thumbStr = boost::get<const std::string&>(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<Message::Ptr> Api::sendMediaGroup(std::int64_t chatId, const std::vector<InputMedia::Ptr>& media, bool disableNotification, - std::int32_t replyToMessageId, bool allowSendingWithoutReply) const { +vector<Message::Ptr> Api::sendMediaGroup(boost::variant<std::int64_t, const std::string&> chatId, + const std::vector<InputMedia::Ptr>& media, + bool disableNotification, + std::int32_t replyToMessageId, + bool allowSendingWithoutReply, + bool protectContent) const { vector<HttpReqArg> args; - args.reserve(5); + args.reserve(6); args.emplace_back("chat_id", chatId); args.emplace_back("media", _tgTypeParser.parseArray<InputMedia>(&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<Message::Ptr> Api::sendMediaGroup(std::int64_t chatId, const std::vector< return _tgTypeParser.parseJsonAndGetArray<Message>(&TgTypeParser::parseJsonAndGetMessage, sendRequest("sendMediaGroup", args)); } -Message::Ptr Api::sendLocation(std::int64_t chatId, +Message::Ptr Api::sendLocation(boost::variant<std::int64_t, const std::string&> 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<HttpReqArg> 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<std::int64_t, const std::string&> 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<HttpReqArg> 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<std::int64_t, const std::string&> 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<HttpReqArg> 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<std::int64_t, const std::string&> chatId, const std::string& question, const std::vector<std::string>& 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<HttpReqArg> 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<std::int64_t, const std::string&> chatId, bool disableNotification, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const std::string& emoji, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector<HttpReqArg> 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<HttpReqArg> 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<InputFile::Ptr, std::string> sticker, +Message::Ptr Api::sendSticker(boost::variant<std::int64_t, const std::string&> chatId, + boost::variant<InputFile::Ptr, const std::string&> sticker, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, bool disableNotification, - bool allowSendingWithoutReply) const { + bool allowSendingWithoutReply, + bool protectContent) const { vector<HttpReqArg> 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<InputFile::Ptr>(sticker); args.emplace_back("sticker", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("sticker", boost::get<std::string>(sticker)); + } else { // const std::string& + args.emplace_back("sticker", boost::get<const std::string&>(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<Inlin return sendRequest("answerInlineQuery", args).get<bool>("", false); } -Message::Ptr Api::sendInvoice(std::int64_t chatId, +Message::Ptr Api::sendInvoice(boost::variant<std::int64_t, const std::string&> 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<std::int32_t>& suggestedTipAmounts, - const std::string& startParameter) const { + const std::string& startParameter, + bool protectContent) const { vector<HttpReqArg> 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<HttpReqArg> 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<bool>("can_send_polls", false); result->canSendOtherMessages = data.get<bool>("can_send_other_messages", false); result->canAddWebPagePreviews = data.get<bool>("can_add_web_page_previews", false); - result->untilDate = data.get<uint32_t>("until_date", 0); + result->untilDate = data.get<std::uint32_t>("until_date", 0); return result; } @@ -1666,9 +1666,9 @@ ChatInviteLink::Ptr TgTypeParser::parseJsonAndGetChatInviteLink(const boost::pro result->isPrimary = data.get<bool>("is_primary", false); result->isRevoked = data.get<bool>("is_revoked", false); result->name = data.get<std::string>("name", ""); - result->expireDate = data.get<std::int32_t>("expire_date", 0); - result->memberLimit = data.get<std::int32_t>("member_limit", 0); - result->pendingJoinRequestCount = data.get<std::int32_t>("pending_join_request_count", 0); + result->expireDate = data.get<std::uint32_t>("expire_date", 0); + result->memberLimit = data.get<std::uint32_t>("member_limit", 0); + result->pendingJoinRequestCount = data.get<std::uint32_t>("pending_join_request_count", 0); return result; } |