summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md9
-rw-r--r--include/tgbot/Api.h193
-rw-r--r--include/tgbot/TgTypeParser.h3
-rw-r--r--include/tgbot/types/Audio.h7
-rw-r--r--include/tgbot/types/Contact.h5
-rw-r--r--include/tgbot/types/InlineQueryResultContact.h5
-rw-r--r--include/tgbot/types/InlineQueryResultVenue.h5
-rw-r--r--include/tgbot/types/InputContactMessageContent.h5
-rw-r--r--include/tgbot/types/InputMedia.h32
-rw-r--r--include/tgbot/types/InputMediaAnimation.h49
-rw-r--r--include/tgbot/types/InputMediaAudio.h49
-rw-r--r--include/tgbot/types/InputMediaDocument.h49
-rw-r--r--include/tgbot/types/InputVenueMessageContent.h9
-rw-r--r--include/tgbot/types/Message.h8
-rw-r--r--include/tgbot/types/MessageEntity.h4
-rw-r--r--include/tgbot/types/Venue.h7
-rw-r--r--src/Api.cpp351
-rw-r--r--src/TgTypeParser.cpp120
-rw-r--r--src/net/HttpParser.cpp2
19 files changed, 524 insertions, 388 deletions
diff --git a/README.md b/README.md
index d460d7e..fc7e330 100644
--- a/README.md
+++ b/README.md
@@ -18,13 +18,8 @@ Documentation is located [here](http://reo7sp.github.io/tgbot-cpp).
## State
-- [x] Bot API 3.0
-- [x] Bot API 3.1
-- [x] Bot API 3.2
-- [x] Bot API 3.3
-- [x] Bot API 3.4
-- [x] Bot API 3.5
-- [x] Bot API 3.6
+- [x] Bot API 3.0 ~ 3.6
+- [x] Bot API 4.0 (Implemented all APIs except 'Telegram Passport')
## Sample
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index 0a781e6..84a6c9b 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -27,6 +27,7 @@
#include <vector>
#include <boost/property_tree/ptree.hpp>
+#include <boost/variant.hpp>
#include "tgbot/TgTypeParser.h"
#include "tgbot/net/HttpClient.h"
@@ -107,21 +108,7 @@ public:
* @param disableNotification Optional. Sends the message silenty.
* @return On success, the sent message is returned.
*/
- Message::Ptr sendPhoto(int64_t chatId, InputFile::Ptr photo, const std::string& caption = "", int32_t replyToMessageId = 0,
- GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
-
- /**
- * @brief Use this method to send photos.
- * @param chatId Unique identifier for the target chat.
- * @param photo Photo to send. Id of the photo that is already on the Telegram servers.
- * @param caption Optional. Photo caption.
- * @param replyToMessageId Optional. If the message is a reply, ID of the original message.
- * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
- * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
- * @param disableNotification Optional. Sends the message silenty.
- * @return On success, the sent message is returned.
- */
- Message::Ptr sendPhoto(int64_t chatId, const std::string& photoId, const std::string& caption = "", int32_t replyToMessageId = 0,
+ Message::Ptr sendPhoto(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> photo, const std::string& caption = "", int32_t replyToMessageId = 0,
GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
/**
@@ -132,38 +119,22 @@ public:
* @param duration Duration of sent audio in seconds.
* @param performer Performer
* @param title Track name
+ * @param thumb Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. 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>.
* @param replyToMessageId Optional. If the message is a reply, ID of the original message.
* @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
* @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
* @param disableNotification Optional. Sends the message silenty.
* @return On success, the sent message is returned.
*/
- Message::Ptr sendAudio(int64_t chatId, InputFile::Ptr audio, const std::string &caption = "", int32_t duration = 0,
- const std::string& performer = "", const std::string& title = "", int32_t replyToMessageId = 0,
- GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = 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 Document).
- * @param chatId Unique identifier for the target chat.
- * @param audio Id of the audio that is already on the Telegram servers.
- * @param caption Audio caption, 0-200 characters
- * @param duration Duration of sent audio in seconds.
- * @param performer Performer
- * @param title Track name
- * @param replyToMessageId Optional. If the message is a reply, ID of the original message.
- * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
- * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
- * @param disableNotification Optional. Sends the message silenty.
- * @return On success, the sent message is returned.
- */
- Message::Ptr sendAudio(int64_t chatId, const std::string& audioId, const std::string &caption = "", int32_t duration = 0,
- const std::string& performer = "", const std::string& title = "", int32_t replyToMessageId = 0,
+ Message::Ptr sendAudio(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> audio, const std::string &caption = "", int32_t duration = 0,
+ const std::string& performer = "", const std::string& title = "", const boost::variant<InputFile::Ptr, std::string> thumb = "", int32_t replyToMessageId = 0,
GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
/**
* @brief Use this method to send general files.
* @param chatId Unique identifier for the target chat.
* @param document Document to send.
+ * @param thumb Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. 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>.
* @param caption Document caption (may also be used when resending documents by file_id), 0-200 characters
* @param replyToMessageId Optional. If the message is a reply, ID of the original message.
* @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
@@ -171,21 +142,7 @@ public:
* @param disableNotification Optional. Sends the message silenty.
* @return On success, the sent message is returned.
*/
- Message::Ptr sendDocument(int64_t chatId, InputFile::Ptr document, const std::string &caption = "", int32_t replyToMessageId = 0,
- GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
-
- /**
- * @brief Use this method to send general files.
- * @param chatId Unique identifier for the target chat.
- * @param document Id of the document that is already on the Telegram servers.
- * @param caption Document caption (may also be used when resending documents by file_id), 0-200 characters
- * @param replyToMessageId Optional. If the message is a reply, ID of the original message.
- * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
- * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
- * @param disableNotification Optional. Sends the message silenty.
- * @return On success, the sent message is returned.
- */
- Message::Ptr sendDocument(int64_t chatId, const std::string& documentId, const std::string &caption = "", int32_t replyToMessageId = 0,
+ Message::Ptr sendDocument(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> document, const boost::variant<InputFile::Ptr, std::string> thumb = "", const std::string &caption = "", int32_t replyToMessageId = 0,
GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
/**
@@ -258,19 +215,7 @@ public:
* @param disableNotification Optional. Sends the message silenty.
* @return On success, the sent message is returned.
*/
- Message::Ptr sendSticker(int64_t chatId, InputFile::Ptr sticker, int32_t replyToMessageId = 0,
- GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const;
-
- /**
- * @brief Use this method to send .webp stickers.
- * @param chatId Unique identifier for the target chat.
- * @param stickerId Id of the sticker that is already on the Telegram servers.
- * @param replyToMessageId Optional. If the message is a reply, ID of the original message.
- * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
- * @param disableNotification Optional. Sends the message silenty.
- * @return On success, the sent message is returned.
- */
- Message::Ptr sendSticker(int64_t chatId, const std::string& stickerId, int32_t replyToMessageId = 0,
+ Message::Ptr sendSticker(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> sticker, int32_t replyToMessageId = 0,
GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const;
/**
@@ -300,21 +245,7 @@ public:
* @return Returns True on success.
*/
bool createNewStickerSet(int32_t userId, const std::string& name, const std::string& title,
- InputFile::Ptr pngSticker, const std::string& emojis, bool containsMasks = false, MaskPosition::Ptr maskPosition = nullptr) const;
-
- /**
- * @brief Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set.
- * @param userId User identifier of created sticker set owner.
- * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters.
- * @param title Sticker set title, 1-64 characters.
- * @param pngSticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet.
- * @param emojis One or more emoji corresponding to the sticker.
- * @param containsMasks Optional. Pass True, if a set of mask stickers should be created.
- * @param maskPosition Optional. A JSON-serialized object for position where the mask should be placed on faces.
- * @return Returns True on success.
- */
- bool createNewStickerSet(int32_t userId, const std::string& name, const std::string& title,
- const std::string& pngSticker, const std::string& emojis, bool containsMasks = false, MaskPosition::Ptr maskPosition = nullptr) const;
+ boost::variant<InputFile::Ptr, std::string> pngSticker, const std::string& emojis, bool containsMasks = false, MaskPosition::Ptr maskPosition = nullptr) const;
/**
* @brief Use this method to add a new sticker to a set created by the bot.
@@ -327,20 +258,7 @@ public:
* @return Returns True on success.
*/
bool addStickerToSet(int32_t userId, const std::string& name, const std::string& title,
- InputFile::Ptr pngSticker, const std::string& emojis, MaskPosition::Ptr maskPosition = nullptr) const;
-
- /**
- * @brief Use this method to add a new sticker to a set created by the bot.
- * @param userId User identifier of created sticker set owner.
- * @param name Sticker set name.
- * @param title Sticker set title, 1-64 characters.
- * @param pngSticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet.
- * @param emojis One or more emoji corresponding to the sticker.
- * @param maskPosition Optional. A JSON-serialized object for position where the mask should be placed on faces.
- * @return Returns True on success.
- */
- bool addStickerToSet(int32_t userId, const std::string& name, const std::string& title,
- const std::string& pngSticker, const std::string& emojis, MaskPosition::Ptr maskPosition = nullptr) const;
+ boost::variant<InputFile::Ptr, std::string> pngSticker, const std::string& emojis, MaskPosition::Ptr maskPosition = nullptr) const;
/**
* @brief Use this method to move a sticker in a set created by the bot to a specific position.
@@ -365,6 +283,7 @@ public:
* @param duration Optional. Duration of sent video in seconds
* @param width Optional. Video width
* @param height Optional. Video height
+ * @param thumb Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. 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>.
* @param caption Optional. Video caption (may also be used when resending videos by file_id), 0-200 characters
* @param replyToMessageId Optional. If the message is a reply, ID of the original message.
* @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
@@ -372,54 +291,43 @@ public:
* @param disableNotification Optional. Sends the message silenty.
* @return On success, the sent message is returned.
*/
- Message::Ptr sendVideo(int64_t chatId, InputFile::Ptr video, bool supportsStreaming = false, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const std::string& caption = "",
+ Message::Ptr sendVideo(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> video, bool supportsStreaming = false, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const boost::variant<InputFile::Ptr, std::string> thumb = "", const std::string& caption = "",
int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
/**
- * @brief Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
+ * @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.
- * @param videoId Id of the video that is already on the Telegram servers.
- * @param supportsStreaming Optional. Pass True, if the uploaded video is suitable for streaming.
- * @param duration Optional. Duration of sent video in seconds
- * @param width Optional. Video width
- * @param height Optional. Video height
- * @param caption Optional. Video caption (may also be used when resending videos by file_id), 0-200 characters
+ * @param animation Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data.
+ * @param duration Optional. Duration of sent animation in seconds.
+ * @param width Optional. Animation width.
+ * @param height Optional. Animation height.
+ * @param thumb Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. 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>.
+ * @param caption Optional. Animation caption (may also be used when resending animation by file_id), 0-200 characters
* @param replyToMessageId Optional. If the message is a reply, ID of the original message.
- * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
+ * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
* @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
* @param disableNotification Optional. Sends the message silenty.
- * @return On success, the sent message is returned.
- */
- Message::Ptr sendVideo(int64_t chatId, const std::string& videoId, bool supportsStreaming = false, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const std::string& caption = "",
- int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
-
- /**
- * @brief Use this method to send video messages. On success, the sent Message is returned.
- * @param chatId Unique identifier for the target chat.
- * @param videoNote Video note to send.
- * @param replyToMessageId If the message is a reply, ID of the original message.
- * @param disableNotification Sends the message silently. Users will receive a notification with no sound.
- * @param duration Duration of sent video in seconds.
- * @param length Video width and height.
- * @param replyMarkup Additional interface options. A object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendVideoNote(int64_t chatId, InputFile::Ptr videoNote, int64_t replyToMessageId = 0, bool disableNotification = false,
- int32_t duration = 0, int32_t length = 0, GenericReply::Ptr replyMarkup = GenericReply::Ptr());
-
+ Message::Ptr sendAnimation(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> animation, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const boost::variant<InputFile::Ptr, std::string> thumb = "", const std::string &caption = "",
+ int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
/**
* @brief Use this method to send video messages. On success, the sent Message is returned.
* @param chatId Unique identifier for the target chat.
- * @param videoNote Id of the video note that exists on the Telegram servers.
+ * @param videoNote Video note to send.
* @param replyToMessageId If the message is a reply, ID of the original message.
* @param disableNotification Sends the message silently. Users will receive a notification with no sound.
* @param duration Duration of sent video in seconds.
* @param length Video width and height.
+ * @param thumb Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. 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>.
* @param replyMarkup Additional interface options. A object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendVideoNote(int64_t chatId, const std::string& videoNote, int64_t replyToMessageId = 0, bool disableNotification = false,
- int32_t duration = 0, int32_t length = 0, GenericReply::Ptr replyMarkup = GenericReply::Ptr());
+ Message::Ptr sendVideoNote(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> videoNote, int64_t replyToMessageId = 0, bool disableNotification = false,
+ int32_t duration = 0, int32_t length = 0, const boost::variant<InputFile::Ptr, std::string> thumb = "", GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
/**
* @brief Use this method to send a group of photos or videos as an album.
@@ -444,22 +352,7 @@ public:
* @param disableNotification Optional. Sends the message silenty.
* @return On success, the sent message is returned.
*/
- Message::Ptr sendVoice(int64_t chatId, InputFile::Ptr voice, const std::string& caption = "", int duration = 0, int32_t replyToMessageId = 0,
- GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
-
- /**
- * @brief Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message.
- * @param chatId Unique identifier for the target chat.
- * @param voiceId Id of the voice that is already on the Telegram servers.
- * @param caption Voice message caption, 0-200 characters
- * @param duration Duration of send audio in seconds.
- * @param replyToMessageId Optional. If the message is a reply, ID of the original message.
- * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
- * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
- * @param disableNotification Optional. Sends the message silenty.
- * @return On success, the sent message is returned.
- */
- Message::Ptr sendVoice(int64_t chatId, const std::string& voiceId, const std::string& caption = "", int duration = 0, int32_t replyToMessageId = 0,
+ Message::Ptr sendVoice(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> voice, const std::string& caption = "", int duration = 0, int32_t replyToMessageId = 0,
GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
/**
@@ -520,13 +413,14 @@ public:
* @param longitude Longitude of location.
* @param title Name of the venue.
* @param address Address of the venue.
- * @param foursquare_id Foursquare identifier of the venue.
+ * @param foursquareId Foursquare identifier of the venue.
+ * @param foursquareType Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
* @param replyToMessageId Optional. If the message is a reply, ID of the original message.
* @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
* @param disableNotification Optional. Sends the message silenty.
* @return On success, the sent message is returned.
*/
- Message::Ptr sendVenue(int64_t chatId, float latitude, float longitude, const std::string& title, const std::string& address, const std::string& foursquareId = "",
+ Message::Ptr sendVenue(int64_t chatId, float latitude, float longitude, const std::string& title, const std::string& address, const std::string& foursquareId = "", const std::string& foursquareType = "",
bool disableNotification = false, int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
/**
@@ -535,12 +429,13 @@ public:
* @param phoneNumber Contact's phone number.
* @param firstName Contact's first name.
* @param lastName Contact's last name.
+ * @param vcard Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes.
* @param disableNotification Optional. Sends the message silenty.
* @param replyToMessageId Optional. If the message is a reply, ID of the original message.
* @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
* @return On success, the sent message is returned.
*/
- Message::Ptr sendContact(int64_t chatId, const std::string& phoneNumber, const std::string& firstName, const std::string& lastName = "", bool disableNotification = false,
+ Message::Ptr sendContact(int64_t chatId, const std::string& phoneNumber, const std::string& firstName, const std::string& lastName = "", const std::string& vcard = "", bool disableNotification = false,
int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
/**
@@ -660,6 +555,24 @@ public:
const std::string& inlineMessageId = "", GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
/**
+ * @brief Use this method to edit audio, document, photo, or video messages.
+ *
+ *
+ * If a message is a part of a message album, then it can be edited only to a photo or a video.
+ * Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded.
+ * Use previously uploaded file via its file_id or specify a URL.
+ *
+ * @param media A JSON-serialized object for a new media content of the message.
+ * @param chatId Optional Required if inline_message_id is not specified. Unique identifier for the target chat of the target channel.
+ * @param messageId Optional Required if inline_message_id is not specified. Identifier of the sent message
+ * @param inlineMessageId Optional Required if chat_id and message_id are not specified. Identifier of the inline message
+ * @param replyMarkup Optional A JSON-serialized object for an inline keyboard.
+ * @return On success, if the edited message was sent by the bot, the edited Message is returned, otherwise nullptr is returned.
+ */
+ Message::Ptr editMessageMedia(InputMedia::Ptr media, int64_t chatId = 0, int32_t messageId = 0, const std::string& inlineMessageId = "",
+ GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
+
+ /**
* @brief Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
* @param chatId Optional Required if inline_message_id is not specified. Unique identifier for the target chat of the target channel.
* @param messageId Optional Required if inline_message_id is not specified. Identifier of the sent message
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index 656007b..06e7890 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -99,6 +99,9 @@
#include "tgbot/types/InputMedia.h"
#include "tgbot/types/InputMediaPhoto.h"
#include "tgbot/types/InputMediaVideo.h"
+#include "tgbot/types/InputMediaAudio.h"
+#include "tgbot/types/InputMediaDocument.h"
+#include "tgbot/types/InputMediaAnimation.h"
namespace TgBot {
diff --git a/include/tgbot/types/Audio.h b/include/tgbot/types/Audio.h
index 3b8b3e3..b77a106 100644
--- a/include/tgbot/types/Audio.h
+++ b/include/tgbot/types/Audio.h
@@ -26,6 +26,8 @@
#include <string>
#include <memory>
+#include "tgbot/types/PhotoSize.h"
+
namespace TgBot {
/**
@@ -69,6 +71,11 @@ public:
* @brief Optional. File size.
*/
int32_t fileSize;
+
+ /**
+ * @brief Optional. Thumbnail of the album cover to which the music file belongs
+ */
+ PhotoSize::Ptr thumb;
};
}
diff --git a/include/tgbot/types/Contact.h b/include/tgbot/types/Contact.h
index eb17e5a..9cfc477 100644
--- a/include/tgbot/types/Contact.h
+++ b/include/tgbot/types/Contact.h
@@ -57,6 +57,11 @@ public:
* @brief Optional. Contact's user identifier in Telegram.
*/
std::string userId;
+
+ /**
+ * @brief Optional. Additional data about the contact in the form of a vCard.
+ */
+ std::string vcard;
};
}
diff --git a/include/tgbot/types/InlineQueryResultContact.h b/include/tgbot/types/InlineQueryResultContact.h
index 39bd570..3f18a2a 100644
--- a/include/tgbot/types/InlineQueryResultContact.h
+++ b/include/tgbot/types/InlineQueryResultContact.h
@@ -45,6 +45,11 @@ public:
std::string lastName;
/**
+ * @brief Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes
+ */
+ std::string vcard;
+
+ /**
* @brief Optional. Url of the thumbnail for the result
*/
std::string thumbUrl;
diff --git a/include/tgbot/types/InlineQueryResultVenue.h b/include/tgbot/types/InlineQueryResultVenue.h
index d012463..3f58e19 100644
--- a/include/tgbot/types/InlineQueryResultVenue.h
+++ b/include/tgbot/types/InlineQueryResultVenue.h
@@ -50,6 +50,11 @@ public:
std::string foursquareId;
/**
+ * @brief Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
+ */
+ std::string foursquareType;
+
+ /**
* @brief Optional. Url of the thumbnail for the result
*/
std::string thumbUrl;
diff --git a/include/tgbot/types/InputContactMessageContent.h b/include/tgbot/types/InputContactMessageContent.h
index 865dbba..799fa64 100644
--- a/include/tgbot/types/InputContactMessageContent.h
+++ b/include/tgbot/types/InputContactMessageContent.h
@@ -38,6 +38,11 @@ public:
*/
std::string lastName;
+ /**
+ * @brief Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes
+ */
+ std::string vcard;
+
virtual ~InputContactMessageContent() { }
};
}
diff --git a/include/tgbot/types/InputMedia.h b/include/tgbot/types/InputMedia.h
index a4610ad..f9e37ff 100644
--- a/include/tgbot/types/InputMedia.h
+++ b/include/tgbot/types/InputMedia.h
@@ -41,11 +41,14 @@ public:
enum class TYPE : uint8_t {
PHOTO,
- VIDEO
+ VIDEO,
+ ANIMATION,
+ DOCUMENT,
+ AUDIO
};
/**
- * @brief Type of the result, It should be one of TYPE::PHOTO/TYPE::VIDEO
+ * @brief Type of the result, It should be one of TYPE::*
*/
TYPE type;
@@ -55,7 +58,14 @@ public:
std::string media;
/**
- * @brief Optional. Caption of the photo to be sent, 0-200 characters
+ * @brief Optional. Thumbnail of the file sent.
+ *
+ * The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. 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>.
+ */
+ std::string thumb;
+
+ /**
+ * @brief Optional. Caption of the media to be sent, 0-200 characters
*/
std::string caption;
@@ -65,21 +75,31 @@ public:
std::string parseMode;
/**
- * @brief Optional. Video width
+ * @brief Optional. Media width
*/
int32_t width = 0;
/**
- * @brief Optional. Video height
+ * @brief Optional. Media height
*/
int32_t height = 0;
/**
- * @brief Optional. Video duration
+ * @brief Optional. Media duration
*/
int32_t duration = 0;
/**
+ * @brief Optional. Performer of the audio.
+ */
+ int32_t performer = 0;
+
+ /**
+ * @brief Optional. Title of the audio.
+ */
+ int32_t title = 0;
+
+ /**
* @brief Optional. Pass True, if the uploaded video is suitable for streaming
*/
bool supportsStreaming = false;
diff --git a/include/tgbot/types/InputMediaAnimation.h b/include/tgbot/types/InputMediaAnimation.h
new file mode 100644
index 0000000..8b3b976
--- /dev/null
+++ b/include/tgbot/types/InputMediaAnimation.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015 Oleg Morozenkov
+ * Copyright (c) 2016 Konstantin Kukin
+ * Copyright (c) 2018 JellyBrick
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef TGBOT_INPUTMEDIAANIMATION_H
+#define TGBOT_INPUTMEDIAANIMATION_H
+
+#include <memory>
+#include <string>
+
+#include "tgbot/types/InputMedia.h"
+
+namespace TgBot {
+
+/**
+ * @brief Represents a video to be sent.
+ * @ingroup types
+ */
+class InputMediaAnimation : public InputMedia {
+public:
+ typedef std::shared_ptr<InputMediaAnimation> Ptr;
+
+ InputMediaAnimation() {
+ this->type = TYPE::ANIMATION;
+ }
+};
+}
+
+#endif //TGBOT_INPUTMEDIAANIMATION_H
diff --git a/include/tgbot/types/InputMediaAudio.h b/include/tgbot/types/InputMediaAudio.h
new file mode 100644
index 0000000..08b21ab
--- /dev/null
+++ b/include/tgbot/types/InputMediaAudio.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015 Oleg Morozenkov
+ * Copyright (c) 2016 Konstantin Kukin
+ * Copyright (c) 2018 JellyBrick
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef TGBOT_INPUTMEDIAAUDIO_H
+#define TGBOT_INPUTMEDIAAUDIO_H
+
+#include <memory>
+#include <string>
+
+#include "tgbot/types/InputMedia.h"
+
+namespace TgBot {
+
+/**
+ * @brief Represents a video to be sent.
+ * @ingroup types
+ */
+class InputMediaAudio : public InputMedia {
+public:
+ typedef std::shared_ptr<InputMediaAudio> Ptr;
+
+ InputMediaAudio() {
+ this->type = TYPE::AUDIO;
+ }
+};
+}
+
+#endif //TGBOT_INPUTMEDIAAUDIO_H
diff --git a/include/tgbot/types/InputMediaDocument.h b/include/tgbot/types/InputMediaDocument.h
new file mode 100644
index 0000000..a00eabb
--- /dev/null
+++ b/include/tgbot/types/InputMediaDocument.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015 Oleg Morozenkov
+ * Copyright (c) 2016 Konstantin Kukin
+ * Copyright (c) 2018 JellyBrick
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef TGBOT_INPUTMEDIADOCUMENT_H
+#define TGBOT_INPUTMEDIADOCUMENT_H
+
+#include <memory>
+#include <string>
+
+#include "tgbot/types/InputMedia.h"
+
+namespace TgBot {
+
+/**
+ * @brief Represents a video to be sent.
+ * @ingroup types
+ */
+class InputMediaDocument : public InputMedia {
+public:
+ typedef std::shared_ptr<InputMediaDocument> Ptr;
+
+ InputMediaDocument() {
+ this->type = TYPE::DOCUMENT;
+ }
+};
+}
+
+#endif //TGBOT_INPUTMEDIADOCUMENT_H
diff --git a/include/tgbot/types/InputVenueMessageContent.h b/include/tgbot/types/InputVenueMessageContent.h
index 115e7d0..1f0bea7 100644
--- a/include/tgbot/types/InputVenueMessageContent.h
+++ b/include/tgbot/types/InputVenueMessageContent.h
@@ -48,6 +48,15 @@ public:
* @brief Optional. Foursquare identifier of the venue, if known
*/
std::string foursquareId;
+
+ /**
+ * @brief Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
+ */
+ std::string foursquareType;
+
+ /**
+ * @brief Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
+ */
virtual ~InputVenueMessageContent() { }
};
diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h
index 1f5c75a..f92eeaf 100644
--- a/include/tgbot/types/Message.h
+++ b/include/tgbot/types/Message.h
@@ -32,6 +32,7 @@
#include "tgbot/types/Message.h"
#include "tgbot/types/Audio.h"
#include "tgbot/types/Document.h"
+#include "tgbot/types/Animation.h"
#include "tgbot/types/Sticker.h"
#include "tgbot/types/Video.h"
#include "tgbot/types/Contact.h"
@@ -141,6 +142,13 @@ public:
Document::Ptr document;
/**
+ * @brief Optional. Message is an animation, information about the animation.
+ *
+ * For backward compatibility, when this field is set, the document field will also be set.
+ */
+ Animation::Ptr animation;
+
+ /**
* @brief Optional. Message is a game, information about the game.
*/
Game::Ptr game;
diff --git a/include/tgbot/types/MessageEntity.h b/include/tgbot/types/MessageEntity.h
index ca495ee..530011b 100644
--- a/include/tgbot/types/MessageEntity.h
+++ b/include/tgbot/types/MessageEntity.h
@@ -21,7 +21,9 @@ public:
typedef std::shared_ptr<MessageEntity> Ptr;
/**
- * @brief Type of the entity. One of mention (@username), hashtag, bot_command, url, email, bold (bold text), italic (italic text), code (monowidth string), pre (monowidth block), text_link (for clickable text URLs).
+ * @brief Type of the entity.
+ *
+ * Can be mention (@username), hashtag, cashtag, bot_command, url, email, phone_number, bold (bold text), italic (italic text), code (monowidth string), pre (monowidth block), text_link (for clickable text URLs), text_mention (for users without usernames)
*/
std::string type;
diff --git a/include/tgbot/types/Venue.h b/include/tgbot/types/Venue.h
index 657d951..cc52314 100644
--- a/include/tgbot/types/Venue.h
+++ b/include/tgbot/types/Venue.h
@@ -39,7 +39,12 @@ public:
/**
* @brief Optional. Foursquare identifier of the venue.
*/
- std::string foursquare_id;
+ std::string foursquareId;
+
+ /**
+ * @brief Optional. Foursquare type of the venue. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
+ */
+ std::string foursquareType;
};
}
diff --git a/src/Api.cpp b/src/Api.cpp
index 08f5fac..6b41947 100644
--- a/src/Api.cpp
+++ b/src/Api.cpp
@@ -75,34 +75,16 @@ Message::Ptr Api::forwardMessage(int64_t chatId, int64_t fromChatId, int32_t mes
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("forwardMessage", args));
}
-Message::Ptr Api::sendPhoto(int64_t chatId, const InputFile::Ptr photo, const string& caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
+Message::Ptr Api::sendPhoto(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> photo, const string& caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
vector<HttpReqArg> args;
args.reserve(7);
args.emplace_back("chat_id", chatId);
- args.emplace_back("photo", photo->data, true, photo->mimeType, photo->fileName);
- if (!caption.empty()) {
- args.emplace_back("caption", caption);
- }
- if (replyToMessageId) {
- args.emplace_back("reply_to_message_id", replyToMessageId);
- }
- 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);
+ 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));
}
- return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendPhoto", args));
-}
-
-Message::Ptr Api::sendPhoto(int64_t chatId, const string& photoId, const string& caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
- vector<HttpReqArg> args;
- args.reserve(7);
- args.emplace_back("chat_id", chatId);
- args.emplace_back("photo", photoId);
if (!caption.empty()) {
args.emplace_back("caption", caption);
}
@@ -121,43 +103,16 @@ Message::Ptr Api::sendPhoto(int64_t chatId, const string& photoId, const string&
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendPhoto", args));
}
-Message::Ptr Api::sendAudio(int64_t chatId, const InputFile::Ptr audio, const string &caption, int32_t duration, const string& performer, const string& title, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
+Message::Ptr Api::sendAudio(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> audio, const string &caption, int32_t duration, const string& performer, const string& title, const boost::variant<InputFile::Ptr, std::string> thumb, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
vector<HttpReqArg> args;
- args.reserve(10);
+ args.reserve(11);
args.emplace_back("chat_id", chatId);
- args.emplace_back("audio", audio->data, true, audio->mimeType, audio->fileName);
- if (!caption.empty()) {
- args.emplace_back("caption", caption);
+ 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));
}
- if (duration) {
- args.emplace_back("duration", duration);
- }
- if (!performer.empty()){
- args.emplace_back("performer", performer);
- }
- if (!title.empty()){
- args.emplace_back("title", title);
- }
- if (replyToMessageId) {
- args.emplace_back("reply_to_message_id", replyToMessageId);
- }
- 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("sendAudio", args));
-}
-
-Message::Ptr Api::sendAudio(int64_t chatId, const string& audioId, const string &caption, int32_t duration, const string& performer, const string& title, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
- vector<HttpReqArg> args;
- args.reserve(10);
- args.emplace_back("chat_id", chatId);
- args.emplace_back("audio", audioId);
if (!caption.empty()) {
args.emplace_back("caption", caption);
}
@@ -170,6 +125,15 @@ Message::Ptr Api::sendAudio(int64_t chatId, const string& audioId, const string
if (!title.empty()){
args.emplace_back("title", title);
}
+ 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);
+ if (!thumbStr.empty()) {
+ args.emplace_back("thumb", thumbStr);
+ }
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -185,34 +149,25 @@ Message::Ptr Api::sendAudio(int64_t chatId, const string& audioId, const string
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendAudio", args));
}
-Message::Ptr Api::sendDocument(int64_t chatId, const InputFile::Ptr document, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
+Message::Ptr Api::sendDocument(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> document, const boost::variant<InputFile::Ptr, std::string> thumb, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
vector<HttpReqArg> args;
- args.reserve(7);
+ args.reserve(8);
args.emplace_back("chat_id", chatId);
- args.emplace_back("document", document->data, true, document->mimeType, document->fileName);
- if (!caption.empty()) {
- args.emplace_back("caption", caption);
- }
- if (replyToMessageId) {
- args.emplace_back("reply_to_message_id", replyToMessageId);
- }
- 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);
+ 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));
+ }
+ 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);
+ if (!thumbStr.empty()) {
+ args.emplace_back("thumb", thumbStr);
+ }
}
- return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendDocument", args));
-}
-
-Message::Ptr Api::sendDocument(int64_t chatId, const string& document, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
- vector<HttpReqArg> args;
- args.reserve(7);
- args.emplace_back("chat_id", chatId);
- args.emplace_back("document", document);
if (!caption.empty()) {
args.emplace_back("caption", caption);
}
@@ -321,28 +276,16 @@ bool Api::answerPreCheckoutQuery(const std::string& preCheckoutQueryId, bool ok,
return sendRequest("answerPreCheckoutQuery", args).get<bool>("", false);
}
-Message::Ptr Api::sendSticker(int64_t chatId, const InputFile::Ptr sticker, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendSticker(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> sticker, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
vector<HttpReqArg> args;
args.reserve(5);
args.emplace_back("chat_id", chatId);
- args.emplace_back("sticker", sticker->data, true, sticker->mimeType, sticker->fileName);
- if (replyToMessageId) {
- args.emplace_back("reply_to_message_id", replyToMessageId);
+ 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));
}
- if (replyMarkup) {
- args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
- }
- if (disableNotification){
- args.emplace_back("disable_notification", disableNotification);
- }
- return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendSticker", args));
-}
-
-Message::Ptr Api::sendSticker(int64_t chatId, const string& stickerId, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
- vector<HttpReqArg> args;
- args.reserve(5);
- args.emplace_back("chat_id", chatId);
- args.emplace_back("sticker", stickerId);
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -370,30 +313,18 @@ File::Ptr Api::uploadStickerFile(int32_t userId, const InputFile::Ptr pngSticker
return _tgTypeParser.parseJsonAndGetFile(sendRequest("uploadStickerFile", args));
}
-bool Api::createNewStickerSet(int32_t userId, const string& name, const string& title, InputFile::Ptr pngSticker, const string& emojis, bool containsMasks, MaskPosition::Ptr maskPosition) const {
+bool Api::createNewStickerSet(int32_t userId, const string& name, const string& title, const boost::variant<InputFile::Ptr, std::string> pngSticker, const string& emojis, bool containsMasks, MaskPosition::Ptr maskPosition) const {
vector<HttpReqArg> args;
args.reserve(7);
args.emplace_back("user_id", userId);
args.emplace_back("name", name);
args.emplace_back("title", title);
- args.emplace_back("png_sticker", pngSticker->data, true, pngSticker->mimeType, pngSticker->fileName);
- args.emplace_back("emojis", emojis);
- if (containsMasks) {
- args.emplace_back("contains_mask", containsMasks);
+ if (pngSticker.which() == 0 /* InputFile::Ptr */) {
+ auto file = boost::get<InputFile::Ptr>(pngSticker);
+ args.emplace_back("png_sticker", file->data, true, file->mimeType, file->fileName);
+ } else /* std::string */ {
+ args.emplace_back("png_sticker", boost::get<std::string>(pngSticker));
}
- if (maskPosition != nullptr) {
- args.emplace_back("mask_position", _tgTypeParser.parseMaskPosition(maskPosition));
- }
- return sendRequest("createNewStickerSet", args).get<bool>("", false);
-}
-
-bool Api::createNewStickerSet(int32_t userId, const string& name, const string& title, const string& pngSticker, const string& emojis, bool containsMasks, MaskPosition::Ptr maskPosition) const {
- vector<HttpReqArg> args;
- args.reserve(7);
- args.emplace_back("user_id", userId);
- args.emplace_back("name", name);
- args.emplace_back("title", title);
- args.emplace_back("png_sticker", pngSticker);
args.emplace_back("emojis", emojis);
if (containsMasks) {
args.emplace_back("contains_mask", containsMasks);
@@ -404,27 +335,18 @@ bool Api::createNewStickerSet(int32_t userId, const string& name, const string&
return sendRequest("createNewStickerSet", args).get<bool>("", false);
}
-bool Api::addStickerToSet(int32_t userId, const string& name, const string& title, InputFile::Ptr pngSticker, const string& emojis, MaskPosition::Ptr maskPosition) const {
+bool Api::addStickerToSet(int32_t userId, const string& name, const string& title, const boost::variant<InputFile::Ptr, std::string> pngSticker, const string& emojis, MaskPosition::Ptr maskPosition) const {
vector<HttpReqArg> args;
args.reserve(6);
args.emplace_back("user_id", userId);
args.emplace_back("name", name);
args.emplace_back("title", title);
- args.emplace_back("png_sticker", pngSticker->data, true, pngSticker->mimeType, pngSticker->fileName);
- args.emplace_back("emojis", emojis);
- if (maskPosition != nullptr) {
- args.emplace_back("mask_position", _tgTypeParser.parseMaskPosition(maskPosition));
+ if (pngSticker.which() == 0 /* InputFile::Ptr */) {
+ auto file = boost::get<InputFile::Ptr>(pngSticker);
+ args.emplace_back("png_sticker", file->data, true, file->mimeType, file->fileName);
+ } else /* std::string */ {
+ args.emplace_back("png_sticker", boost::get<std::string>(pngSticker));
}
- return sendRequest("addStickerToSet", args).get<bool>("", false);
-}
-
-bool Api::addStickerToSet(int32_t userId, const string& name, const string& title, const string& pngSticker, const string& emojis, MaskPosition::Ptr maskPosition) const {
- vector<HttpReqArg> args;
- args.reserve(6);
- args.emplace_back("user_id", userId);
- args.emplace_back("name", name);
- args.emplace_back("title", title);
- args.emplace_back("png_sticker", pngSticker);
args.emplace_back("emojis", emojis);
if (maskPosition != nullptr) {
args.emplace_back("mask_position", _tgTypeParser.parseMaskPosition(maskPosition));
@@ -447,11 +369,16 @@ bool Api::deleteStickerPositionInSet(const string& sticker) const {
return sendRequest("setStickerPositionInSet", args).get<bool>("", false);
}
-Message::Ptr Api::sendVideo(int64_t chatId, const InputFile::Ptr video, bool supportsStreaming, int32_t duration, int32_t width, int32_t height, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
+Message::Ptr Api::sendVideo(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> video, bool supportsStreaming, int32_t duration, int32_t width, int32_t height, const boost::variant<InputFile::Ptr, std::string> thumb, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
vector<HttpReqArg> args;
- args.reserve(11);
+ args.reserve(12);
args.emplace_back("chat_id", chatId);
- args.emplace_back("video", video->data, true, video->mimeType, video->fileName);
+ 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));
+ }
if (supportsStreaming) {
args.emplace_back("supports_streaming", supportsStreaming);
}
@@ -464,6 +391,15 @@ Message::Ptr Api::sendVideo(int64_t chatId, const InputFile::Ptr video, bool sup
if (height) {
args.emplace_back("height", height);
}
+ 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);
+ if (!thumbStr.empty()) {
+ args.emplace_back("thumb", thumbStr);
+ }
+ }
if (!caption.empty()) {
args.emplace_back("caption", caption);
}
@@ -482,13 +418,15 @@ Message::Ptr Api::sendVideo(int64_t chatId, const InputFile::Ptr video, bool sup
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVideo", args));
}
-Message::Ptr Api::sendVideo(int64_t chatId, const string& videoId, bool supportsStreaming, int32_t duration, int32_t width, int32_t height, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
+Message::Ptr Api::sendAnimation(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> animation, int32_t duration, int32_t width, int32_t height, const boost::variant<InputFile::Ptr, std::string> thumb, const string& caption, int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
vector<HttpReqArg> args;
args.reserve(11);
args.emplace_back("chat_id", chatId);
- args.emplace_back("video", videoId);
- if (supportsStreaming) {
- args.emplace_back("supports_streaming", supportsStreaming);
+ 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));
}
if (duration) {
args.emplace_back("duration", duration);
@@ -499,6 +437,15 @@ Message::Ptr Api::sendVideo(int64_t chatId, const string& videoId, bool supports
if (height) {
args.emplace_back("height", height);
}
+ 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);
+ if (!thumbStr.empty()) {
+ args.emplace_back("thumb", thumbStr);
+ }
+ }
if (!caption.empty()) {
args.emplace_back("caption", caption);
}
@@ -514,37 +461,19 @@ Message::Ptr Api::sendVideo(int64_t chatId, const string& videoId, bool supports
if (disableNotification){
args.emplace_back("disable_notification", disableNotification);
}
- return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVideo", args));
+ return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendAnimation", args));
}
-Message::Ptr Api::sendVideoNote(int64_t chatId, const InputFile::Ptr videoNote, int64_t replyToMessageId, bool disableNotification, int32_t duration, int32_t length, const GenericReply::Ptr replyMarkup) {
+Message::Ptr Api::sendVideoNote(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> videoNote, int64_t replyToMessageId, bool disableNotification, int32_t duration, int32_t length, const boost::variant<InputFile::Ptr, std::string> thumb, const GenericReply::Ptr replyMarkup) const {
vector<HttpReqArg> args;
- args.reserve(7);
+ args.reserve(8);
args.emplace_back("chat_id", chatId);
- args.emplace_back("video_note", videoNote);
- if (disableNotification) {
- args.emplace_back("disable_notification", disableNotification);
- }
- if (duration) {
- args.emplace_back("duration", duration);
- }
- if (length) {
- args.emplace_back("length", length);
- }
- if (replyMarkup) {
- args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
+ 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));
}
- if (replyToMessageId) {
- args.emplace_back("reply_to_message_id", replyToMessageId);
- }
- return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVoiceNote", args));
-}
-
-Message::Ptr Api::sendVideoNote(int64_t chatId, const string &videoNote, int64_t replyToMessageId, bool disableNotification, int32_t duration, int32_t length, const GenericReply::Ptr replyMarkup) {
- vector<HttpReqArg> args;
- args.reserve(7);
- args.emplace_back("chat_id", chatId);
- args.emplace_back("video_note", videoNote);
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
@@ -554,13 +483,22 @@ Message::Ptr Api::sendVideoNote(int64_t chatId, const string &videoNote, int64_t
if (length) {
args.emplace_back("length", length);
}
+ 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);
+ if (!thumbStr.empty()) {
+ args.emplace_back("thumb", thumbStr);
+ }
+ }
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
}
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
- return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVoiceNote", args));
+ return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVideoNote", args));
}
vector<Message::Ptr> Api::sendMediaGroup(int64_t chatId, const vector<InputMedia::Ptr>& media, bool disableNotification, int32_t replyToMessageId) const {
@@ -574,37 +512,16 @@ vector<Message::Ptr> Api::sendMediaGroup(int64_t chatId, const vector<InputMedia
return _tgTypeParser.parseJsonAndGetArray<Message>(&TgTypeParser::parseJsonAndGetMessage, sendRequest("sendMediaGroup", args));
}
-Message::Ptr Api::sendVoice(int64_t chatId, const InputFile::Ptr voice, const string &caption, int duration, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
+Message::Ptr Api::sendVoice(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> voice, const string &caption, int duration, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
vector<HttpReqArg> args;
args.reserve(8);
args.emplace_back("chat_id", chatId);
- args.emplace_back("voice", voice->data, true, voice->mimeType, voice->fileName);
- if (!caption.empty()) {
- args.emplace_back("caption", caption);
+ 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));
}
- if (duration){
- args.emplace_back("duration", duration);
- }
- if (replyToMessageId) {
- args.emplace_back("reply_to_message_id", replyToMessageId);
- }
- 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::sendVoice(int64_t chatId, const string& voiceId, const string &caption, int duration, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
- vector<HttpReqArg> args;
- args.reserve(8);
- args.emplace_back("chat_id", chatId);
- args.emplace_back("voice", voiceId);
if (!caption.empty()) {
args.emplace_back("caption", caption);
}
@@ -717,9 +634,9 @@ bool Api::deleteChatStickerSet(int64_t chatId) const {
return sendRequest("deleteChatStickerSet", args).get<bool>("", false);
}
-Message::Ptr Api::sendVenue(int64_t chatId, float latitude, float longitude, const string& title, const string& address, const string& foursquareId, bool disableNotification, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const {
+Message::Ptr Api::sendVenue(int64_t chatId, float latitude, float longitude, const string& title, const string& address, const string& foursquareId, const string& foursquareType, bool disableNotification, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const {
vector<HttpReqArg> args;
- args.reserve(9);
+ args.reserve(10);
args.emplace_back("chat_id", chatId);
args.emplace_back("latitude", latitude);
args.emplace_back("longitude", longitude);
@@ -728,6 +645,9 @@ Message::Ptr Api::sendVenue(int64_t chatId, float latitude, float longitude, con
if (!foursquareId.empty()) {
args.emplace_back("foursquare_id", foursquareId);
}
+ if (!foursquareType.empty()) {
+ args.emplace_back("foursquare_type", foursquareType);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -740,13 +660,18 @@ Message::Ptr Api::sendVenue(int64_t chatId, float latitude, float longitude, con
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVenue", args));
}
-Message::Ptr Api::sendContact(int64_t chatId, const string& phoneNumber, const string& firstName, const string& lastName, bool disableNotification, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const {
+Message::Ptr Api::sendContact(int64_t chatId, const string& phoneNumber, const string& firstName, const string& lastName, const string& vcard, bool disableNotification, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const {
vector<HttpReqArg> args;
- args.reserve(7);
+ args.reserve(8);
args.emplace_back("chat_id", chatId);
args.emplace_back("phone_number", phoneNumber);
args.emplace_back("first_name", firstName);
- args.emplace_back("last_name", lastName);
+ if (!lastName.empty()) {
+ args.emplace_back("last_name", lastName);
+ }
+ if (!vcard.empty()) {
+ args.emplace_back("vcard", vcard);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -918,6 +843,32 @@ Message::Ptr Api::editMessageReplyMarkup(int64_t chatId, int32_t messageId, cons
}
}
+Message::Ptr Api::editMessageMedia(InputMedia::Ptr media, int64_t chatId, int32_t messageId, const std::string& inlineMessageId,
+ GenericReply::Ptr replyMarkup) const {
+
+ vector<HttpReqArg> args;
+ args.reserve(5);
+ args.emplace_back("media", _tgTypeParser.parseInputMedia(media));
+ 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 (replyMarkup) {
+ args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
+ }
+ ptree p = sendRequest("editMessageMedia", args);
+ if (p.get_child_optional("message_id")) {
+ return _tgTypeParser.parseJsonAndGetMessage(p);
+ } else {
+ return nullptr;
+ }
+}
+
ChatMember::Ptr Api::getChatMember(int64_t chatId, int32_t userId) const {
vector<HttpReqArg> args;
args.reserve(2);
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp
index dbfb266..ad200b3 100644
--- a/src/TgTypeParser.cpp
+++ b/src/TgTypeParser.cpp
@@ -153,6 +153,7 @@ Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const {
result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
result->audio = tryParseJson<Audio>(&TgTypeParser::parseJsonAndGetAudio, data, "audio");
result->document = tryParseJson<Document>(&TgTypeParser::parseJsonAndGetDocument, data, "document");
+ result->animation = tryParseJson<Animation>(&TgTypeParser::parseJsonAndGetAnimation, data, "animation");
result->game = tryParseJson<Game>(&TgTypeParser::parseJsonAndGetGame, data, "game");
result->photo = parseJsonAndGetArray<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "photo");
result->sticker = tryParseJson<Sticker>(&TgTypeParser::parseJsonAndGetSticker, data, "sticker");
@@ -199,6 +200,7 @@ string TgTypeParser::parseMessage(const Message::Ptr& object) const {
appendToJson(result, "text", object->text);
appendToJson(result, "audio", parseAudio(object->audio));
appendToJson(result, "document", parseDocument(object->document));
+ appendToJson(result, "animation", parseAnimation(object->animation));
appendToJson(result, "photo", parseArray(&TgTypeParser::parsePhotoSize, object->photo));
appendToJson(result, "sticker", parseSticker(object->sticker));
appendToJson(result, "video", parseVideo(object->video));
@@ -257,6 +259,7 @@ Audio::Ptr TgTypeParser::parseJsonAndGetAudio(const ptree& data) const {
result->title = data.get<string>("title", "");
result->mimeType = data.get("mime_type", "");
result->fileSize = data.get("file_size", 0);
+ result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
return result;
}
@@ -270,6 +273,7 @@ string TgTypeParser::parseAudio(const Audio::Ptr& object) const {
appendToJson(result, "duration", object->duration);
appendToJson(result, "mime_type", object->mimeType);
appendToJson(result, "file_size", object->fileSize);
+ appendToJson(result, "thumb", parsePhotoSize(object->thumb));
removeLastComma(result);
result += '}';
return result;
@@ -517,6 +521,7 @@ Contact::Ptr TgTypeParser::parseJsonAndGetContact(const ptree& data) const {
result->firstName = data.get<string>("first_name");
result->lastName = data.get("last_name", "");
result->userId = data.get("user_id", "");
+ result->vcard = data.get("vcard", "");
return result;
}
@@ -530,6 +535,7 @@ string TgTypeParser::parseContact(const Contact::Ptr& object) const {
appendToJson(result, "first_name", object->firstName);
appendToJson(result, "last_name", object->lastName);
appendToJson(result, "user_id", object->userId);
+ appendToJson(result, "vcard", object->vcard);
removeLastComma(result);
result += '}';
return result;
@@ -618,6 +624,7 @@ InputMedia::Ptr TgTypeParser::parseJsonAndGetInputMedia(const ptree& data) const
result->media = data.get("media", "");
result->caption = data.get("caption", "");
result->parseMode = data.get("parse_mode", "");
+ result->thumb = data.get("thumb", "");
return result;
}
else if (type == "video") {
@@ -625,12 +632,40 @@ InputMedia::Ptr TgTypeParser::parseJsonAndGetInputMedia(const ptree& data) const
result->media = data.get("media", "");
result->caption = data.get("caption", "");
result->parseMode = data.get("parse_mode", "");
+ result->thumb = data.get("thumb", "");
result->width = data.get<int32_t>("width", 0);
result->height = data.get<int32_t>("height", 0);
result->duration = data.get<int32_t>("duration", 0);
result->supportsStreaming = data.get<bool>("supports_streaming", false);
return result;
}
+ else if (type == "animation") {
+ auto result(make_shared<InputMediaAnimation>());
+ result->media = data.get("media", "");
+ result->caption = data.get("caption", "");
+ result->parseMode = data.get("parse_mode", "");
+ result->thumb = data.get("thumb", "");
+ result->width = data.get<int32_t>("width", 0);
+ result->height = data.get<int32_t>("height", 0);
+ result->duration = data.get<int32_t>("duration", 0);
+ return result;
+ } else if (type == "document") {
+ auto result(make_shared<InputMediaDocument>());
+ result->media = data.get("media", "");
+ result->caption = data.get("caption", "");
+ result->parseMode = data.get("parse_mode", "");
+ result->thumb = data.get("thumb", "");
+ return result;
+ } else if (type == "audio") {
+ auto result(make_shared<InputMediaAudio>());
+ result->media = data.get("media", "");
+ result->caption = data.get("caption", "");
+ result->parseMode = data.get("parse_mode", "");
+ result->thumb = data.get("thumb", "");
+ result->duration = data.get<int32_t>("duration", 0);
+ result->title = data.get<int32_t>("title", 0);
+ result->performer = data.get<int32_t>("performer", 0);
+ }
else {
return nullptr;
}
@@ -642,12 +677,23 @@ string TgTypeParser::parseInputMedia(const InputMedia::Ptr& object) const {
}
string result;
result += '{';
- if (object->type == InputMedia::TYPE::PHOTO) {
- appendToJson(result, "type", "photo");
- }
- else {
- appendToJson(result, "type", "video");
- }
+ switch(object->type) {
+ case InputMedia::TYPE::PHOTO:
+ appendToJson(result, "type", "photo");
+ break;
+ case InputMedia::TYPE::VIDEO:
+ appendToJson(result, "type", "video");
+ break;
+ case InputMedia::TYPE::ANIMATION:
+ appendToJson(result, "type", "animation");
+ break;
+ case InputMedia::TYPE::DOCUMENT:
+ appendToJson(result, "type", "document");
+ break;
+ case InputMedia::TYPE::AUDIO:
+ appendToJson(result, "type", "audio");
+ break;
+ }
appendToJson(result, "media", object->media);
appendToJson(result, "caption", object->caption);
appendToJson(result, "parse_mode", object->parseMode);
@@ -660,6 +706,9 @@ string TgTypeParser::parseInputMedia(const InputMedia::Ptr& object) const {
if (object->duration) {
appendToJson(result, "duration", object->duration);
}
+ if (object->performer) {
+ appendToJson(result, "performer", object->performer);
+ }
if (object->supportsStreaming) {
appendToJson(result, "supports_streaming", object->supportsStreaming);
}
@@ -1064,7 +1113,7 @@ InlineQueryResultCachedAudio::Ptr TgTypeParser::parseJsonAndGetInlineQueryResult
std::string TgTypeParser::parseInlineQueryResultCachedAudio(const InlineQueryResultCachedAudio::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1084,7 +1133,7 @@ InlineQueryResultCachedDocument::Ptr TgTypeParser::parseJsonAndGetInlineQueryRes
std::string TgTypeParser::parseInlineQueryResultCachedDocument(const InlineQueryResultCachedDocument::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1105,7 +1154,7 @@ InlineQueryResultCachedGif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCa
std::string TgTypeParser::parseInlineQueryResultCachedGif(const InlineQueryResultCachedGif::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1125,7 +1174,7 @@ InlineQueryResultCachedMpeg4Gif::Ptr TgTypeParser::parseJsonAndGetInlineQueryRes
std::string TgTypeParser::parseInlineQueryResultCachedMpeg4Gif(const InlineQueryResultCachedMpeg4Gif::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1146,7 +1195,7 @@ InlineQueryResultCachedPhoto::Ptr TgTypeParser::parseJsonAndGetInlineQueryResult
std::string TgTypeParser::parseInlineQueryResultCachedPhoto(const InlineQueryResultCachedPhoto::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1167,7 +1216,7 @@ InlineQueryResultCachedSticker::Ptr TgTypeParser::parseJsonAndGetInlineQueryResu
std::string TgTypeParser::parseInlineQueryResultCachedSticker(const InlineQueryResultCachedSticker::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1187,7 +1236,7 @@ InlineQueryResultCachedVideo::Ptr TgTypeParser::parseJsonAndGetInlineQueryResult
std::string TgTypeParser::parseInlineQueryResultCachedVideo(const InlineQueryResultCachedVideo::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1208,7 +1257,7 @@ InlineQueryResultCachedVoice::Ptr TgTypeParser::parseJsonAndGetInlineQueryResult
std::string TgTypeParser::parseInlineQueryResultCachedVoice(const InlineQueryResultCachedVoice::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1232,7 +1281,7 @@ InlineQueryResultArticle::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultArti
std::string TgTypeParser::parseInlineQueryResultArticle(const InlineQueryResultArticle::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1258,7 +1307,7 @@ InlineQueryResultAudio::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultAudio(
std::string TgTypeParser::parseInlineQueryResultAudio(const InlineQueryResultAudio::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1277,6 +1326,7 @@ InlineQueryResultContact::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCont
result->phoneNumber = data.get<string>("phone_number");
result->firstName = data.get<string>("first_name");
result->lastName = data.get<string>("last_name", "");
+ result->vcard = data.get<string>("vcard", "");
result->thumbUrl = data.get<string>("thumb_url", "");
result->thumbWidth = data.get<int32_t>("thumb_width", 0);
result->thumbHeight = data.get<int32_t>("thumb_height", 0);
@@ -1285,7 +1335,7 @@ InlineQueryResultContact::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCont
std::string TgTypeParser::parseInlineQueryResultContact(const InlineQueryResultContact::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1293,6 +1343,7 @@ std::string TgTypeParser::parseInlineQueryResultContact(const InlineQueryResultC
appendToJson(result, "phone_number", object->phoneNumber);
appendToJson(result, "first_name", object->firstName);
appendToJson(result, "last_name", object->lastName);
+ appendToJson(result, "vcard", object->vcard);
appendToJson(result, "thumb_url", object->thumbUrl);
appendToJson(result, "thumb_width", object->thumbWidth);
appendToJson(result, "thumb_height", object->thumbHeight);
@@ -1310,7 +1361,7 @@ InlineQueryResultGame::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultGame(co
std::string TgTypeParser::parseInlineQueryResultGame(const InlineQueryResultGame::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1334,7 +1385,7 @@ InlineQueryResultDocument::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultDoc
std::string TgTypeParser::parseInlineQueryResultDocument(const InlineQueryResultDocument::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1362,7 +1413,7 @@ InlineQueryResultLocation::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultLoc
std::string TgTypeParser::parseInlineQueryResultLocation(const InlineQueryResultLocation::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1384,6 +1435,7 @@ InlineQueryResultVenue::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultVenue(
result->longitude = data.get<float>("longitude");
result->address = data.get<string>("address");
result->foursquareId = data.get<string>("foursquare_id", "");
+ result->foursquareType = data.get<string>("foursquare_type", "");
result->thumbUrl = data.get<string>("thumb_url", "");
result->thumbWidth = data.get<int32_t>("thumb_width", 0);
result->thumbHeight = data.get<int32_t>("thumb_height", 0);
@@ -1392,7 +1444,7 @@ InlineQueryResultVenue::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultVenue(
std::string TgTypeParser::parseInlineQueryResultVenue(const InlineQueryResultVenue::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1401,6 +1453,7 @@ std::string TgTypeParser::parseInlineQueryResultVenue(const InlineQueryResultVen
appendToJson(result, "longitude", object->longitude);
appendToJson(result, "address", object->address);
appendToJson(result, "foursquare_id", object->foursquareId);
+ appendToJson(result, "foursquare_type", object->foursquareType);
appendToJson(result, "thumb_url", object->thumbUrl);
appendToJson(result, "thumb_width", object->thumbWidth);
appendToJson(result, "thumb_height", object->thumbHeight);
@@ -1418,7 +1471,7 @@ InlineQueryResultVoice::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultVoice(
std::string TgTypeParser::parseInlineQueryResultVoice(const InlineQueryResultVoice::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1442,7 +1495,7 @@ InlineQueryResultPhoto::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultPhoto(
std::string TgTypeParser::parseInlineQueryResultPhoto(const InlineQueryResultPhoto::Ptr& object) const{
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1468,7 +1521,7 @@ InlineQueryResultGif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultGif(cons
}
std::string TgTypeParser::parseInlineQueryResultGif(const InlineQueryResultGif::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1495,7 +1548,7 @@ InlineQueryResultMpeg4Gif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultMpe
std::string TgTypeParser::parseInlineQueryResultMpeg4Gif(const InlineQueryResultMpeg4Gif::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1524,7 +1577,7 @@ InlineQueryResultVideo::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultVideo(
std::string TgTypeParser::parseInlineQueryResultVideo(const InlineQueryResultVideo::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
// curly brackets to the result string.
@@ -1751,7 +1804,7 @@ InputTextMessageContent::Ptr TgTypeParser::parseJsonAndGetInputTextMessageConten
std::string TgTypeParser::parseInputTextMessageContent(const InputTextMessageContent::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInputMessageContent()
string result;
@@ -1772,7 +1825,7 @@ InputLocationMessageContent::Ptr TgTypeParser::parseJsonAndGetInputLocationMessa
std::string TgTypeParser::parseInputLocationMessageContent(const InputLocationMessageContent::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInputMessageContent()
string result;
@@ -1790,12 +1843,13 @@ InputVenueMessageContent::Ptr TgTypeParser::parseJsonAndGetInputVenueMessageCont
result->title = data.get<string>("title");
result->address = data.get<string>("address");
result->foursquareId = data.get<string>("foursquare_id", "");
+ result->foursquareType = data.get<string>("foursquare_type", "");
return result;
}
std::string TgTypeParser::parseInputVenueMessageContent(const InputVenueMessageContent::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInputMessageContent()
string result;
@@ -1814,18 +1868,20 @@ InputContactMessageContent::Ptr TgTypeParser::parseJsonAndGetInputContactMessage
result->phoneNumber = data.get<string>("phone_number");
result->firstName = data.get<string>("first_name");
result->lastName = data.get<string>("last_name", "");
+ result->vcard = data.get<string>("vcard", "");
return result;
}
std::string TgTypeParser::parseInputContactMessageContent(const InputContactMessageContent::Ptr& object) const {
if (!object){
- return " ";
+ return "";
}
// This function will be called by parseInputMessageContent()
string result;
appendToJson(result, "phone_number", object->phoneNumber);
appendToJson(result, "first_name", object->firstName);
appendToJson(result, "last_name", object->lastName);
+ appendToJson(result, "vcard", object->vcard);
// The last comma will be erased by parseInputMessageContent().
return result;
}
@@ -1842,7 +1898,7 @@ Invoice::Ptr TgTypeParser::parseJsonAndGetInvoice(const boost::property_tree::pt
std::string TgTypeParser::parseInvoice(const Invoice::Ptr& object) const {
if (!object) {
- return " ";
+ return "";
}
string result;
result += '{';
@@ -1884,7 +1940,7 @@ OrderInfo::Ptr TgTypeParser::parseJsonAndGetOrderInfo(const boost::property_tree
string TgTypeParser::parseOrderInfo(const OrderInfo::Ptr& object) const {
if (!object) {
- return " ";
+ return "";
}
std::string result;
result += '{';
diff --git a/src/net/HttpParser.cpp b/src/net/HttpParser.cpp
index 41dec14..c4f8215 100644
--- a/src/net/HttpParser.cpp
+++ b/src/net/HttpParser.cpp
@@ -100,7 +100,7 @@ string HttpParser::generateMultipartFormData(const vector<HttpReqArg>& args, con
string HttpParser::generateMultipartBoundary(const vector<HttpReqArg>& args) const {
string result;
- srand((unsigned int) time(nullptr));
+ srand((uint32_t) time(nullptr));
for (const HttpReqArg& item : args) {
if (item.isFile) {
while (result.empty() || item.value.find(result) != string::npos) {