summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Morozenkov <m@oleg.rocks>2022-09-05 10:52:00 +0300
committerGitHub <noreply@github.com>2022-09-05 10:52:00 +0300
commit2e1c2337c07be587dc260c7bb3150d63bd0a71a4 (patch)
treef64bf217f53f3b5ff2ba48711ff05cf50ca1aa3a
parentce50cefc0a7b9aea99344a4b0a418544e2deca4a (diff)
parent5c9062ab3c3bff1fa1fb5b5288dda0cf5d0acf54 (diff)
Merge pull request #224 from llnulldisk/master
Update to API 5.5
-rw-r--r--CMakeLists.txt4
-rw-r--r--README.md1
-rw-r--r--include/tgbot/Api.h1134
-rw-r--r--include/tgbot/TgTypeParser.h118
-rw-r--r--include/tgbot/types/Audio.h5
-rw-r--r--include/tgbot/types/BotCommandScope.h31
-rw-r--r--include/tgbot/types/BotCommandScopeAllChatAdministrators.h27
-rw-r--r--include/tgbot/types/BotCommandScopeAllGroupChats.h27
-rw-r--r--include/tgbot/types/BotCommandScopeAllPrivateChats.h27
-rw-r--r--include/tgbot/types/BotCommandScopeChat.h33
-rw-r--r--include/tgbot/types/BotCommandScopeChatAdministrators.h33
-rw-r--r--include/tgbot/types/BotCommandScopeChatMember.h38
-rw-r--r--include/tgbot/types/BotCommandScopeDefault.h28
-rw-r--r--include/tgbot/types/Chat.h60
-rw-r--r--include/tgbot/types/ChatInviteLink.h70
-rw-r--r--include/tgbot/types/ChatJoinRequest.h51
-rw-r--r--include/tgbot/types/ChatLocation.h33
-rw-r--r--include/tgbot/types/ChatMember.h99
-rw-r--r--include/tgbot/types/ChatMemberAdministrator.h94
-rw-r--r--include/tgbot/types/ChatMemberBanned.h33
-rw-r--r--include/tgbot/types/ChatMemberLeft.h27
-rw-r--r--include/tgbot/types/ChatMemberMember.h27
-rw-r--r--include/tgbot/types/ChatMemberOwner.h38
-rw-r--r--include/tgbot/types/ChatMemberRestricted.h79
-rw-r--r--include/tgbot/types/ChatMemberUpdated.h55
-rw-r--r--include/tgbot/types/ChatPhoto.h4
-rw-r--r--include/tgbot/types/Dice.h4
-rw-r--r--include/tgbot/types/ForceReply.h30
-rw-r--r--include/tgbot/types/InlineQuery.h25
-rw-r--r--include/tgbot/types/InlineQueryResult.h27
-rw-r--r--include/tgbot/types/InlineQueryResultArticle.h22
-rw-r--r--include/tgbot/types/InlineQueryResultAudio.h33
-rw-r--r--include/tgbot/types/InlineQueryResultCachedAudio.h27
-rw-r--r--include/tgbot/types/InlineQueryResultCachedDocument.h31
-rw-r--r--include/tgbot/types/InlineQueryResultCachedGif.h30
-rw-r--r--include/tgbot/types/InlineQueryResultCachedMpeg4Gif.h30
-rw-r--r--include/tgbot/types/InlineQueryResultCachedPhoto.h31
-rw-r--r--include/tgbot/types/InlineQueryResultCachedSticker.h8
-rw-r--r--include/tgbot/types/InlineQueryResultCachedVideo.h33
-rw-r--r--include/tgbot/types/InlineQueryResultCachedVoice.h33
-rw-r--r--include/tgbot/types/InlineQueryResultContact.h14
-rw-r--r--include/tgbot/types/InlineQueryResultDocument.h40
-rw-r--r--include/tgbot/types/InlineQueryResultGif.h36
-rw-r--r--include/tgbot/types/InlineQueryResultLocation.h39
-rw-r--r--include/tgbot/types/InlineQueryResultMpeg4Gif.h35
-rw-r--r--include/tgbot/types/InlineQueryResultPhoto.h41
-rw-r--r--include/tgbot/types/InlineQueryResultVenue.h31
-rw-r--r--include/tgbot/types/InlineQueryResultVideo.h52
-rw-r--r--include/tgbot/types/InlineQueryResultVoice.h36
-rw-r--r--include/tgbot/types/InputContactMessageContent.h12
-rw-r--r--include/tgbot/types/InputInvoiceMessageContent.h140
-rw-r--r--include/tgbot/types/InputLocationMessageContent.h32
-rw-r--r--include/tgbot/types/InputMedia.h67
-rw-r--r--include/tgbot/types/InputMediaAnimation.h33
-rw-r--r--include/tgbot/types/InputMediaAudio.h33
-rw-r--r--include/tgbot/types/InputMediaDocument.h24
-rw-r--r--include/tgbot/types/InputMediaPhoto.h5
-rw-r--r--include/tgbot/types/InputMediaVideo.h36
-rw-r--r--include/tgbot/types/InputMessageContent.h19
-rw-r--r--include/tgbot/types/InputTextMessageContent.h22
-rw-r--r--include/tgbot/types/InputVenueMessageContent.h22
-rw-r--r--include/tgbot/types/Location.h27
-rw-r--r--include/tgbot/types/Message.h136
-rw-r--r--include/tgbot/types/MessageAutoDeleteTimerChanged.h26
-rw-r--r--include/tgbot/types/MessageId.h25
-rw-r--r--include/tgbot/types/PhotoSize.h2
-rw-r--r--include/tgbot/types/ProximityAlertTriggered.h37
-rw-r--r--include/tgbot/types/ReplyKeyboardMarkup.h33
-rw-r--r--include/tgbot/types/Update.h22
-rw-r--r--include/tgbot/types/Venue.h13
-rw-r--r--include/tgbot/types/Video.h5
-rw-r--r--include/tgbot/types/VoiceChatEnded.h26
-rw-r--r--include/tgbot/types/VoiceChatParticipantsInvited.h28
-rw-r--r--include/tgbot/types/VoiceChatScheduled.h26
-rw-r--r--include/tgbot/types/VoiceChatStarted.h21
-rw-r--r--include/tgbot/types/WebhookInfo.h9
-rw-r--r--src/Api.cpp938
-rw-r--r--src/TgTypeParser.cpp2561
-rw-r--r--src/types/BotCommandScope.cpp19
-rw-r--r--src/types/ChatMember.cpp17
-rw-r--r--src/types/InputMedia.cpp15
-rw-r--r--src/types/InputMessageContent.cpp15
82 files changed, 5649 insertions, 1661 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4675203..f11f6d8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,8 +30,12 @@ set(SRC_LIST
src/net/Url.cpp
src/tools/FileTools.cpp
src/tools/StringTools.cpp
+ src/types/BotCommandScope.cpp
+ src/types/ChatMember.cpp
src/types/InlineQueryResult.cpp
src/types/InputFile.cpp
+ src/types/InputMedia.cpp
+ src/types/InputMessageContent.cpp
src/types/PassportElementError.cpp)
# libs
diff --git a/README.md b/README.md
index a7d6734..74a0130 100644
--- a/README.md
+++ b/README.md
@@ -13,6 +13,7 @@ Documentation is located [here](http://reo7sp.github.io/tgbot-cpp).
- [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
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index bb9aa26..87c6c11 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -6,6 +6,7 @@
#include "tgbot/net/HttpReqArg.h"
#include "tgbot/types/User.h"
#include "tgbot/types/Message.h"
+#include "tgbot/types/MessageId.h"
#include "tgbot/types/GenericReply.h"
#include "tgbot/types/InputFile.h"
#include "tgbot/types/UserProfilePhotos.h"
@@ -54,34 +55,59 @@ public:
* This method will not work if an outgoing webhook is set up.
* In order to avoid getting duplicate updates, recalculate offset after each server response.
*
- * @param offset Optional. Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id.
- * @param limit Optional. Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100.
- * @param timeout Optional. Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling.
- * @param allowed_updates Optional. List the types of updates you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all updates regardless of type (default). If not specified, the previous setting will be used.
- * @return An Array of Update objects
+ * @param offset Optional. Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as Api::getUpdates is called with an offset higher than its updateId. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will forgotten.
+ * @param limit Optional. Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100.
+ * @param timeout Optional. Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only.
+ * @param allowedUpdates Optional. A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chatMember (default). If not specified, the previous setting will be used. Please note that this parameter doesn't affect updates created before the call to the Api::getUpdates, so unwanted updates may be received for a short period of time.
+ *
+ * @return An Array of Update objects is returned.
*/
- std::vector<Update::Ptr> getUpdates(std::int32_t offset = 0, std::int32_t limit = 100, std::int32_t timeout = 0, const StringArrayPtr& allowedUpdates = nullptr) const;
+ std::vector<Update::Ptr> getUpdates(std::int32_t offset = 0,
+ std::int32_t limit = 100,
+ std::int32_t timeout = 0,
+ const StringArrayPtr& allowedUpdates = nullptr) const;
/**
- * @brief Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts.
+ * @brief Use this method to specify a url and receive incoming updates via an outgoing webhook.
+ * Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized @ref Update.
+ * In case of an unsuccessful request, we will give up after a reasonable amount of attempts.
*
- * If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. www.example.com/<token>. Since nobody else knows your bot‘s token, you can be pretty sure it’s us.
- * You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up.
- * We currently do not support self-signed certificates.
+ * If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. https://www.example.com/<token>.
+ * Since nobody else knows your bot's token, you can be pretty sure it's us.
+ *
+ * You will not be able to receive updates using @ref Api::getUpdates for as long as an outgoing webhook is set up.
+ *
+ * To use a self-signed certificate, you need to upload your public key certificate using certificate parameter.
+ * Please upload as InputFile, sending a String will not work.
+ *
* Ports currently supported for Webhooks: 443, 80, 88, 8443.
+ *
+ * If you're having any trouble setting up webhooks, please check out https://core.telegram.org/bots/webhooks.
*
- * @param url Optional. HTTPS url to send updates to. Use an empty string to remove webhook integration.
+ * @param url HTTPS url to send updates to. Use an empty string to remove webhook integration
+ * @param certificate Optional. Upload your public key certificate so that the root certificate in use can be checked. See https://core.telegram.org/bots/self-signed for details.
+ * @param maxConnection Optional. Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput.
+ * @param allowedUpdates Optional. A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all updates regardless of type (default). If not specified, the previous setting will be used. Please note that this parameter doesn't affect updates created before the call to the setWebhook, so unwanted updates may be received for a short period of time.
+ * @param ipAddress Optional. The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS
+ * @param dropPendingUpdates Optional. Pass True to drop all pending updates
+ *
+ * @return True on success.
*/
- void setWebhook(const std::string& url = "", InputFile::Ptr certificate = nullptr, std::int32_t maxConnection = 40, const StringArrayPtr& allowedUpdates = nullptr) const;
+ bool setWebhook(const std::string& url,
+ InputFile::Ptr certificate = nullptr,
+ std::int32_t maxConnection = 40,
+ const StringArrayPtr& allowedUpdates = nullptr,
+ const std::string& ipAddress = "",
+ bool dropPendingUpdates = false) const;
/**
- * @brief Use this method to remove webhook integration if you decide to switch back to getUpdates.
+ * @brief Use this method to remove webhook integration if you decide to switch back to @ref Api::getUpdates.
*
- * Requires no parameters.
+ * @param dropPendingUpdates Optional. Pass True to drop all pending updates
*
- * @return Returns True on success.
+ * @return True on success.
*/
- bool deleteWebhook() const;
+ bool deleteWebhook(bool dropPendingUpdates = false) const;
/**
* @brief Use this method to get current webhook status.
@@ -103,18 +129,26 @@ public:
* @brief Use this method to send text messages.
*
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- * @param text Text of the message to be sent
+ * @param text Text of the message to be sent, 1-4096 characters after entities parsing
* @param disableWebPagePreview Optional. Disables link previews for links in this message
* @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. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
+ * @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 allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
*
- * @return On success, the sent @ref Message is returned.
+ * @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,
- std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "",
- bool disableNotification = false) const;
+ Message::Ptr sendMessage(boost::variant<std::int64_t, const std::string&> chatId,
+ const std::string& text,
+ bool disableWebPagePreview = false,
+ std::int32_t replyToMessageId = 0,
+ GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
+ const std::string& parseMode = "",
+ bool disableNotification = false,
+ const std::vector<MessageEntity::Ptr>& entities = std::vector<MessageEntity::Ptr>(),
+ bool allowSendingWithoutReply = false) const;
/**
* @brief Use this method to forward messages of any kind.
@@ -127,160 +161,316 @@ public:
Message::Ptr forwardMessage(std::int64_t chatId, std::int64_t fromChatId, std::int32_t messageId, bool disableNotification = 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.
+ *
+ * @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 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.
+ *
+ * @return 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;
+
+ /**
* @brief Use this method to send photos.
- * @param chatId Unique identifier for the target chat.
- * @param photo Photo to send.
- * @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.
+ *
+ * @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 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 allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ *
+ * @return On success, the sent Message is returned.
*/
- Message::Ptr sendPhoto(std::int64_t chatId, boost::variant<InputFile::Ptr, 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;
+ Message::Ptr sendPhoto(std::int64_t chatId,
+ boost::variant<InputFile::Ptr, 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;
/**
- * @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 Audio to send.
- * @param caption Audio caption, 0-200 characters
- * @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.
+ * @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.
+ *
+ * For sending voice messages, use the Api::sendVoice method instead.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param audio Audio file to send. Pass a fileId as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. https://core.telegram.org/bots/api#sending-files
+ * @param caption Optional. Audio caption, 0-1024 characters after entities parsing
+ * @param duration Optional. Duration of the audio in seconds
+ * @param performer Optional. Performer
+ * @param title Optional. Track name
+ * @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 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 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 allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ *
+ * @return On success, the sent Message is returned.
*/
- Message::Ptr sendAudio(std::int64_t chatId, boost::variant<InputFile::Ptr, 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 = "", std::int32_t replyToMessageId = 0,
- GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
+ Message::Ptr sendAudio(std::int64_t chatId,
+ boost::variant<InputFile::Ptr, 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 = "",
+ 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;
/**
* @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.
- * @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.
+ * 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)
+ * @param document File to send. Pass a fileId as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. 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. Document caption (may also be used when resending documents 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 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 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
+ *
+ * @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 = "", const std::string& caption = "", std::int32_t replyToMessageId = 0,
- GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
+ Message::Ptr sendDocument(std::int64_t chatId,
+ boost::variant<InputFile::Ptr, std::string> document,
+ boost::variant<InputFile::Ptr, 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 disableContentTypeDetection = false,
+ bool allowSendingWithoutReply = false) const;
/**
* @brief Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
- * @param chatId Unique identifier for the target chat.
- * @param video Video to send.
- * @param supportsStreaming Optional. Pass True, if the uploaded video is suitable for streaming.
+ * 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)
+ * @param video Video to send. Pass a fileId as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. https://core.telegram.org/bots/api#sending-files
+ * @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 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.
- * @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.
+ * @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 allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ *
+ * @return On success, the sent Message is returned.
*/
- Message::Ptr sendVideo(std::int64_t chatId, boost::variant<InputFile::Ptr, 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 = "", const std::string& caption = "",
- std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
+ Message::Ptr sendVideo(std::int64_t chatId,
+ boost::variant<InputFile::Ptr, 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 = "",
+ 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;
/**
* @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 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. 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.
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param animation Animation to send. Pass a fileId 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. https://core.telegram.org/bots/api#sending-files
+ * @param duration Optional. Duration of sent animation in seconds
+ * @param width Optional. Animation width
+ * @param height Optional. Animation 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 caption Optional. Animation caption (may also be used when resending animation 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 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 allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ *
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendAnimation(std::int64_t chatId, boost::variant<InputFile::Ptr, 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 = "", const std::string& caption = "",
- std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
+ Message::Ptr sendAnimation(std::int64_t chatId,
+ boost::variant<InputFile::Ptr, 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 = "",
+ 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;
/**
* @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 voice Audio file to send.
- * @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.
+ * 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.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param voice Audio file to send. Pass a fileId as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. https://core.telegram.org/bots/api#sending-files
+ * @param caption Optional. Voice message caption, 0-1024 characters after entities parsing
+ * @param duration Optional. Duration of the voice message in seconds
+ * @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 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 allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ *
+ * @return On success, the sent Message is returned.
*/
- Message::Ptr sendVoice(std::int64_t chatId, boost::variant<InputFile::Ptr, std::string> voice, const std::string& caption = "", int duration = 0, std::int32_t replyToMessageId = 0,
- GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
+ Message::Ptr sendVoice(std::int64_t chatId,
+ boost::variant<InputFile::Ptr, std::string> voice,
+ const std::string& caption = "",
+ std::int32_t duration = 0,
+ 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;
/**
- * @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 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.
+ * @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.
+ *
+ * @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
+ * @param replyToMessageId Optional. If the message is a reply, ID of the original message
+ * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound.
+ * @param duration Optional. Duration of sent video in seconds
+ * @param length Optional. Video width and height, i.e. diameter of the video message
+ * @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
+ *
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendVideoNote(std::int64_t chatId, boost::variant<InputFile::Ptr, 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 = "", GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
+ Message::Ptr sendVideoNote(std::int64_t chatId,
+ boost::variant<InputFile::Ptr, 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 = "",
+ GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
+ bool allowSendingWithoutReply = false) const;
/**
- * @brief Use this method to send a group of photos or videos as an album.
- * @param chatId Unique identifier for the target chat of the target channel.
- * @param media A JSON-serialized array describing photos and videos to be sent, must include 2–10 items.
- * @param disableNotification Optional. Sends the messages silently. Users will receive a notification with no sound.
- * @param replyToMessageId Optional. If the messages are a reply, ID of the original message.
- * @return On success, an array of the sent Messages is returned.
+ * @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)
+ * @param media A JSON-serialized array describing messages to be sent, must include 2-10 items
+ * @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
+ *
+ * @return On success, an array of Messages that were sent is returned.
*/
- std::vector<Message::Ptr> sendMediaGroup(std::int64_t chatId, const std::vector<InputMedia::Ptr>& media,
- bool disableNotification = false, std::int32_t replyToMessageId = 0) const;
+ std::vector<Message::Ptr> sendMediaGroup(std::int64_t chatId,
+ const std::vector<InputMedia::Ptr>& media,
+ bool disableNotification = false,
+ std::int32_t replyToMessageId = 0,
+ bool allowSendingWithoutReply = false) const;
/**
* @brief Use this method to send point on the map.
- * @param chatId Unique identifier for the target chat.
- * @param latitude Latitude of location.
- * @param longitude Longitude of location.
- * @param livePeriod Optional. Period in seconds for which the location will be updated (see 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 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.
+ *
+ * @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 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.
+ * @param horizontalAccuracy Optional. The radius of uncertainty for the location, measured in meters; 0-1500
+ * @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
+ *
+ * @return On success, the sent Message is returned.
*/
- Message::Ptr sendLocation(std::int64_t chatId, float latitude, float longitude, std::uint32_t livePeriod = 0,
- std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const;
-
- /**
- * @brief Use this method to edit live location messages sent by the bot or via the bot (for inline bots).
- * @param latitude Latitude of new location.
- * @param longitude Longitude of new location.
- * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat of the target channel.
- * @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the sent message.
- * @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message.
+ Message::Ptr sendLocation(std::int64_t chatId,
+ float latitude,
+ float longitude,
+ std::uint32_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;
+
+ /**
+ * @brief Use this method to edit live location messages.
+ * A location can be edited until its livePeriod expires or editing is explicitly disabled by a call to Api::stopMessageLiveLocation.
+ *
+ * @param latitude Latitude of new location
+ * @param longitude Longitude of new location
+ * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the message to edit
+ * @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message
* @param replyMarkup Optional. A JSON-serialized object for a new inline keyboard.
- * @return On success, if the edited message was sent by the bot, the edited Message is returned, otherwise nullptr is returned.
+ * @param horizontalAccuracy Optional. The radius of uncertainty for the location, measured in meters; 0-1500
+ * @param heading Optional. Direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.
+ * @param proximityAlertRadius Optional. Maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.
+ *
+ * @return On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.
*/
- Message::Ptr editMessageLiveLocation(float latitude, float longitude, std::int64_t chatId = 0, std::int32_t messageId = 0,
- std::int32_t inlineMessageId = 0, InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>()) const;
+ Message::Ptr editMessageLiveLocation(float latitude,
+ float longitude,
+ std::int64_t chatId = 0,
+ std::int32_t messageId = 0,
+ std::int32_t inlineMessageId = 0,
+ InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>(),
+ float horizontalAccuracy = 0,
+ std::int32_t heading = 0,
+ std::int32_t proximityAlertRadius = 0) const;
/**
* @brief Use this method to edit live location messages sent by the bot or via the bot (for inline bots).
@@ -294,88 +484,140 @@ public:
InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>()) const;
/**
- * @brief Use this method to send information about a venue. On success, the sent Message is returned.
- * @param chatId Unique identifier for the target chat.
- * @param latitude Latitude of location.
- * @param longitude Longitude of location.
- * @param title Name of the venue.
- * @param address Address 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.
+ * @brief Use this method to send information about a venue.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param latitude Latitude of the venue
+ * @param longitude Longitude of the venue
+ * @param title Name of the venue
+ * @param address Address of the venue
+ * @param foursquareId Optional. Foursquare identifier of the venue
+ * @param foursquareType Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
+ * @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 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 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
+ *
+ * @return On success, the sent Message is returned.
*/
- Message::Ptr sendVenue(std::int64_t chatId, float latitude, float longitude, const std::string& title, const std::string& address, const std::string& foursquareId = "", const std::string& foursquareType = "",
- bool disableNotification = false, std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
-
- /**
- * @brief Use this method to send phone contacts. On success, the sent Message is returned.
- * @param chatId Unique identifier for the target chat.
- * @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 sendVenue(std::int64_t chatId,
+ float latitude,
+ float longitude,
+ const std::string& title,
+ const std::string& address,
+ const std::string& foursquareId = "",
+ const std::string& foursquareType = "",
+ bool disableNotification = false,
+ std::int32_t replyToMessageId = 0,
+ GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
+ const std::string& googlePlaceId = "",
+ const std::string& googlePlaceType = "",
+ bool allowSendingWithoutReply = false) const;
+
+ /**
+ * @brief Use this method to send phone contacts.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param phoneNumber Contact's phone number
+ * @param firstName Contact's first name
+ * @param lastName Optional. 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 silently. Users will receive a notification with no sound.
+ * @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
+ *
+ * @return On success, the sent Message is returned.
*/
- Message::Ptr sendContact(std::int64_t chatId, const std::string& phoneNumber, const std::string& firstName, const std::string& lastName = "", const std::string& vcard = "", bool disableNotification = false,
- std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
+ Message::Ptr sendContact(std::int64_t chatId,
+ const std::string& phoneNumber,
+ const std::string& firstName,
+ const std::string& lastName = "",
+ const std::string& vcard = "",
+ bool disableNotification = false,
+ std::int32_t replyToMessageId = 0,
+ GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
+ bool allowSendingWithoutReply = false) const;
/**
* @brief Use this method to send a native poll.
*
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- * @param question Poll question, 1-255 characters
+ * @param question Poll question, 1-300 characters
* @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
+ * @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 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 isAnonymous Optional. True, if the poll needs to be anonymous, defaults to True
* @param type Optional. Poll type, “quiz” or “regular”, defaults to “regular”
* @param allowsMultipleAnswers Optional. True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False
* @param correctOptionId Optional. 0-based identifier of the correct answer option, required for polls in quiz mode
* @param explanation Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing
* @param explanationParseMode Optional. Mode for parsing entities in the explanation. See https://core.telegram.org/bots/api#formatting-options for more details.
- * @param openPeriod Optional. Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with close_date.
- * @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 open_period.
+ * @param explanationEntities Optional. List of special entities that appear in the poll explanation, which can be specified instead of parseMode
+ * @param openPeriod Optional. Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with closeDate.
+ * @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 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 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
*
- * @return On success, the sent @ref Message is returned.
+ * @return On success, the sent Message is returned.
*/
- Message::Ptr sendPoll(std::int64_t chatId, const std::string& question, const std::vector<std::string>& options,
- bool isAnonymous = true, const std::string& type = "", bool allowsMultipleAnswers = false,
- std::int32_t correctOptionId = 0, const std::string& explanation = "", const std::string& explanationParseMode = "",
- std::int32_t openPeriod = 0, std::int64_t closeDate = 0, bool isClosed = false,
- bool disableNotification = false, std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
-
- /**
- * @brief Use this method to send a dice, which will have a random value from 1 to 6.
+ Message::Ptr sendPoll(std::int64_t chatId,
+ const std::string& question,
+ const std::vector<std::string>& options,
+ bool disableNotification = false,
+ std::int32_t replyToMessageId = 0,
+ GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
+ bool isAnonymous = true,
+ const std::string& type = "",
+ bool allowsMultipleAnswers = false,
+ std::int32_t correctOptionId = 0,
+ const std::string& explanation = "",
+ const std::string& explanationParseMode = "",
+ const std::vector<MessageEntity::Ptr>& explanationEntities = std::vector<MessageEntity::Ptr>(),
+ std::int32_t openPeriod = 0,
+ std::int32_t closeDate = 0,
+ bool isClosed = false,
+ bool allowSendingWithoutReply = false) const;
+
+ /**
+ * @brief Use this method to send an animated emoji that will display a random value.
*
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- * @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 “🎯”, and values 1-5 for “🏀”. Defaults to “🎲”
* @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 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
*
- * @return On success, the sent @ref Message is returned.
+ * @return On success, the sent Message is returned.
*/
- Message::Ptr sendDice(std::int64_t chatId, const std::string& emoji = "", bool disableNotification = false,
- std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
+ Message::Ptr sendDice(std::int64_t chatId,
+ bool disableNotification = false,
+ std::int32_t replyToMessageId = 0,
+ GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
+ const std::string& emoji = "",
+ bool allowSendingWithoutReply = false) const;
/**
- * @brief Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
+ * @brief Use this method when you need to tell the user that something is happening on the bot's side.
+ * The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
*
- * Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot.
+ * Example: The ImageBot needs some time to process a request and upload the image.
+ * Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo.
+ * The user will see a “sending photo” status for the bot.
+ *
* We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
*
- * @param chatId Unique identifier for the target chat.
- * @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_audio or upload_audio for audio files, upload_document for general files, find_location for location data.
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.
+ *
+ * @return True on success.
*/
- void sendChatAction(std::int64_t chatId, const std::string& action) const;
+ bool sendChatAction(std::int64_t chatId,
+ const std::string& action) const;
/**
* @brief Use this method to get a list of profile pictures for a user.
@@ -402,51 +644,90 @@ public:
std::string downloadFile(const std::string& filePath, const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>()) const;
/**
- * @brief Use this method to kick a user from a group or a supergroup.
- * @param chatId Unique identifier for the target group.
- * @param userId Unique identifier of the target user.
- * @param untilDate Optional. Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever.
- * @return True on success
+ * @brief Use this method to kick a user from a group, a supergroup or a channel.
+ * In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first.
+ * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
+ *
+ * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername)
+ * @param userId Unique identifier of the target user
+ * @param untilDate Optional. Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Applied for supergroups and channels only.
+ * @param revokeMessages Optional. Pass True to delete all messages from the chat for the user that is being removed. If False, the user will be able to see messages in the group that were sent before the user was removed. Always True for supergroups and channels.
+ *
+ * @return True on success.
*/
- bool kickChatMember(std::int64_t chatId, std::int64_t userId, std::uint64_t untilDate = 0) const;
+ bool banChatMember(std::int64_t chatId,
+ std::int64_t userId,
+ std::uint64_t untilDate = 0,
+ bool revokeMessages = true) const;
/**
- * @brief Use this method to unban a previously kicked user in a supergroup.
- * @param chatId Unique identifier for the target group.
- * @param userId Unique identifier of the target user.
+ * @brief Use this method to unban a previously kicked user in a supergroup or channel.
+ *
+ * The user will not return to the group or channel automatically, but will be able to join via link, etc.
+ * The bot must be an administrator for this to work.
+ * By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it.
+ * So if the user is a member of the chat they will also be removed from the chat.
+ * If you don't want this, use the parameter only_if_banned.
+ *
+ * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format @username)
+ * @param userId Unique identifier of the target user
+ * @param onlyIfBanned Optional. True = Do nothing if the user is not banned
+ *
* @return True on success
*/
- bool unbanChatMember(std::int64_t chatId, std::int64_t userId) const;
+ bool unbanChatMember(std::int64_t chatId, std::int64_t userId, bool onlyIfBanned = false) const;
/**
* @brief Use this method to restrict a user in a supergroup.
- * @param chatId Unique identifier for the target chat of the target supergroup.
- * @param userId Unique identifier of the target user.
- * @param untilDate Optional. Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever.
- * @param canSendMessages Optional. Pass True, if the user can send text messages, contacts, locations and venues.
- * @param canSendMediaMessages Optional. Pass True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages.
- * @param canSendOtherMessages Optional. Pass True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages.
- * @param canAddWebPagePreviews Optional. Pass True, if the user may add web page previews to their messages, implies can_send_media_messages.
+ * The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights.
+ * Pass True for all permissions to lift restrictions from a user.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
+ * @param userId Unique identifier of the target user
+ * @param permissions A JSON-serialized object for new user permissions
+ * @param untilDate Optional. Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever
+ *
* @return True on success
*/
- bool restrictChatMember(std::int64_t chatId, std::int64_t userId, ChatPermissions::Ptr permissions, std::uint64_t untilDate = 0) const;
+ bool restrictChatMember(std::int64_t chatId,
+ std::int64_t userId,
+ ChatPermissions::Ptr permissions,
+ std::uint64_t untilDate = 0) const;
/**
* @brief Use this method to promote or demote a user in a supergroup or a channel.
- * @param chatId Unique identifier for the target chat of the target supergroup or channal.
- * @param userId Unique identifier of the target user.
- * @param canChangeInfo Optional. Pass True, if the administrator can change chat title, photo and other settings.
- * @param canPostMessages Optional. Pass True, if the administrator can create channel posts, channels only.
- * @param canEditMessages Optional. Pass True, if the administrator can edit messages of other users and can pin messages, channels only.
- * @param canDeleteMessages Optional. Pass True, if the administrator can delete messages of other users.
- * @param canInviteUsers Optional. Pass True, if the administrator can invite new users to the chat.
- * @param canRestrictMembers Optional. Pass True, if the administrator can restrict, ban or unban chat members.
- * @param canPinMessages Optional. Pass True, if the administrator can pin messages, supergroups only.
- * @param canPromoteMembers Optional. Pass True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him).
- * @return True on success
+ * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
+ * Pass False for all boolean parameters to demote a user.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param userId Unique identifier of the target user
+ * @param canChangeInfo Optional. Pass True, if the administrator can change chat title, photo and other settings
+ * @param canPostMessages Optional. Pass True, if the administrator can create channel posts, channels only
+ * @param canEditMessages Optional. Pass True, if the administrator can edit messages of other users and can pin messages, channels only
+ * @param canDeleteMessages Optional. Pass True, if the administrator can delete messages of other users
+ * @param canInviteUsers Optional. Pass True, if the administrator can invite new users to the chat
+ * @param canPinMessages Optional. Pass True, if the administrator can pin messages, supergroups only
+ * @param canPromoteMembers Optional. Pass True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him)
+ * @param isAnonymous Optional. Pass True, if the administrator's presence in the chat is hidden
+ * @param canManageChat Optional. Pass True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege
+ * @param canManageVoiceChats Optional. Pass True, if the administrator can manage voice chats, supergroups only
+ * @param canRestrictMembers Optional. Pass True, if the administrator can restrict, ban or unban chat members
+ *
+ * @return True on success.
*/
- bool promoteChatMember(std::int64_t chatId, std::int64_t userId, bool canChangeInfo = false, bool canPostMessages = false,
- bool canEditMessages = false, bool canDeleteMessages = false, bool canInviteUsers = false, bool canPinMessages = false, bool canPromoteMembers = false) const;
+ bool promoteChatMember(std::int64_t chatId,
+ std::int64_t userId,
+ bool canChangeInfo = false,
+ bool canPostMessages = false,
+ bool canEditMessages = false,
+ bool canDeleteMessages = false,
+ bool canInviteUsers = false,
+ bool canPinMessages = false,
+ bool canPromoteMembers = false,
+ bool isAnonymous = false,
+ bool canManageChat = false,
+ bool canManageVoiceChats = false,
+ bool canRestrictMembers = false) const;
/**
* @brief Use this method to set a custom title for an administrator in a supergroup promoted by the bot.
@@ -460,6 +741,31 @@ public:
bool setChatAdministratorCustomTitle(std::int64_t chatId, std::int64_t userId, const std::string& customTitle) const;
/**
+ * @brief Use this method to ban a channel chat in a supergroup or a channel.
+ * Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels.
+ * The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param senderChatId Unique identifier of the target sender chat
+ *
+ * @return True on success.
+ */
+ bool banChatSenderChat(std::int64_t chatId,
+ std::int64_t senderChatId) const;
+
+ /**
+ * @brief Use this method to unban a previously banned channel chat in a supergroup or channel.
+ * The bot must be an administrator for this to work and must have the appropriate administrator rights.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param senderChatId Unique identifier of the target sender chat
+ *
+ * @return Returns True on success.
+ */
+ bool unbanChatSenderChat(std::int64_t chatId,
+ std::int64_t senderChatId) const;
+
+ /**
* @brief Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members admin rights. Returns True on success.
* @param chatId Unique identifier for the target chat of the target supergroup.
* @param permissions New default chat permissions.
@@ -475,6 +781,82 @@ public:
std::string exportChatInviteLink(std::int64_t chatId) const;
/**
+ * @brief Use this method to create an additional invite link for a chat.
+ * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
+ * The link can be revoked using the method Api::revokeChatInviteLink.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param expireDate Optional. Point in time (Unix timestamp) when the link will expire
+ * @param memberLimit Optional. Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
+ * @param name Optional. Invite link name; 0-32 characters
+ * @param createsJoinRequest Optional. True, if users joining the chat via the link need to be approved by chat administrators. If True, memberLimit can't be specified
+ *
+ * @return the new invite link as ChatInviteLink object.
+ */
+ ChatInviteLink::Ptr createChatInviteLink(std::int64_t chatId,
+ std::int32_t expireDate = 0,
+ std::int32_t memberLimit = 0,
+ const std::string& name = "",
+ bool createsJoinRequest = false) const;
+
+ /**
+ * @brief Use this method to edit a non-primary invite link created by the bot.
+ * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param inviteLink The invite link to edit
+ * @param expireDate Optional. Point in time (Unix timestamp) when the link will expire
+ * @param memberLimit Optional. Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
+ * @param name Optional. Invite link name; 0-32 characters
+ * @param createsJoinRequest Optional. True, if users joining the chat via the link need to be approved by chat administrators. If True, memberLimit can't be specified
+ *
+ * @return the edited invite link as a ChatInviteLink object.
+ */
+ ChatInviteLink::Ptr editChatInviteLink(std::int64_t chatId,
+ std::string inviteLink,
+ std::int32_t expireDate = 0,
+ std::int32_t memberLimit = 0,
+ const std::string& name = "",
+ bool createsJoinRequest = false) const;
+
+ /**
+ * @brief Use this method to revoke an invite link created by the bot.
+ * If the primary link is revoked, a new link is automatically generated.
+ * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param inviteLink The invite link to revoke
+ *
+ * @return the revoked invite link as ChatInviteLink object.
+ */
+ ChatInviteLink::Ptr revokeChatInviteLink(std::int64_t chatId,
+ std::string inviteLink) const;
+
+ /**
+ * @brief Use this method to approve a chat join request.
+ * The bot must be an administrator in the chat for this to work and must have the canInviteUsers administrator right.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param userId Unique identifier of the target user
+ *
+ * @return True on success.
+ */
+ bool approveChatJoinRequest(std::int64_t chatId,
+ std::int64_t userId) const;
+
+ /**
+ * @brief Use this method to decline a chat join request.
+ * The bot must be an administrator in the chat for this to work and must have the canInviteUsers administrator right.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param userId Unique identifier of the target user
+ *
+ * @return True on success.
+ */
+ bool declineChatJoinRequest(std::int64_t chatId,
+ std::int64_t userId) const;
+
+ /**
* @brief Use this method to set a new profile photo for the chat.
*
* Photos can't be changed for private chats.
@@ -524,11 +906,25 @@ public:
bool pinChatMessage(std::int64_t chatId, std::int32_t messageId, bool disableNotification = false) const;
/**
- * @brief Use this method to unpin a message in a group, a supergroup, or a channel.
- * @param chatId Unique identifier for the target chat or username of the target channel.
- * @return True on success
+ * @brief Use this method to remove a message from the list of pinned messages in a chat.
+ * If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' admin right in a channel.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param messageId Optional. Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned.
+ *
+ * @return True on success.
+ */
+ bool unpinChatMessage(std::int64_t chatId, std::int32_t messageId = 0) const;
+
+ /**
+ * @brief Use this method to clear the list of pinned messages in a chat.
+ * If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' admin right in a channel.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ *
+ * @return True on success.
*/
- bool unpinChatMessage(std::int64_t chatId) const;
+ bool unpinAllChatMessages(std::int64_t chatId) const;
/**
* @brief Use this method for your bot to leave a group, supergroup or channel.
@@ -538,9 +934,11 @@ public:
bool leaveChat(std::int64_t chatId) const;
/**
- * @brief Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success.
- * @param chatId Unique identifier for the target chat of the target supergroup or channel.
- * @return Chat object.
+ * @brief Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.).
+ *
+ * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
+ *
+ * @return @ref Chat object on success.
*/
Chat::Ptr getChat(std::int64_t chatId) const;
@@ -552,11 +950,13 @@ public:
std::vector<ChatMember::Ptr> getChatAdministrators(std::int64_t chatId) const;
/**
- * @brief Use this method to get the number of members in a chat. Returns Int on success.
- * @param chatId Unique identifier for the target chat of the target supergroup or channel.
- * @return Int.
+ * @brief Use this method to get the number of members in a chat.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
+ *
+ * @return Int on success.
*/
- std::int32_t getChatMembersCount(std::int64_t chatId) const;
+ std::int32_t getChatMemberCount(std::int64_t chatId) const;
/**
* @brief Use this method to get information about a member of a chat. Returns a ChatMember object on success.
@@ -594,42 +994,84 @@ public:
/**
* @brief Use this method to change the list of the bot's commands.
+ * See https://core.telegram.org/bots#commands for more details about bot commands.
+ *
* @param commands A JSON-serialized list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.
+ * @param scope Optional. A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault.
+ * @param languageCode Optional. A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands
+ *
* @return True on success.
*/
- bool setMyCommands(const std::vector<BotCommand::Ptr>& commands) const;
+ bool setMyCommands(const std::vector<BotCommand::Ptr>& commands,
+ BotCommandScope::Ptr scope = nullptr,
+ const std::string& languageCode = "") const;
/**
- * @brief Use this method to get the current list of the bot's commands.
- * @return Array of @ref BotCommand on success.
+ * @brief Use this method to delete the list of the bot's commands for the given scope and user language.
+ * After deletion, higher level commands will be shown to affected users.
+ *
+ * @param scope Optional. A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault.
+ * @param languageCode Optional. A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands
+ *
+ * @return True on success.
*/
- std::vector<BotCommand::Ptr> getMyCommands() const;
+ bool deleteMyCommands(BotCommandScope::Ptr scope = nullptr,
+ const std::string& languageCode = "") const;
/**
- * @brief Use this method to edit text and game messages sent by the bot or via the bot (for inline bots)
- * @param text New text 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 parseMode Optional Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
- * @param disableWebPagePreview Optional Disables link previews for links in this message
- * @param replyMarkup Optional A JSON-serialized object for an inline keyboard.
- * @return Message object on success, otherwise nullptr
+ * @brief Use this method to get the current list of the bot's commands for the given scope and user language.
+ *
+ * @param scope Optional. A JSON-serialized object, describing scope of users. Defaults to BotCommandScopeDefault.
+ * @param languageCode Optional. A two-letter ISO 639-1 language code or an empty string
+ *
+ * @return Array of BotCommand on success. If commands aren't set, an empty list is returned.
*/
- Message::Ptr editMessageText(const std::string& text, std::int64_t chatId = 0, std::int32_t messageId = 0, const std::string& inlineMessageId = "",
- const std::string& parseMode = "", bool disableWebPagePreview = false, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
+ std::vector<BotCommand::Ptr> getMyCommands(BotCommandScope::Ptr scope = nullptr,
+ const std::string& languageCode = "") const;
/**
- * @brief Use this method to edit captions 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
- * @param caption Optional New caption of the 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 Message object on success, otherwise nullptr
- */
- Message::Ptr editMessageCaption(std::int64_t chatId = 0, std::int32_t messageId = 0, const std::string& caption = "",
- const std::string& inlineMessageId = "", GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
+ * @brief Use this method to edit text and game messages.
+ *
+ * @param text New text of the message, 1-4096 characters after entities parsing
+ * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the message to edit
+ * @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message
+ * @param parseMode Optional. Mode for parsing entities in the message text. See https://core.telegram.org/bots/api#formatting-options for more details.
+ * @param disableWebPagePreview Optional. Disables link previews for links in this message
+ * @param replyMarkup Optional. A JSON-serialized object for an inline keyboard.
+ * @param entities Optional. List of special entities that appear in message text, which can be specified instead of parseMode
+ *
+ * @return On success, the edited Message is returned.
+ */
+ Message::Ptr editMessageText(const std::string& text,
+ std::int64_t chatId = 0,
+ std::int32_t messageId = 0,
+ const std::string& inlineMessageId = "",
+ const std::string& parseMode = "",
+ bool disableWebPagePreview = false,
+ GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
+ const std::vector<MessageEntity::Ptr>& entities = std::vector<MessageEntity::Ptr>()) const;
+
+ /**
+ * @brief Use this method to edit captions of messages.
+ *
+ * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the message to edit
+ * @param caption Optional. New caption of the message, 0-1024 characters after entities parsing
+ * @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message
+ * @param replyMarkup Optional. A JSON-serialized object for an inline keyboard.
+ * @param parseMode Optional. Mode for parsing entities in the message caption. See https://core.telegram.org/bots/api#formatting-options for more details.
+ * @param captionEntities Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ *
+ * @return On success, the edited Message is returned.
+ */
+ Message::Ptr editMessageCaption(std::int64_t chatId = 0,
+ std::int32_t messageId = 0,
+ const std::string& caption = "",
+ const std::string& inlineMessageId = "",
+ GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
+ const std::string& parseMode = "",
+ const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>()) const;
/**
* @brief Use this method to edit audio, document, photo, or video messages.
@@ -637,7 +1079,7 @@ public:
*
* 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.
+ * Use previously uploaded file via its fileId 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.
@@ -679,20 +1121,29 @@ public:
void deleteMessage(std::int64_t chatId, std::int32_t messageId) const;
/**
- * @brief Use this method to send .webp stickers.
- * @param chatId Unique identifier for the target chat.
- * @param sticker Sticker to send.
- * @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 disableNotification Optional. Sends the message silenty.
- * @return On success, the sent message is returned.
+ * @brief Use this method to send static .WEBP or animated .TGS stickers.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param sticker Sticker to send. Pass a fileId as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP file from the Internet, or upload a new one using multipart/form-data. https://core.telegram.org/bots/api#sending-files
+ * @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.
+ * @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ *
+ * @return On success, the sent Message is returned.
*/
- Message::Ptr sendSticker(std::int64_t chatId, boost::variant<InputFile::Ptr, std::string> sticker, std::int32_t replyToMessageId = 0,
- GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const;
+ Message::Ptr sendSticker(std::int64_t chatId,
+ boost::variant<InputFile::Ptr, std::string> sticker,
+ std::int32_t replyToMessageId = 0,
+ GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
+ bool disableNotification = false,
+ bool allowSendingWithoutReply = false) const;
/**
* @brief Use this method to get a sticker set.
- * @param chatId Name of the sticker set.
+ *
+ * @param name Name of the sticker set
+ *
* @return On success, a StickerSet object is returned.
*/
StickerSet::Ptr getStickerSet(const std::string& name) const;
@@ -712,16 +1163,21 @@ public:
* @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 emojis One or more emoji corresponding to the sticker
- * @param pngSticker Optional. 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, or upload a new one using multipart/form-data.
- * @param tgsSticker Optional. TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
* @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
+ * @param pngSticker Optional. 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 fileId 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, or upload a new one using multipart/form-data.
+ * @param tgsSticker Optional. TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
*
* @return Returns True on success.
*/
- bool createNewStickerSet(std::int64_t userId, const std::string& name, const std::string& title,
- const std::string& emojis, boost::variant<InputFile::Ptr, std::string> pngSticker = "", boost::variant<InputFile::Ptr, std::string> tgsSticker = "",
- bool containsMasks = false, MaskPosition::Ptr maskPosition = nullptr) const;
+ bool createNewStickerSet(std::int64_t userId,
+ const std::string& name,
+ const std::string& title,
+ const std::string& emojis,
+ bool containsMasks = false,
+ MaskPosition::Ptr maskPosition = nullptr,
+ boost::variant<InputFile::Ptr, std::string> pngSticker = "",
+ boost::variant<InputFile::Ptr, std::string> tgsSticker = "") const;
/**
* @brief Use this method to add a new sticker to a set created by the bot. You must use exactly one of the fields png_sticker or tgs_sticker. Animated stickers can be added to animated sticker sets and only to them. Animated sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers.
@@ -729,27 +1185,36 @@ public:
* @param userId User identifier of sticker set owner
* @param name Sticker set name
* @param emojis One or more emoji corresponding to the sticker
- * @param pngSticker Optional. 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, or upload a new one using multipart/form-data.
- * @param tgsSticker Optional. TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
* @param maskPosition Optional. A JSON-serialized object for position where the mask should be placed on faces
+ * @param pngSticker Optional. 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 fileId 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, or upload a new one using multipart/form-data.
+ * @param tgsSticker Optional. TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
*
* @return Returns True on success.
*/
- bool addStickerToSet(std::int64_t userId, const std::string& name, const std::string& emojis,
- boost::variant<InputFile::Ptr, std::string> pngSticker = "", boost::variant<InputFile::Ptr, std::string> tgsSticker = "", MaskPosition::Ptr maskPosition = nullptr) const;
+ bool addStickerToSet(std::int64_t userId,
+ const std::string& name,
+ const std::string& emojis,
+ MaskPosition::Ptr maskPosition = nullptr,
+ boost::variant<InputFile::Ptr, std::string> pngSticker = "",
+ boost::variant<InputFile::Ptr, std::string> tgsSticker = "") const;
/**
* @brief Use this method to move a sticker in a set created by the bot to a specific position.
- * @param stickers File identifier of the sticker.
- * @param position New sticker position in the set, zero-based.
- * @return Returns True on success.
+ *
+ * @param sticker File identifier of the sticker
+ * @param position New sticker position in the set, zero-based
+ *
+ * @return True on success.
*/
- bool setStickerPositionInSet(const std::string& sticker, std::uint32_t position) const;
+ bool setStickerPositionInSet(const std::string& sticker,
+ std::uint32_t position) const;
/**
* @brief Use this method to delete a sticker from a set created by the bot.
- * @param stickers File identifier of the sticker.
- * @return Returns True on success.
+ *
+ * @param sticker File identifier of the sticker
+ *
+ * @return True on success.
*/
bool deleteStickerFromSet(const std::string& sticker) const;
@@ -758,7 +1223,7 @@ public:
*
* @param name Sticker set name
* @param userId User identifier of the sticker set owner
- * @param thumb Optional. A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/animated_stickers#technical-requirements for animated sticker technical requirements. 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, or upload a new one using multipart/form-data. Animated sticker set thumbnail can't be uploaded via HTTP URL.
+ * @param thumb Optional. A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/animated_stickers#technical-requirements for animated sticker technical requirements. Pass a fileId 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, or upload a new one using multipart/form-data. Animated sticker set thumbnail can't be uploaded via HTTP URL.
*
* @return Returns True on success.
*/
@@ -781,38 +1246,62 @@ public:
/**
* @brief Use this method to send invoices.
- * @param chatId Unique identifier for the target private chat.
- * @param title Product name, 1-32 characters.
- * @param description Product description, 1-255 characters.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param title Product name, 1-32 characters
+ * @param description Product description, 1-255 characters
* @param payload Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
- * @param providerToken Payments provider token, obtained via Botfather.
- * @param startParameter Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter.
- * @param currency Three-letter ISO 4217 currency code.
- * @param prices Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
- * @param providerData Optional. JSON-encoded data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.
+ * @param providerToken Payments provider token, obtained via Botfather
+ * @param currency Three-letter ISO 4217 currency code, see https://core.telegram.org/bots/payments#supported-currencies
+ * @param prices Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
+ * @param providerData Optional. A JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.
* @param photoUrl Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.
* @param photoSize Optional. Photo size
* @param photoWidth Optional. Photo width
* @param photoHeight Optional. Photo height
- * @param needName Optional. Pass True, if you require the user's full name to complete the order.
- * @param needPhoneNumber Optional. Pass True, if you require the user's phone number to complete the order.
- * @param needEmail Optional. Pass True, if you require the user's email address to complete the order.
- * @param needShippingAddress Optional. Pass True, if you require the user's shipping address to complete the order.
- * @param sendPhoneNumberToProvider Optional. Pass True, if user's phone number should be sent to provider.
+ * @param needName Optional. Pass True, if you require the user's full name to complete the order
+ * @param needPhoneNumber Optional. Pass True, if you require the user's phone number to complete the order
+ * @param needEmail Optional. Pass True, if you require the user's email address to complete the order
+ * @param needShippingAddress Optional. Pass True, if you require the user's shipping address to complete the order
+ * @param sendPhoneNumberToProvider Optional. Pass True, if user's phone number should be sent to provider
* @param sendEmailToProvider Optional. Pass True, if user's email address should be sent to provider
- * @param isFlexible Optional. Pass True, if the final price depends on the shipping method.
- * @param replyToMessageId Optional. If the message is a reply, ID of the original message.
+ * @param isFlexible Optional. Pass True, if the final price depends on the shipping method
+ * @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 'Pay total price' button will be shown. If not empty, the first button must be a Pay button.
* @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 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
+ *
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendInvoice(std::int64_t chatId, const std::string& title, const std::string& description, const std::string& payload,
- const std::string& providerToken, const std::string& startParameter, const std::string& currency, const std::vector<LabeledPrice::Ptr>& prices,
- const std::string& providerData = "", const std::string& photoUrl = "", std::int32_t photoSize = 0,
- std::int32_t photoWidth = 0, std::int32_t photoHeight = 0, bool needName = false,
- bool needPhoneNumber = false, bool needEmail = false, bool needShippingAddress = false,
- bool sendPhoneNumberToProvider = false, bool sendEmailToProvider = false, bool isFlexible = false,
- std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const;
+ Message::Ptr sendInvoice(std::int64_t chatId,
+ const std::string& title,
+ const std::string& description,
+ const std::string& payload,
+ const std::string& providerToken,
+ const std::string& currency,
+ const std::vector<LabeledPrice::Ptr>& prices,
+ const std::string& providerData = "",
+ const std::string& photoUrl = "",
+ std::int32_t photoSize = 0,
+ std::int32_t photoWidth = 0,
+ std::int32_t photoHeight = 0,
+ bool needName = false,
+ bool needPhoneNumber = false,
+ bool needEmail = false,
+ bool needShippingAddress = false,
+ bool sendPhoneNumberToProvider = false,
+ bool sendEmailToProvider = false,
+ bool isFlexible = false,
+ std::int32_t replyToMessageId = 0,
+ GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
+ bool disableNotification = false,
+ 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;
/**
* @brief Use this method to reply to shipping queries.
@@ -857,15 +1346,22 @@ public:
/**
* @brief Use this method to send a game.
- * @param chatId Unique identifier for the target chat.
+ *
+ * @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 disableNotification Optional. Sends the message silenty.
- * @return On success, the sent message is returned.
+ * @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 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
+ *
+ * @return On success, the sent Message is returned.
*/
- Message::Ptr sendGame(std::int64_t chatId, const std::string& gameShortName, std::int32_t replyToMessageId = 0,
- InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>(), bool disableNotification = false) const;
+ Message::Ptr sendGame(std::int64_t chatId,
+ const std::string& gameShortName,
+ std::int32_t replyToMessageId = 0,
+ InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>(),
+ bool disableNotification = false,
+ bool allowSendingWithoutReply = false) const;
/**
* @brief Use this method to set the score of the specified user in a game.
@@ -886,17 +1382,23 @@ public:
/**
* @brief Use this method to get data for high score tables.
+ * Will return the score of the specified user and several of their neighbors in a game.
*
- * Will return the score of the specified user and several of his neighbors in a game.
- *
- * @param userId User identifier.
+ * This method will currently return scores for the target user, plus two of their closest neighbors on each side.
+ * Will also return the top three users if the user and his neighbors are not among them.
+ * Please note that this behavior is subject to change.
+ *
+ * @param userId Target user id
* @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat
* @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the sent message
* @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message
+ *
* @return On success, returns an Array of GameHighScore objects.
*/
- std::vector<GameHighScore::Ptr> getGameHighScores(std::int64_t userId, std::int32_t score, bool force = false,
- bool disableEditMessage = false, std::int64_t chatId = 0, std::int32_t messageId = 0, const std::string& inlineMessageId = "") const;
+ std::vector<GameHighScore::Ptr> getGameHighScores(std::int64_t userId,
+ std::int64_t chatId = 0,
+ std::int32_t messageId = 0,
+ const std::string& inlineMessageId = "") const;
private:
boost::property_tree::ptree sendRequest(const std::string& method, const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>()) const;
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index 15a29d6..db96a0b 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -5,6 +5,7 @@
#include "tgbot/types/User.h"
#include "tgbot/types/Chat.h"
#include "tgbot/types/Message.h"
+#include "tgbot/types/MessageId.h"
#include "tgbot/types/PhotoSize.h"
#include "tgbot/types/Audio.h"
#include "tgbot/types/Document.h"
@@ -15,12 +16,19 @@
#include "tgbot/types/PollAnswer.h"
#include "tgbot/types/PollOption.h"
#include "tgbot/types/ChatPermissions.h"
+#include "tgbot/types/ChatLocation.h"
#include "tgbot/types/MaskPosition.h"
#include "tgbot/types/Video.h"
#include "tgbot/types/Voice.h"
#include "tgbot/types/VideoNote.h"
#include "tgbot/types/Contact.h"
#include "tgbot/types/Location.h"
+#include "tgbot/types/ProximityAlertTriggered.h"
+#include "tgbot/types/MessageAutoDeleteTimerChanged.h"
+#include "tgbot/types/VoiceChatScheduled.h"
+#include "tgbot/types/VoiceChatStarted.h"
+#include "tgbot/types/VoiceChatEnded.h"
+#include "tgbot/types/VoiceChatParticipantsInvited.h"
#include "tgbot/types/Update.h"
#include "tgbot/types/UserProfilePhotos.h"
#include "tgbot/types/File.h"
@@ -30,6 +38,14 @@
#include "tgbot/types/ReplyKeyboardRemove.h"
#include "tgbot/types/ForceReply.h"
#include "tgbot/types/ChatMember.h"
+#include "tgbot/types/ChatMemberOwner.h"
+#include "tgbot/types/ChatMemberAdministrator.h"
+#include "tgbot/types/ChatMemberMember.h"
+#include "tgbot/types/ChatMemberRestricted.h"
+#include "tgbot/types/ChatMemberLeft.h"
+#include "tgbot/types/ChatMemberBanned.h"
+#include "tgbot/types/ChatMemberUpdated.h"
+#include "tgbot/types/ChatJoinRequest.h"
#include "tgbot/types/ChatPhoto.h"
#include "tgbot/types/ResponseParameters.h"
#include "tgbot/types/GenericReply.h"
@@ -69,6 +85,7 @@
#include "tgbot/types/InputLocationMessageContent.h"
#include "tgbot/types/InputVenueMessageContent.h"
#include "tgbot/types/InputContactMessageContent.h"
+#include "tgbot/types/InputInvoiceMessageContent.h"
#include "tgbot/types/Invoice.h"
#include "tgbot/types/OrderInfo.h"
#include "tgbot/types/PreCheckoutQuery.h"
@@ -78,6 +95,14 @@
#include "tgbot/types/SuccessfulPayment.h"
#include "tgbot/types/LabeledPrice.h"
#include "tgbot/types/BotCommand.h"
+#include "tgbot/types/BotCommandScope.h"
+#include "tgbot/types/BotCommandScopeDefault.h"
+#include "tgbot/types/BotCommandScopeAllPrivateChats.h"
+#include "tgbot/types/BotCommandScopeAllGroupChats.h"
+#include "tgbot/types/BotCommandScopeAllChatAdministrators.h"
+#include "tgbot/types/BotCommandScopeChat.h"
+#include "tgbot/types/BotCommandScopeChatAdministrators.h"
+#include "tgbot/types/BotCommandScopeChatMember.h"
#include "tgbot/types/InputMedia.h"
#include "tgbot/types/InputMediaPhoto.h"
#include "tgbot/types/InputMediaVideo.h"
@@ -129,6 +154,9 @@ public:
Message::Ptr parseJsonAndGetMessage(const boost::property_tree::ptree& data) const;
std::string parseMessage(const Message::Ptr& object) const;
+ MessageId::Ptr parseJsonAndGetMessageId(const boost::property_tree::ptree& data) const;
+ std::string parseMessageId(const MessageId::Ptr& object) const;
+
PhotoSize::Ptr parseJsonAndGetPhotoSize(const boost::property_tree::ptree& data) const;
std::string parsePhotoSize(const PhotoSize::Ptr& object) const;
@@ -162,6 +190,9 @@ public:
ChatPermissions::Ptr parseJsonAndGetChatPermissions(const boost::property_tree::ptree& data) const;
std::string parseChatPermissions(const ChatPermissions::Ptr& object) const;
+ ChatLocation::Ptr parseJsonAndGetChatLocation(const boost::property_tree::ptree& data) const;
+ std::string parseChatLocation(const ChatLocation::Ptr& object) const;
+
Video::Ptr parseJsonAndGetVideo(const boost::property_tree::ptree& data) const;
std::string parseVideo(const Video::Ptr& object) const;
@@ -189,6 +220,24 @@ public:
Venue::Ptr parseJsonAndGetVenue(const boost::property_tree::ptree& data) const;
std::string parseVenue(const Venue::Ptr& object) const;
+ ProximityAlertTriggered::Ptr parseJsonAndGetProximityAlertTriggered(const boost::property_tree::ptree& data) const;
+ std::string parseProximityAlertTriggered(const ProximityAlertTriggered::Ptr& object) const;
+
+ MessageAutoDeleteTimerChanged::Ptr parseJsonAndGetMessageAutoDeleteTimerChanged(const boost::property_tree::ptree& data) const;
+ std::string parseMessageAutoDeleteTimerChanged(const MessageAutoDeleteTimerChanged::Ptr& object) const;
+
+ VoiceChatScheduled::Ptr parseJsonAndGetVoiceChatScheduled(const boost::property_tree::ptree& data) const;
+ std::string parseVoiceChatScheduled(const VoiceChatScheduled::Ptr& object) const;
+
+ VoiceChatStarted::Ptr parseJsonAndGetVoiceChatStarted(const boost::property_tree::ptree& data) const;
+ std::string parseVoiceChatStarted(const VoiceChatStarted::Ptr& object) const;
+
+ VoiceChatEnded::Ptr parseJsonAndGetVoiceChatEnded(const boost::property_tree::ptree& data) const;
+ std::string parseVoiceChatEnded(const VoiceChatEnded::Ptr& object) const;
+
+ VoiceChatParticipantsInvited::Ptr parseJsonAndGetVoiceChatParticipantsInvited(const boost::property_tree::ptree& data) const;
+ std::string parseVoiceChatParticipantsInvited(const VoiceChatParticipantsInvited::Ptr& object) const;
+
Update::Ptr parseJsonAndGetUpdate(const boost::property_tree::ptree& data) const;
std::string parseUpdate(const Update::Ptr& object) const;
@@ -198,6 +247,21 @@ public:
InputMedia::Ptr parseJsonAndGetInputMedia(const boost::property_tree::ptree& data) const;
std::string parseInputMedia(const InputMedia::Ptr& object) const;
+ InputMediaPhoto::Ptr parseJsonAndGetInputMediaPhoto(const boost::property_tree::ptree& data) const;
+ std::string parseInputMediaPhoto(const InputMediaPhoto::Ptr& object) const;
+
+ InputMediaVideo::Ptr parseJsonAndGetInputMediaVideo(const boost::property_tree::ptree& data) const;
+ std::string parseInputMediaVideo(const InputMediaVideo::Ptr& object) const;
+
+ InputMediaAnimation::Ptr parseJsonAndGetInputMediaAnimation(const boost::property_tree::ptree& data) const;
+ std::string parseInputMediaAnimation(const InputMediaAnimation::Ptr& object) const;
+
+ InputMediaAudio::Ptr parseJsonAndGetInputMediaAudio(const boost::property_tree::ptree& data) const;
+ std::string parseInputMediaAudio(const InputMediaAudio::Ptr& object) const;
+
+ InputMediaDocument::Ptr parseJsonAndGetInputMediaDocument(const boost::property_tree::ptree& data) const;
+ std::string parseInputMediaDocument(const InputMediaDocument::Ptr& object) const;
+
File::Ptr parseJsonAndGetFile(const boost::property_tree::ptree& data) const;
std::string parseFile(const File::Ptr& object) const;
@@ -219,9 +283,36 @@ public:
ChatMember::Ptr parseJsonAndGetChatMember(const boost::property_tree::ptree& data) const;
std::string parseChatMember(const ChatMember::Ptr& object) const;
+ ChatMemberOwner::Ptr parseJsonAndGetChatMemberOwner(const boost::property_tree::ptree& data) const;
+ std::string parseChatMemberOwner(const ChatMemberOwner::Ptr& object) const;
+
+ ChatMemberAdministrator::Ptr parseJsonAndGetChatMemberAdministrator(const boost::property_tree::ptree& data) const;
+ std::string parseChatMemberAdministrator(const ChatMemberAdministrator::Ptr& object) const;
+
+ ChatMemberMember::Ptr parseJsonAndGetChatMemberMember(const boost::property_tree::ptree& data) const;
+ std::string parseChatMemberMember(const ChatMemberMember::Ptr& object) const;
+
+ ChatMemberRestricted::Ptr parseJsonAndGetChatMemberRestricted(const boost::property_tree::ptree& data) const;
+ std::string parseChatMemberRestricted(const ChatMemberRestricted::Ptr& object) const;
+
+ ChatMemberLeft::Ptr parseJsonAndGetChatMemberLeft(const boost::property_tree::ptree& data) const;
+ std::string parseChatMemberLeft(const ChatMemberLeft::Ptr& object) const;
+
+ ChatMemberBanned::Ptr parseJsonAndGetChatMemberBanned(const boost::property_tree::ptree& data) const;
+ std::string parseChatMemberBanned(const ChatMemberBanned::Ptr& object) const;
+
+ ChatMemberUpdated::Ptr parseJsonAndGetChatMemberUpdated(const boost::property_tree::ptree& data) const;
+ std::string parseChatMemberUpdated(const ChatMemberUpdated::Ptr& object) const;
+
+ ChatJoinRequest::Ptr parseJsonAndGetChatJoinRequest(const boost::property_tree::ptree& data) const;
+ std::string parseChatJoinRequest(const ChatJoinRequest::Ptr& object) const;
+
ChatPhoto::Ptr parseJsonAndGetChatPhoto(const boost::property_tree::ptree& data) const;
std::string parseChatPhoto(const ChatPhoto::Ptr& object) const;
+ ChatInviteLink::Ptr parseJsonAndGetChatInviteLink(const boost::property_tree::ptree& data) const;
+ std::string parseChatInviteLink(const ChatInviteLink::Ptr& object) const;
+
ResponseParameters::Ptr parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const;
std::string parseResponseParameters(const ResponseParameters::Ptr& object) const;
@@ -324,6 +415,9 @@ public:
InputContactMessageContent::Ptr parseJsonAndGetInputContactMessageContent(const boost::property_tree::ptree& data) const;
std::string parseInputContactMessageContent(const InputContactMessageContent::Ptr& object) const;
+ InputInvoiceMessageContent::Ptr parseJsonAndGetInputInvoiceMessageContent(const boost::property_tree::ptree& data) const;
+ std::string parseInputInvoiceMessageContent(const InputInvoiceMessageContent::Ptr& object) const;
+
Invoice::Ptr parseJsonAndGetInvoice(const boost::property_tree::ptree& data) const;
std::string parseInvoice(const Invoice::Ptr& object) const;
@@ -333,6 +427,30 @@ public:
BotCommand::Ptr parseJsonAndGetBotCommand(const boost::property_tree::ptree& data) const;
std::string parseBotCommand(const BotCommand::Ptr& object) const;
+ BotCommandScope::Ptr parseJsonAndGetBotCommandScope(const boost::property_tree::ptree& data) const;
+ std::string parseBotCommandScope(const BotCommandScope::Ptr& object) const;
+
+ BotCommandScopeDefault::Ptr parseJsonAndGetBotCommandScopeDefault(const boost::property_tree::ptree& data) const;
+ std::string parseBotCommandScopeDefault(const BotCommandScopeDefault::Ptr& object) const;
+
+ BotCommandScopeAllPrivateChats::Ptr parseJsonAndGetBotCommandScopeAllPrivateChats(const boost::property_tree::ptree& data) const;
+ std::string parseBotCommandScopeAllPrivateChats(const BotCommandScopeAllPrivateChats::Ptr& object) const;
+
+ BotCommandScopeAllGroupChats::Ptr parseJsonAndGetBotCommandScopeAllGroupChats(const boost::property_tree::ptree& data) const;
+ std::string parseBotCommandScopeAllGroupChats(const BotCommandScopeAllGroupChats::Ptr& object) const;
+
+ BotCommandScopeAllChatAdministrators::Ptr parseJsonAndGetBotCommandScopeAllChatAdministrators(const boost::property_tree::ptree& data) const;
+ std::string parseBotCommandScopeAllChatAdministrators(const BotCommandScopeAllChatAdministrators::Ptr& object) const;
+
+ BotCommandScopeChat::Ptr parseJsonAndGetBotCommandScopeChat(const boost::property_tree::ptree& data) const;
+ std::string parseBotCommandScopeChat(const BotCommandScopeChat::Ptr& object) const;
+
+ BotCommandScopeChatAdministrators::Ptr parseJsonAndGetBotCommandScopeChatAdministrators(const boost::property_tree::ptree& data) const;
+ std::string parseBotCommandScopeChatAdministrators(const BotCommandScopeChatAdministrators::Ptr& object) const;
+
+ BotCommandScopeChatMember::Ptr parseJsonAndGetBotCommandScopeChatMember(const boost::property_tree::ptree& data) const;
+ std::string parseBotCommandScopeChatMember(const BotCommandScopeChatMember::Ptr& object) const;
+
OrderInfo::Ptr parseJsonAndGetOrderInfo(const boost::property_tree::ptree& data) const;
std::string parseOrderInfo(const OrderInfo::Ptr& object) const;
diff --git a/include/tgbot/types/Audio.h b/include/tgbot/types/Audio.h
index a4b8c94..50611ca 100644
--- a/include/tgbot/types/Audio.h
+++ b/include/tgbot/types/Audio.h
@@ -46,6 +46,11 @@ public:
std::string title;
/**
+ * @brief Optional. Original filename as defined by sender
+ */
+ std::string fileName;
+
+ /**
* @brief Optional. MIME type of the file as defined by sender
*/
std::string mimeType;
diff --git a/include/tgbot/types/BotCommandScope.h b/include/tgbot/types/BotCommandScope.h
new file mode 100644
index 0000000..47a3ee9
--- /dev/null
+++ b/include/tgbot/types/BotCommandScope.h
@@ -0,0 +1,31 @@
+#ifndef TGBOT_BOTCOMMANDSCOPE_H
+#define TGBOT_BOTCOMMANDSCOPE_H
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief This abstract class is base of all bot command scopes.
+ *
+ * This object represents the scope to which bot commands are applied.
+ *
+ * @ingroup types
+ */
+class BotCommandScope {
+public:
+ typedef std::shared_ptr<BotCommandScope> Ptr;
+
+ BotCommandScope() {}
+
+ virtual ~BotCommandScope() {}
+
+ /**
+ * @brief Scope type
+ */
+ std::string type;
+};
+}
+
+#endif //TGBOT_BOTCOMMANDSCOPE_H
diff --git a/include/tgbot/types/BotCommandScopeAllChatAdministrators.h b/include/tgbot/types/BotCommandScopeAllChatAdministrators.h
new file mode 100644
index 0000000..bc814bc
--- /dev/null
+++ b/include/tgbot/types/BotCommandScopeAllChatAdministrators.h
@@ -0,0 +1,27 @@
+#ifndef TGBOT_BOTCOMMANDSCOPEALLCHATADMINISTRATORS_H
+#define TGBOT_BOTCOMMANDSCOPEALLCHATADMINISTRATORS_H
+
+#include "tgbot/types/BotCommandScope.h"
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents the scope of bot commands, covering all group and supergroup chat administrators.
+ *
+ * @ingroup types
+ */
+class BotCommandScopeAllChatAdministrators : public BotCommandScope {
+public:
+ static const std::string TYPE;
+
+ typedef std::shared_ptr<BotCommandScopeAllChatAdministrators> Ptr;
+
+ BotCommandScopeAllChatAdministrators() {
+ this->type = TYPE;
+ }
+};
+}
+
+#endif //TGBOT_BOTCOMMANDSCOPEALLCHATADMINISTRATORS_H
diff --git a/include/tgbot/types/BotCommandScopeAllGroupChats.h b/include/tgbot/types/BotCommandScopeAllGroupChats.h
new file mode 100644
index 0000000..8b709d6
--- /dev/null
+++ b/include/tgbot/types/BotCommandScopeAllGroupChats.h
@@ -0,0 +1,27 @@
+#ifndef TGBOT_BOTCOMMANDSCOPEALLGROUPCHATS_H
+#define TGBOT_BOTCOMMANDSCOPEALLGROUPCHATS_H
+
+#include "tgbot/types/BotCommandScope.h"
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents the scope of bot commands, covering all group and supergroup chats.
+ *
+ * @ingroup types
+ */
+class BotCommandScopeAllGroupChats : public BotCommandScope {
+public:
+ static const std::string TYPE;
+
+ typedef std::shared_ptr<BotCommandScopeAllGroupChats> Ptr;
+
+ BotCommandScopeAllGroupChats() {
+ this->type = TYPE;
+ }
+};
+}
+
+#endif //TGBOT_BOTCOMMANDSCOPEALLGROUPCHATS_H
diff --git a/include/tgbot/types/BotCommandScopeAllPrivateChats.h b/include/tgbot/types/BotCommandScopeAllPrivateChats.h
new file mode 100644
index 0000000..b2e36b8
--- /dev/null
+++ b/include/tgbot/types/BotCommandScopeAllPrivateChats.h
@@ -0,0 +1,27 @@
+#ifndef TGBOT_BOTCOMMANDSCOPEALLPRIVATECHATS_H
+#define TGBOT_BOTCOMMANDSCOPEALLPRIVATECHATS_H
+
+#include "tgbot/types/BotCommandScope.h"
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents the scope of bot commands, covering all private chats.
+ *
+ * @ingroup types
+ */
+class BotCommandScopeAllPrivateChats : public BotCommandScope {
+public:
+ static const std::string TYPE;
+
+ typedef std::shared_ptr<BotCommandScopeAllPrivateChats> Ptr;
+
+ BotCommandScopeAllPrivateChats() {
+ this->type = TYPE;
+ }
+};
+}
+
+#endif //TGBOT_BOTCOMMANDSCOPEALLPRIVATECHATS_H
diff --git a/include/tgbot/types/BotCommandScopeChat.h b/include/tgbot/types/BotCommandScopeChat.h
new file mode 100644
index 0000000..fd36125
--- /dev/null
+++ b/include/tgbot/types/BotCommandScopeChat.h
@@ -0,0 +1,33 @@
+#ifndef TGBOT_BOTCOMMANDSCOPECHAT_H
+#define TGBOT_BOTCOMMANDSCOPECHAT_H
+
+#include "tgbot/types/BotCommandScope.h"
+
+#include <cstdint>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents the scope of bot commands, covering a specific chat.
+ *
+ * @ingroup types
+ */
+class BotCommandScopeChat : public BotCommandScope {
+public:
+ static const std::string TYPE;
+
+ typedef std::shared_ptr<BotCommandScopeChat> Ptr;
+
+ BotCommandScopeChat() {
+ this->type = TYPE;
+ }
+
+ /**
+ * @brief Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
+ */
+ std::int64_t chatId;
+};
+}
+
+#endif //TGBOT_BOTCOMMANDSCOPECHAT_H
diff --git a/include/tgbot/types/BotCommandScopeChatAdministrators.h b/include/tgbot/types/BotCommandScopeChatAdministrators.h
new file mode 100644
index 0000000..f046e31
--- /dev/null
+++ b/include/tgbot/types/BotCommandScopeChatAdministrators.h
@@ -0,0 +1,33 @@
+#ifndef TGBOT_BOTCOMMANDSCOPECHATADMINISTRATORS_H
+#define TGBOT_BOTCOMMANDSCOPECHATADMINISTRATORS_H
+
+#include "tgbot/types/BotCommandScope.h"
+
+#include <cstdint>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents the scope of bot commands, covering all administrators of a specific group or supergroup chat.
+ *
+ * @ingroup types
+ */
+class BotCommandScopeChatAdministrators : public BotCommandScope {
+public:
+ static const std::string TYPE;
+
+ typedef std::shared_ptr<BotCommandScopeChatAdministrators> Ptr;
+
+ BotCommandScopeChatAdministrators() {
+ this->type = TYPE;
+ }
+
+ /**
+ * @brief Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
+ */
+ std::int64_t chatId;
+};
+}
+
+#endif //TGBOT_BOTCOMMANDSCOPECHATADMINISTRATORS_H
diff --git a/include/tgbot/types/BotCommandScopeChatMember.h b/include/tgbot/types/BotCommandScopeChatMember.h
new file mode 100644
index 0000000..5beaee6
--- /dev/null
+++ b/include/tgbot/types/BotCommandScopeChatMember.h
@@ -0,0 +1,38 @@
+#ifndef TGBOT_BOTCOMMANDSCOPECHATMEMBER_H
+#define TGBOT_BOTCOMMANDSCOPECHATMEMBER_H
+
+#include "tgbot/types/BotCommandScope.h"
+
+#include <cstdint>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents the scope of bot commands, covering a specific member of a group or supergroup chat.
+ *
+ * @ingroup types
+ */
+class BotCommandScopeChatMember : public BotCommandScope {
+public:
+ static const std::string TYPE;
+
+ typedef std::shared_ptr<BotCommandScopeChatMember> Ptr;
+
+ BotCommandScopeChatMember() {
+ this->type = TYPE;
+ }
+
+ /**
+ * @brief Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
+ */
+ std::int64_t chatId;
+
+ /**
+ * @brief Unique identifier of the target user
+ */
+ std::int64_t userId;
+};
+}
+
+#endif //TGBOT_BOTCOMMANDSCOPECHATMEMBER_H
diff --git a/include/tgbot/types/BotCommandScopeDefault.h b/include/tgbot/types/BotCommandScopeDefault.h
new file mode 100644
index 0000000..76b8192
--- /dev/null
+++ b/include/tgbot/types/BotCommandScopeDefault.h
@@ -0,0 +1,28 @@
+#ifndef TGBOT_BOTCOMMANDSCOPEDEFAULT_H
+#define TGBOT_BOTCOMMANDSCOPEDEFAULT_H
+
+#include "tgbot/types/BotCommandScope.h"
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents the default scope of bot commands.
+ * Default commands are used if no commands with a narrower scope are specified for the user.
+ *
+ * @ingroup types
+ */
+class BotCommandScopeDefault : public BotCommandScope {
+public:
+ static const std::string TYPE;
+
+ typedef std::shared_ptr<BotCommandScopeDefault> Ptr;
+
+ BotCommandScopeDefault() {
+ this->type = TYPE;
+ }
+};
+}
+
+#endif //TGBOT_BOTCOMMANDSCOPEDEFAULT_H
diff --git a/include/tgbot/types/Chat.h b/include/tgbot/types/Chat.h
index ad2329e..24f7955 100644
--- a/include/tgbot/types/Chat.h
+++ b/include/tgbot/types/Chat.h
@@ -3,6 +3,7 @@
#include "tgbot/types/ChatPhoto.h"
#include "tgbot/types/ChatPermissions.h"
+#include "tgbot/types/ChatLocation.h"
#include <cstdint>
#include <string>
@@ -63,52 +64,93 @@ public:
/**
* @brief Optional. Chat photo.
- * Returned only in @ref Api::getChat.
+ * Returned only in Api::getChat.
*/
ChatPhoto::Ptr photo;
/**
+ * @brief Optional. Bio of the other party in a private chat.
+ * Returned only in Api::getChat.
+ */
+ std::string bio;
+
+ /**
+ * @brief Optional. True, if privacy settings of the other party in the private chat allows to use tg://user?id=<user_id> links only in chats with the user.
+ * Returned only in Api::getChat.
+ */
+ bool hasPrivateForwards;
+
+ /**
* @brief Optional. Description, for groups, supergroups and channel chats.
- * Returned only in @ref Api::getChat.
+ * Returned only in Api::getChat.
*/
std::string description;
/**
* @brief Optional. Chat invite link, for groups, supergroups and channel chats.
- * Each administrator in a chat generates their own invite links, so the bot must first generate the link using @ref Api::exportChatInviteLink.
- * Returned only in @ref Api::getChat.
+ * Each administrator in a chat generates their own invite links, so the bot must first generate the link using Api::exportChatInviteLink.
+ * Returned only in Api::getChat.
*/
std::string inviteLink;
/**
* @brief Optional. Pinned message, for groups, supergroups and channels.
- * Returned only in @ref Api::getChat.
+ * Returned only in Api::getChat.
*/
std::shared_ptr<Message> pinnedMessage;
/**
* @brief Optional. Default chat member permissions, for groups and supergroups.
- * Returned only in @ref Api::getChat.
+ * Returned only in Api::getChat.
*/
ChatPermissions::Ptr permissions;
/**
* @brief Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user.
- * Returned only in @ref Api::getChat.
+ * Returned only in Api::getChat.
*/
std::int32_t slowModeDelay;
/**
+ * @brief Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds.
+ * Returned only in Api::getChat.
+ */
+ std::int32_t messageAutoDeleteTime;
+
+ /**
+ * @brief Optional. True, if messages from the chat can't be forwarded to other chats.
+ * Returned only in Api::getChat.
+ */
+ bool hasProtectedContent;
+
+ /**
* @brief Optional. For supergroups, name of group sticker set.
- * Returned only in @ref Api::getChat.
+ * Returned only in Api::getChat.
*/
std::string stickerSetName;
/**
* @brief Optional. True, if the bot can change the group sticker set.
- * Returned only in @ref Api::getChat.
+ * Returned only in Api::getChat.
*/
bool canSetStickerSet;
+
+ /**
+ * @brief Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats.
+ *
+ * This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it.
+ * But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
+ *
+ * Returned only in Api::getChat.
+ */
+ std::int64_t linkedChatId;
+
+ /**
+ * @brief Optional. For supergroups, the location to which the supergroup is connected.
+ *
+ * Returned only in Api::getChat.
+ */
+ ChatLocation::Ptr location;
};
}
diff --git a/include/tgbot/types/ChatInviteLink.h b/include/tgbot/types/ChatInviteLink.h
new file mode 100644
index 0000000..b0fb840
--- /dev/null
+++ b/include/tgbot/types/ChatInviteLink.h
@@ -0,0 +1,70 @@
+#ifndef TGBOT_CPP_CHATINVITELINK_H
+#define TGBOT_CPP_CHATINVITELINK_H
+
+#include "tgbot/types/User.h"
+
+#include <cstdint>
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief Represents an invite link for a chat.
+ *
+ * @ingroup types
+ */
+class ChatInviteLink {
+
+public:
+ typedef std::shared_ptr<ChatInviteLink> Ptr;
+
+ /**
+ * @brief The invite link.
+ * If the link was created by another chat administrator, then the second part of the link will be replaced with “…”.
+ */
+ std::string inviteLink;
+
+ /**
+ * @brief Creator of the link
+ */
+ User::Ptr creator;
+
+ /**
+ * @brief True, if users joining the chat via the link need to be approved by chat administrators
+ */
+ bool createsJoinRequest;
+
+ /**
+ * @brief True, if the link is primary
+ */
+ bool isPrimary;
+
+ /**
+ * @brief True, if the link is revoked
+ */
+ bool isRevoked;
+
+ /**
+ * @brief Optional. Invite link name
+ */
+ std::string name;
+
+ /**
+ * @brief Optional. Point in time (Unix timestamp) when the link will expire or has been expired
+ */
+ std::uint32_t expireDate;
+
+ /**
+ * @brief Optional. Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
+ */
+ std::uint32_t memberLimit;
+
+ /**
+ * @brief Optional. Number of pending join requests created using this link
+ */
+ std::uint32_t pendingJoinRequestCount;
+};
+}
+
+#endif //TGBOT_CPP_CHATINVITELINK_H
diff --git a/include/tgbot/types/ChatJoinRequest.h b/include/tgbot/types/ChatJoinRequest.h
new file mode 100644
index 0000000..bcd3e4e
--- /dev/null
+++ b/include/tgbot/types/ChatJoinRequest.h
@@ -0,0 +1,51 @@
+#ifndef TGBOT_CPP_CHATJOINREQUEST_H
+#define TGBOT_CPP_CHATJOINREQUEST_H
+
+#include "tgbot/types/Chat.h"
+#include "tgbot/types/User.h"
+#include "tgbot/types/ChatInviteLink.h"
+
+#include <cstdint>
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief Represents a join request sent to a chat.
+ *
+ * @ingroup types
+ */
+class ChatJoinRequest {
+
+public:
+ typedef std::shared_ptr<ChatJoinRequest> Ptr;
+
+ /**
+ * @brief Chat to which the request was sent
+ */
+ Chat::Ptr chat;
+
+ /**
+ * @brief User that sent the join request
+ */
+ User::Ptr from;
+
+ /**
+ * @brief Date the request was sent in Unix time
+ */
+ std::int32_t date;
+
+ /**
+ * @brief Optional. Bio of the user.
+ */
+ std::string bio;
+
+ /**
+ * @brief Optional. Chat invite link that was used by the user to send the join request
+ */
+ ChatInviteLink::Ptr inviteLink;
+};
+}
+
+#endif //TGBOT_CPP_CHATJOINREQUEST_H
diff --git a/include/tgbot/types/ChatLocation.h b/include/tgbot/types/ChatLocation.h
new file mode 100644
index 0000000..0abbba0
--- /dev/null
+++ b/include/tgbot/types/ChatLocation.h
@@ -0,0 +1,33 @@
+#ifndef TGBOT_CPP_CHATLOCATION_H
+#define TGBOT_CPP_CHATLOCATION_H
+
+#include "tgbot/types/Location.h"
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents a location to which a chat is connected.
+ *
+ * @ingroup types
+ */
+class ChatLocation {
+
+public:
+ typedef std::shared_ptr<ChatLocation> Ptr;
+
+ /**
+ * @brief The location to which the supergroup is connected.
+ * Can't be a live location.
+ */
+ Location::Ptr location;
+
+ /**
+ * @brief Location address; 1-64 characters, as defined by the chat owner
+ */
+ std::string address;
+};
+}
+
+#endif //TGBOT_CPP_CHATLOCATION_H
diff --git a/include/tgbot/types/ChatMember.h b/include/tgbot/types/ChatMember.h
index 5ec07a5..183cb8b 100644
--- a/include/tgbot/types/ChatMember.h
+++ b/include/tgbot/types/ChatMember.h
@@ -3,14 +3,15 @@
#include "tgbot/types/User.h"
-#include <cstdint>
#include <memory>
#include <string>
namespace TgBot {
/**
- * @brief This object contains information about one member of the chat.
+ * @brief This abstract class is base of all chat members.
+ *
+ * This object contains information about one member of a chat.
*
* @ingroup types
*/
@@ -19,101 +20,19 @@ class ChatMember {
public:
typedef std::shared_ptr<ChatMember> Ptr;
- /**
- * @brief Information about the user
- */
- User::Ptr user;
-
- /**
- * @brief The member's status in the chat.
- * Can be “creator”, “administrator”, “member”, “restricted”, “left” or “kicked”
- */
- std::string status;
-
- /**
- * @brief Optional. Owner and administrators only. Custom title for this user
- */
- std::string customTitle;
-
- /**
- * @brief Optional. Restricted and kicked only. Date when restrictions will be lifted for this user; unix time
- */
- std::uint64_t untilDate;
+ ChatMember() {}
- /**
- * @brief Optional. Administrators only. True, if the bot is allowed to edit administrator privileges of that user
- */
- bool canBeEdited;
-
- /**
- * @brief Optional. Administrators only. True, if the administrator can post in the channel; channels only
- */
- bool canPostMessages;
-
- /**
- * @brief Optional. Administrators only. True, if the administrator can edit messages of other users and can pin messages; channels only
- */
- bool canEditMessages;
-
- /**
- * @brief Optional. Administrators only. True, if the administrator can delete messages of other users
- */
- bool canDeleteMessages;
-
- /**
- * @brief Optional. Administrators only. True, if the administrator can restrict, ban or unban chat members
- */
- bool canRestrictMembers;
+ virtual ~ChatMember() {}
/**
- * @brief Optional. Administrators only. True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user)
+ * @brief The member's status in the chat
*/
- bool canPromoteMembers;
-
- /**
- * @brief Optional. Administrators and restricted only. True, if the user is allowed to change the chat title, photo and other settings
- */
- bool canChangeInfo;
-
- /**
- * @brief Optional. Administrators and restricted only. True, if the user is allowed to invite new users to the chat
- */
- bool canInviteUsers;
-
- /**
- * @brief Optional. Administrators and restricted only. True, if the user is allowed to pin messages; groups and supergroups only
- */
- bool canPinMessages;
-
- /**
- * @brief Optional. Restricted only. True, if the user is a member of the chat at the moment of the request
- */
- bool isMember;
-
- /**
- * @brief Optional. Restricted only. True, if the user is allowed to send text messages, contacts, locations and venues
- */
- bool canSendMessages;
-
- /**
- * @brief Optional. Restricted only. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes
- */
- bool canSendMediaMessages;
-
- /**
- * @brief Optional. Restricted only. True, if the user is allowed to send polls
- */
- bool canSendPolls;
-
- /**
- * @brief Optional. Restricted only. True, if the user is allowed to send animations, games, stickers and use inline bots
- */
- bool canSendOtherMessages;
+ std::string status;
/**
- * @brief Optional. Restricted only. True, if the user is allowed to add web page previews to their messages
+ * @brief Information about the user
*/
- bool canAddWebPagePreviews;
+ User::Ptr user;
};
}
diff --git a/include/tgbot/types/ChatMemberAdministrator.h b/include/tgbot/types/ChatMemberAdministrator.h
new file mode 100644
index 0000000..1d5ad6f
--- /dev/null
+++ b/include/tgbot/types/ChatMemberAdministrator.h
@@ -0,0 +1,94 @@
+#ifndef TGBOT_CHATMEMBERADMINISTRATOR_H
+#define TGBOT_CHATMEMBERADMINISTRATOR_H
+
+#include "tgbot/types/ChatMember.h"
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief Represents a chat member that has some additional privileges.
+ *
+ * @ingroup types
+ */
+class ChatMemberAdministrator : public ChatMember {
+public:
+ static const std::string STATUS;
+
+ typedef std::shared_ptr<ChatMemberAdministrator> Ptr;
+
+ ChatMemberAdministrator() {
+ this->status = STATUS;
+ }
+
+ /**
+ * @brief True, if the bot is allowed to edit administrator privileges of that user
+ */
+ bool canBeEdited;
+
+ /**
+ * @brief Custom title for this user
+ */
+ std::string customTitle;
+
+ /**
+ * @brief True, if the user's presence in the chat is hidden
+ */
+ bool isAnonymous;
+
+ /**
+ * @brief True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode.
+ * Implied by any other administrator privilege
+ */
+ bool canManageChat;
+
+ /**
+ * @brief True, if the administrator can post in the channel; channels only
+ */
+ bool canPostMessages;
+
+ /**
+ * @brief True, if the administrator can edit messages of other users and can pin messages; channels only
+ */
+ bool canEditMessages;
+
+ /**
+ * @brief True, if the administrator can delete messages of other users
+ */
+ bool canDeleteMessages;
+
+ /**
+ * @brief True, if the administrator can manage voice chats
+ */
+ bool canManageVoiceChats;
+
+ /**
+ * @brief True, if the administrator can restrict, ban or unban chat members
+ */
+ bool canRestrictMembers;
+
+ /**
+ * @brief True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user)
+ */
+ bool canPromoteMembers;
+
+ /**
+ * @brief True, if the user is allowed to change the chat title, photo and other settings
+ */
+ bool canChangeInfo;
+
+ /**
+ * @brief True, if the user is allowed to invite new users to the chat
+ */
+ bool canInviteUsers;
+
+ /**
+ * @brief True, if the user is allowed to pin messages; groups and supergroups only
+ */
+ bool canPinMessages;
+};
+}
+
+#endif //TGBOT_CHATMEMBERADMINISTRATOR_H
diff --git a/include/tgbot/types/ChatMemberBanned.h b/include/tgbot/types/ChatMemberBanned.h
new file mode 100644
index 0000000..c54385e
--- /dev/null
+++ b/include/tgbot/types/ChatMemberBanned.h
@@ -0,0 +1,33 @@
+#ifndef TGBOT_CHATMEMBERBANNED_H
+#define TGBOT_CHATMEMBERBANNED_H
+
+#include "tgbot/types/ChatMember.h"
+
+#include <cstdint>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents a chat member that was banned in the chat and can't return to the chat or view chat messages.
+ *
+ * @ingroup types
+ */
+class ChatMemberBanned : public ChatMember {
+public:
+ static const std::string STATUS;
+
+ typedef std::shared_ptr<ChatMemberBanned> Ptr;
+
+ ChatMemberBanned() {
+ this->status = STATUS;
+ }
+
+ /**
+ * @brief Date when restrictions will be lifted for this user; unix time
+ */
+ std::int32_t untilDate;
+};
+}
+
+#endif //TGBOT_CHATMEMBERBANNED_H
diff --git a/include/tgbot/types/ChatMemberLeft.h b/include/tgbot/types/ChatMemberLeft.h
new file mode 100644
index 0000000..3431aca
--- /dev/null
+++ b/include/tgbot/types/ChatMemberLeft.h
@@ -0,0 +1,27 @@
+#ifndef TGBOT_CHATMEMBERLEFT_H
+#define TGBOT_CHATMEMBERLEFT_H
+
+#include "tgbot/types/ChatMember.h"
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents a chat member that isn't currently a member of the chat, but may join it themselves.
+ *
+ * @ingroup types
+ */
+class ChatMemberLeft : public ChatMember {
+public:
+ static const std::string STATUS;
+
+ typedef std::shared_ptr<ChatMemberLeft> Ptr;
+
+ ChatMemberLeft() {
+ this->status = STATUS;
+ }
+};
+}
+
+#endif //TGBOT_CHATMEMBERLEFT_H
diff --git a/include/tgbot/types/ChatMemberMember.h b/include/tgbot/types/ChatMemberMember.h
new file mode 100644
index 0000000..6bdccd7
--- /dev/null
+++ b/include/tgbot/types/ChatMemberMember.h
@@ -0,0 +1,27 @@
+#ifndef TGBOT_CHATMEMBERMEMBER_H
+#define TGBOT_CHATMEMBERMEMBER_H
+
+#include "tgbot/types/ChatMember.h"
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents a chat member that has no additional privileges or restrictions.
+ *
+ * @ingroup types
+ */
+class ChatMemberMember : public ChatMember {
+public:
+ static const std::string STATUS;
+
+ typedef std::shared_ptr<ChatMemberMember> Ptr;
+
+ ChatMemberMember() {
+ this->status = STATUS;
+ }
+};
+}
+
+#endif //TGBOT_CHATMEMBERMEMBER_H
diff --git a/include/tgbot/types/ChatMemberOwner.h b/include/tgbot/types/ChatMemberOwner.h
new file mode 100644
index 0000000..2881a33
--- /dev/null
+++ b/include/tgbot/types/ChatMemberOwner.h
@@ -0,0 +1,38 @@
+#ifndef TGBOT_CHATMEMBEROWNER_H
+#define TGBOT_CHATMEMBEROWNER_H
+
+#include "tgbot/types/ChatMember.h"
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief Represents a chat member that owns the chat and has all administrator privileges.
+ *
+ * @ingroup types
+ */
+class ChatMemberOwner : public ChatMember {
+public:
+ static const std::string STATUS;
+
+ typedef std::shared_ptr<ChatMemberOwner> Ptr;
+
+ ChatMemberOwner() {
+ this->status = STATUS;
+ }
+
+ /**
+ * @brief Custom title for this user
+ */
+ std::string customTitle;
+
+ /**
+ * @brief True, if the user's presence in the chat is hidden
+ */
+ bool isAnonymous;
+};
+}
+
+#endif //TGBOT_CHATMEMBEROWNER_H
diff --git a/include/tgbot/types/ChatMemberRestricted.h b/include/tgbot/types/ChatMemberRestricted.h
new file mode 100644
index 0000000..76a9cd7
--- /dev/null
+++ b/include/tgbot/types/ChatMemberRestricted.h
@@ -0,0 +1,79 @@
+#ifndef TGBOT_CHATMEMBERRESTRICTED_H
+#define TGBOT_CHATMEMBERRESTRICTED_H
+
+#include "tgbot/types/ChatMember.h"
+
+#include <cstdint>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents a chat member that is under certain restrictions in the chat.
+ * Supergroups only.
+ *
+ * @ingroup types
+ */
+class ChatMemberRestricted : public ChatMember {
+public:
+ static const std::string STATUS;
+
+ typedef std::shared_ptr<ChatMemberRestricted> Ptr;
+
+ ChatMemberRestricted() {
+ this->status = STATUS;
+ }
+
+ /**
+ * @brief True, if the user is a member of the chat at the moment of the request
+ */
+ bool isMember;
+
+ /**
+ * @brief True, if the user is allowed to change the chat title, photo and other settings
+ */
+ bool canChangeInfo;
+
+ /**
+ * @brief True, if the user is allowed to invite new users to the chat
+ */
+ bool canInviteUsers;
+
+ /**
+ * @brief True, if the user is allowed to pin messages; groups and supergroups only
+ */
+ bool canPinMessages;
+
+ /**
+ * @brief True, if the user is allowed to send text messages, contacts, locations and venues
+ */
+ bool canSendMessages;
+
+ /**
+ * @brief True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes
+ */
+ bool canSendMediaMessages;
+
+ /**
+ * @brief True, if the user is allowed to send polls
+ */
+ bool canSendPolls;
+
+ /**
+ * @brief True, if the user is allowed to send animations, games, stickers and use inline bots
+ */
+ bool canSendOtherMessages;
+
+ /**
+ * @brief True, if the user is allowed to add web page previews to their messages
+ */
+ bool canAddWebPagePreviews;
+
+ /**
+ * @brief Date when restrictions will be lifted for this user; unix time
+ */
+ std::int32_t untilDate;
+};
+}
+
+#endif //TGBOT_CHATMEMBERRESTRICTED_H
diff --git a/include/tgbot/types/ChatMemberUpdated.h b/include/tgbot/types/ChatMemberUpdated.h
new file mode 100644
index 0000000..9d8ce2b
--- /dev/null
+++ b/include/tgbot/types/ChatMemberUpdated.h
@@ -0,0 +1,55 @@
+#ifndef TGBOT_CPP_CHATMEMBERUPDATED_H
+#define TGBOT_CPP_CHATMEMBERUPDATED_H
+
+#include "tgbot/types/Chat.h"
+#include "tgbot/types/User.h"
+#include "tgbot/types/ChatMember.h"
+#include "tgbot/types/ChatInviteLink.h"
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents changes in the status of a chat member.
+ *
+ * @ingroup types
+ */
+class ChatMemberUpdated {
+
+public:
+ typedef std::shared_ptr<ChatMemberUpdated> Ptr;
+
+ /**
+ * @brief Chat the user belongs to
+ */
+ Chat::Ptr chat;
+
+ /**
+ * @brief Performer of the action, which resulted in the change
+ */
+ User::Ptr from;
+
+ /**
+ * @brief Date the change was done in Unix time
+ */
+ std::uint32_t date;
+
+ /**
+ * @brief Previous information about the chat member
+ */
+ ChatMember::Ptr oldChatMember;
+
+ /**
+ * @brief New information about the chat member
+ */
+ ChatMember::Ptr newChatMember;
+
+ /**
+ * @brief Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only.
+ */
+ ChatInviteLink::Ptr inviteLink;
+};
+}
+
+#endif //TGBOT_CPP_CHATMEMBERUPDATED_H
diff --git a/include/tgbot/types/ChatPhoto.h b/include/tgbot/types/ChatPhoto.h
index 8ee25f1..30c702e 100644
--- a/include/tgbot/types/ChatPhoto.h
+++ b/include/tgbot/types/ChatPhoto.h
@@ -18,7 +18,7 @@ public:
/**
* @brief File identifier of small (160x160) chat photo.
- * This file_id can be used only for photo download and only for as long as the photo is not changed.
+ * This fileId can be used only for photo download and only for as long as the photo is not changed.
*/
std::string smallFileId;
@@ -30,7 +30,7 @@ public:
/**
* @brief File identifier of big (640x640) chat photo.
- * This file_id can be used only for photo download and only for as long as the photo is not changed.
+ * This fileId can be used only for photo download and only for as long as the photo is not changed.
*/
std::string bigFileId;
diff --git a/include/tgbot/types/Dice.h b/include/tgbot/types/Dice.h
index 4c2a68e..58a97f5 100644
--- a/include/tgbot/types/Dice.h
+++ b/include/tgbot/types/Dice.h
@@ -21,9 +21,9 @@ public:
std::string emoji;
/**
- * @brief Value of the dice, 1-6 for “🎲” and “🎯” base emoji, 1-5 for “🏀” base emoji
+ * @brief Value of the dice, 1-6 for “🎲”, “🎯” and “🎳” base emoji, 1-5 for “🏀” and “⚽” base emoji, 1-64 for “🎰” base emoji
*/
- std::int8_t value;
+ std::int32_t value;
};
}
diff --git a/include/tgbot/types/ForceReply.h b/include/tgbot/types/ForceReply.h
index bf4fe0a..83a2d0b 100644
--- a/include/tgbot/types/ForceReply.h
+++ b/include/tgbot/types/ForceReply.h
@@ -4,16 +4,25 @@
#include "tgbot/types/GenericReply.h"
#include <memory>
+#include <string>
namespace TgBot {
/**
- * @brief Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot‘s message and tapped ’Reply'). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode.
+ * @brief Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot's message and tapped 'Reply').
+ * This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode.
*
- * Example: A poll bot for groups runs in privacy mode (only receives commands, replies to its messages and mentions). There could be two ways to create a new poll:
- * Explain the user how to send a command with parameters (e.g. /newpoll question answer1 answer2). May be appealing for hardcore users but lacks modern day polish.
- * Guide the user through a step-by-step process. ‘Please send me your question’, ‘Cool, now let’s add the first answer option‘, ’Great. Keep adding answer options, then send /done when you‘re ready’.
- * The last option is definitely more attractive. And if you use ForceReply in your bot‘s questions, it will receive the user’s answers even if it only receives replies, commands and mentions — without any extra work for the user.
+ * Example: A poll bot for groups runs in privacy mode (only receives commands, replies to its messages and mentions).
+ * There could be two ways to create a new poll:
+ *
+ * Explain the user how to send a command with parameters (e.g. /newpoll question answer1 answer2).
+ * May be appealing for hardcore users but lacks modern day polish.
+ *
+ * Guide the user through a step-by-step process.
+ * 'Please send me your question', 'Cool, now let's add the first answer option', 'Great. Keep adding answer options, then send /done when you're ready'.
+ *
+ * The last option is definitely more attractive.
+ * And if you use ForceReply in your bot's questions, it will receive the user's answers even if it only receives replies, commands and mentions — without any extra work for the user.
*
* @ingroup types
*/
@@ -23,16 +32,21 @@ public:
typedef std::shared_ptr<ForceReply> Ptr;
/**
- * @brief Shows reply interface to the user, as if they manually selected the bot‘s message and tapped ’Reply'
+ * @brief Shows reply interface to the user, as if they manually selected the bot's message and tapped 'Reply'
*/
const bool forceReply = true;
/**
- * @brief Optional. Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
+ * @brief Optional. The placeholder to be shown in the input field when the reply is active; 1-64 characters
+ */
+ std::string inputFieldPlaceholder;
+
+ /**
+ * @brief Optional. Use this parameter if you want to force reply from specific users only.
+ * Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has replyToMessageId), sender of the original message.
*/
bool selective = false;
};
-
}
#endif //TGBOT_CPP_FORCEREPLY_H
diff --git a/include/tgbot/types/InlineQuery.h b/include/tgbot/types/InlineQuery.h
index e50f6d6..ad04b8f 100644
--- a/include/tgbot/types/InlineQuery.h
+++ b/include/tgbot/types/InlineQuery.h
@@ -11,6 +11,7 @@ namespace TgBot {
/**
* @brief This object represents an incoming inline query.
+ * When the user sends an empty query, your bot could return some default or trending results.
*
* @ingroup types
*/
@@ -19,31 +20,37 @@ public:
typedef std::shared_ptr<InlineQuery> Ptr;
/**
- * @brief Unique query identifier.
+ * @brief Unique identifier for this query
*/
std::string id;
/**
- * @brief Sender.
+ * @brief Sender
*/
User::Ptr from;
/**
- * @brief Optional. Sender location, only for bots that request user location
+ * @brief Text of the query (up to 256 characters)
*/
- Location::Ptr location;
+ std::string query;
/**
- * @brief Text of the query.
+ * @brief Offset of the results to be returned, can be controlled by the bot
*/
- std::string query;
+ std::string offset;
/**
- * @brief Offset of the results to be returned.
+ * @brief Optional. Type of the chat, from which the inline query was sent.
+ * Can be either “sender” for a private chat with the inline query sender, “private”, “group”, “supergroup”, or “channel”.
+ * The chat type should be always known for requests sent from official clients and most third-party clients, unless the request was sent from a secret chat
*/
- std::string offset;
-};
+ std::string chatType;
+ /**
+ * @brief Optional. Sender location, only for bots that request user location
+ */
+ Location::Ptr location;
+};
}
#endif //TGBOT_INLINEQUERY_H
diff --git a/include/tgbot/types/InlineQueryResult.h b/include/tgbot/types/InlineQueryResult.h
index 5674015..dec086e 100644
--- a/include/tgbot/types/InlineQueryResult.h
+++ b/include/tgbot/types/InlineQueryResult.h
@@ -2,7 +2,6 @@
#define TGBOT_INLINEQUERYRESULT_H
#include "tgbot/types/InlineKeyboardMarkup.h"
-#include "tgbot/types/InputMessageContent.h"
#include <memory>
#include <string>
@@ -11,6 +10,8 @@ namespace TgBot {
/**
* @brief This abstract class is base of all inline query results.
+ *
+ * This object represents one result of an inline query.
*
* @ingroup types
*/
@@ -33,33 +34,9 @@ public:
std::string id;
/**
- * @brief Requred, optional or missing. See description of derived classes.
- * Title for the result
- */
- std::string title;
-
- /**
- * @brief Optional or missing. See description of derived classes.
- * Caption of the file to be sent, 0-1024 characters after entities parsing
- */
- std::string caption;
-
- /**
- * @brief Optional or missing. See description of derived classes.
- * Mode for parsing entities in the caption.
- */
- std::string parseMode;
-
- /**
* @brief Optional. Inline keyboard attached to the message
*/
InlineKeyboardMarkup::Ptr replyMarkup;
-
- /**
- * @brief Requred, optional or missing. See description of derived classes.
- * Content of the message to be sent
- */
- InputMessageContent::Ptr inputMessageContent;
};
}
diff --git a/include/tgbot/types/InlineQueryResultArticle.h b/include/tgbot/types/InlineQueryResultArticle.h
index 5c51f3d..509a8d2 100644
--- a/include/tgbot/types/InlineQueryResultArticle.h
+++ b/include/tgbot/types/InlineQueryResultArticle.h
@@ -2,6 +2,7 @@
#define TGBOT_INLINEQUERYRESULTARTICLE_H
#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/InputMessageContent.h"
#include <cstdint>
#include <string>
@@ -22,13 +23,20 @@ public:
InlineQueryResultArticle() {
this->type = TYPE;
- this->hideUrl = false;
- this->thumbHeight = 0;
- this->thumbWidth = 0;
}
/**
- * @brief Optional. URL of the result.
+ * @brief Title of the result
+ */
+ std::string title;
+
+ /**
+ * @brief Content of the message to be sent
+ */
+ InputMessageContent::Ptr inputMessageContent;
+
+ /**
+ * @brief Optional. URL of the result
*/
std::string url;
@@ -38,7 +46,7 @@ public:
bool hideUrl;
/**
- * @brief Optional. Short description of the result.
+ * @brief Optional. Short description of the result
*/
std::string description;
@@ -48,12 +56,12 @@ public:
std::string thumbUrl;
/**
- * @brief Optional. Thumbnail width.
+ * @brief Optional. Thumbnail width
*/
std::int32_t thumbWidth;
/**
- * @brief Optinal. Thumbnail height
+ * @brief Optional. Thumbnail height
*/
std::int32_t thumbHeight;
};
diff --git a/include/tgbot/types/InlineQueryResultAudio.h b/include/tgbot/types/InlineQueryResultAudio.h
index dfee389..7925c28 100644
--- a/include/tgbot/types/InlineQueryResultAudio.h
+++ b/include/tgbot/types/InlineQueryResultAudio.h
@@ -2,6 +2,8 @@
#define TGBOT_INLINEQUERYRESULTAUDIO_H
#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/MessageEntity.h"
+#include "tgbot/types/InputMessageContent.h"
#include <cstdint>
#include <string>
@@ -10,7 +12,9 @@
namespace TgBot {
/**
- * @brief Represents a link to an mp3 audio file.
+ * @brief Represents a link to an MP3 audio file.
+ * By default, this audio file will be sent by the user.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the audio.
*
* @ingroup types
*/
@@ -22,7 +26,6 @@ public:
InlineQueryResultAudio() {
this->type = TYPE;
- this->audioDuration = 0;
}
/**
@@ -31,6 +34,27 @@ public:
std::string audioUrl;
/**
+ * @brief Title
+ */
+ std::string title;
+
+ /**
+ * @brief Optional. Caption, 0-1024 characters after entities parsing
+ */
+ std::string caption;
+
+ /**
+ * @brief Optional. Mode for parsing entities in the audio caption.
+ * See https://core.telegram.org/bots/api#formatting-options for more details.
+ */
+ std::string parseMode;
+
+ /**
+ * @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ */
+ std::vector<MessageEntity::Ptr> captionEntities;
+
+ /**
* @brief Optional. Performer
*/
std::string performer;
@@ -39,6 +63,11 @@ public:
* @brief Optional. Audio duration in seconds
*/
std::int32_t audioDuration;
+
+ /**
+ * @brief Optional. Content of the message to be sent instead of the audio
+ */
+ InputMessageContent::Ptr inputMessageContent;
};
}
diff --git a/include/tgbot/types/InlineQueryResultCachedAudio.h b/include/tgbot/types/InlineQueryResultCachedAudio.h
index c157226..d26534b 100644
--- a/include/tgbot/types/InlineQueryResultCachedAudio.h
+++ b/include/tgbot/types/InlineQueryResultCachedAudio.h
@@ -2,14 +2,19 @@
#define TGBOT_INLINEQUERYRESULTCACHEDAUDIO_H
#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/MessageEntity.h"
+#include "tgbot/types/InputMessageContent.h"
#include <string>
#include <memory>
+#include <vector>
namespace TgBot {
/**
- * @brief Represents a link to an mp3 audio file stored on the Telegram servers.
+ * @brief Represents a link to an MP3 audio file stored on the Telegram servers.
+ * By default, this audio file will be sent by the user.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the audio.
*
* @ingroup types
*/
@@ -28,6 +33,26 @@ public:
*/
std::string audioFileId;
+ /**
+ * @brief Optional. Caption, 0-1024 characters after entities parsing
+ */
+ std::string caption;
+
+ /**
+ * @brief Optional. Mode for parsing entities in the audio caption.
+ * See https://core.telegram.org/bots/api#formatting-options for more details.
+ */
+ std::string parseMode;
+
+ /**
+ * @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ */
+ std::vector<MessageEntity::Ptr> captionEntities;
+
+ /**
+ * @brief Optional. Content of the message to be sent instead of the audio
+ */
+ InputMessageContent::Ptr inputMessageContent;
};
}
diff --git a/include/tgbot/types/InlineQueryResultCachedDocument.h b/include/tgbot/types/InlineQueryResultCachedDocument.h
index 24bb2f3..4b3b42f 100644
--- a/include/tgbot/types/InlineQueryResultCachedDocument.h
+++ b/include/tgbot/types/InlineQueryResultCachedDocument.h
@@ -2,14 +2,19 @@
#define TGBOT_INLINEQUERYRESULTCACHEDDOCUMENT_H
#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/MessageEntity.h"
+#include "tgbot/types/InputMessageContent.h"
#include <string>
#include <memory>
+#include <vector>
namespace TgBot {
/**
* @brief Represents a link to a file stored on the Telegram servers.
+ * By default, this file will be sent by the user with an optional caption.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the file.
*
* @ingroup types
*/
@@ -24,6 +29,11 @@ public:
}
/**
+ * @brief Title for the result
+ */
+ std::string title;
+
+ /**
* @brief A valid file identifier for the file
*/
std::string documentFileId;
@@ -32,6 +42,27 @@ public:
* @brief Optional. Short description of the result
*/
std::string description;
+
+ /**
+ * @brief Optional. Caption of the document to be sent, 0-1024 characters after entities parsing
+ */
+ std::string caption;
+
+ /**
+ * @brief Optional. Mode for parsing entities in the document caption.
+ * See https://core.telegram.org/bots/api#formatting-options for more details.
+ */
+ std::string parseMode;
+
+ /**
+ * @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ */
+ std::vector<MessageEntity::Ptr> captionEntities;
+
+ /**
+ * @brief Optional. Content of the message to be sent instead of the file
+ */
+ InputMessageContent::Ptr inputMessageContent;
};
}
diff --git a/include/tgbot/types/InlineQueryResultCachedGif.h b/include/tgbot/types/InlineQueryResultCachedGif.h
index 23ec84a..b75ca39 100644
--- a/include/tgbot/types/InlineQueryResultCachedGif.h
+++ b/include/tgbot/types/InlineQueryResultCachedGif.h
@@ -2,14 +2,19 @@
#define TGBOT_INLINEQUERYRESULTCACHEDGIF_H
#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/MessageEntity.h"
+#include "tgbot/types/InputMessageContent.h"
#include <string>
#include <memory>
+#include <vector>
namespace TgBot {
/**
* @brief Represents a link to an animated GIF file stored on the Telegram servers.
+ * By default, this animated GIF file will be sent by the user with an optional caption.
+ * Alternatively, you can use inputMessageContent to send a message with specified content instead of the animation.
*
* @ingroup types
*/
@@ -28,6 +33,31 @@ public:
*/
std::string gifFileId;
+ /**
+ * @brief Optional. Title for the result
+ */
+ std::string title;
+
+ /**
+ * @brief Optional. Caption of the GIF file to be sent, 0-1024 characters after entities parsing
+ */
+ std::string caption;
+
+ /**
+ * @brief Optional. Mode for parsing entities in the caption.
+ * See https://core.telegram.org/bots/api#formatting-options for more details.
+ */
+ std::string parseMode;
+
+ /**
+ * @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ */
+ std::vector<MessageEntity::Ptr> captionEntities;
+
+ /**
+ * @brief Optional. Content of the message to be sent instead of the GIF animation
+ */
+ InputMessageContent::Ptr inputMessageContent;
};
}
diff --git a/include/tgbot/types/InlineQueryResultCachedMpeg4Gif.h b/include/tgbot/types/InlineQueryResultCachedMpeg4Gif.h
index 19a63a8..91bc4ae 100644
--- a/include/tgbot/types/InlineQueryResultCachedMpeg4Gif.h
+++ b/include/tgbot/types/InlineQueryResultCachedMpeg4Gif.h
@@ -2,14 +2,19 @@
#define TGBOT_INLINEQUERYRESULTCACHEDMPEG4GIF_H
#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/MessageEntity.h"
+#include "tgbot/types/InputMessageContent.h"
#include <string>
#include <memory>
+#include <vector>
namespace TgBot {
/**
* @brief Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers.
+ * By default, this animated MPEG-4 file will be sent by the user with an optional caption.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the animation.
*
* @ingroup types
*/
@@ -28,6 +33,31 @@ public:
*/
std::string mpeg4FileId;
+ /**
+ * @brief Optional. Title for the result
+ */
+ std::string title;
+
+ /**
+ * @brief Optional. Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing
+ */
+ std::string caption;
+
+ /**
+ * @brief Optional. Mode for parsing entities in the caption.
+ * See https://core.telegram.org/bots/api#formatting-options for more details.
+ */
+ std::string parseMode;
+
+ /**
+ * @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ */
+ std::vector<MessageEntity::Ptr> captionEntities;
+
+ /**
+ * @brief Optional. Content of the message to be sent instead of the video animation
+ */
+ InputMessageContent::Ptr inputMessageContent;
};
}
diff --git a/include/tgbot/types/InlineQueryResultCachedPhoto.h b/include/tgbot/types/InlineQueryResultCachedPhoto.h
index ba32314..8ab23e8 100644
--- a/include/tgbot/types/InlineQueryResultCachedPhoto.h
+++ b/include/tgbot/types/InlineQueryResultCachedPhoto.h
@@ -2,14 +2,19 @@
#define TGBOT_INLINEQUERYRESULTCACHEDPHOTO_H
#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/MessageEntity.h"
+#include "tgbot/types/InputMessageContent.h"
#include <string>
#include <memory>
+#include <vector>
namespace TgBot {
/**
* @brief Represents a link to a photo stored on the Telegram servers.
+ * By default, this photo will be sent by the user with an optional caption.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the photo.
*
* @ingroup types
*/
@@ -29,9 +34,35 @@ public:
std::string photoFileId;
/**
+ * @brief Optional. Title for the result
+ */
+ std::string title;
+
+ /**
* @brief Optional. Short description of the result
*/
std::string description;
+
+ /**
+ * @brief Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing
+ */
+ std::string caption;
+
+ /**
+ * @brief Optional. Mode for parsing entities in the photo caption.
+ * See https://core.telegram.org/bots/api#formatting-options for more details.
+ */
+ std::string parseMode;
+
+ /**
+ * @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ */
+ std::vector<MessageEntity::Ptr> captionEntities;
+
+ /**
+ * @brief Optional. Content of the message to be sent instead of the photo
+ */
+ InputMessageContent::Ptr inputMessageContent;
};
}
diff --git a/include/tgbot/types/InlineQueryResultCachedSticker.h b/include/tgbot/types/InlineQueryResultCachedSticker.h
index 29290fc..40d82f6 100644
--- a/include/tgbot/types/InlineQueryResultCachedSticker.h
+++ b/include/tgbot/types/InlineQueryResultCachedSticker.h
@@ -2,6 +2,7 @@
#define TGBOT_INLINEQUERYRESULTCACHEDSTICKER_H
#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/InputMessageContent.h"
#include <string>
#include <memory>
@@ -10,6 +11,8 @@ namespace TgBot {
/**
* @brief Represents a link to a sticker stored on the Telegram servers.
+ * By default, this sticker will be sent by the user.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the sticker.
*
* @ingroup types
*/
@@ -27,6 +30,11 @@ public:
* @brief A valid file identifier of the sticker
*/
std::string stickerFileId;
+
+ /**
+ * @brief Optional. Content of the message to be sent instead of the sticker
+ */
+ InputMessageContent::Ptr inputMessageContent;
};
}
diff --git a/include/tgbot/types/InlineQueryResultCachedVideo.h b/include/tgbot/types/InlineQueryResultCachedVideo.h
index f7b700a..b82cf34 100644
--- a/include/tgbot/types/InlineQueryResultCachedVideo.h
+++ b/include/tgbot/types/InlineQueryResultCachedVideo.h
@@ -2,14 +2,19 @@
#define TGBOT_INLINEQUERYRESULTCACHEDVIDEO_H
#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/MessageEntity.h"
+#include "tgbot/types/InputMessageContent.h"
#include <string>
#include <memory>
+#include <vector>
namespace TgBot {
/**
* @brief Represents a link to a video file stored on the Telegram servers.
+ * By default, this video file will be sent by the user with an optional caption.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the video.
*
* @ingroup types
*/
@@ -24,14 +29,40 @@ public:
}
/**
- * @brief A valid file identifier of the video
+ * @brief A valid file identifier for the video file
*/
std::string videoFileId;
/**
+ * @brief Title for the result
+ */
+ std::string title;
+
+ /**
* @brief Optional. Short description of the result
*/
std::string description;
+
+ /**
+ * @brief Optional. Caption of the video to be sent, 0-1024 characters after entities parsing
+ */
+ std::string caption;
+
+ /**
+ * @brief Optional. Mode for parsing entities in the video caption.
+ * See https://core.telegram.org/bots/api#formatting-options for more details.
+ */
+ std::string parseMode;
+
+ /**
+ * @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ */
+ std::vector<MessageEntity::Ptr> captionEntities;
+
+ /**
+ * @brief Optional. Content of the message to be sent instead of the video
+ */
+ InputMessageContent::Ptr inputMessageContent;
};
}
diff --git a/include/tgbot/types/InlineQueryResultCachedVoice.h b/include/tgbot/types/InlineQueryResultCachedVoice.h
index ef08fca..ec21f43 100644
--- a/include/tgbot/types/InlineQueryResultCachedVoice.h
+++ b/include/tgbot/types/InlineQueryResultCachedVoice.h
@@ -2,14 +2,19 @@
#define TGBOT_INLINEQUERYRESULTCACHEDVOICE_H
#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/MessageEntity.h"
+#include "tgbot/types/InputMessageContent.h"
#include <string>
#include <memory>
+#include <vector>
namespace TgBot {
/**
* @brief Represents a link to a voice message stored on the Telegram servers.
+ * By default, this voice message will be sent by the user.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the voice message.
*
* @ingroup types
*/
@@ -24,9 +29,35 @@ public:
}
/**
- * @brief A valid file identifier of the voice message
+ * @brief A valid file identifier for the voice message
*/
std::string voiceFileId;
+
+ /**
+ * @brief Voice message title
+ */
+ std::string title;
+
+ /**
+ * @brief Optional. Caption, 0-1024 characters after entities parsing
+ */
+ std::string caption;
+
+ /**
+ * @brief Optional. Mode for parsing entities in the voice message caption.
+ * See https://core.telegram.org/bots/api#formatting-options for more details.
+ */
+ std::string parseMode;
+
+ /**
+ * @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ */
+ std::vector<MessageEntity::Ptr> captionEntities;
+
+ /**
+ * @brief Optional. Content of the message to be sent instead of the voice message
+ */
+ InputMessageContent::Ptr inputMessageContent;
};
}
diff --git a/include/tgbot/types/InlineQueryResultContact.h b/include/tgbot/types/InlineQueryResultContact.h
index 83ae223..32894c9 100644
--- a/include/tgbot/types/InlineQueryResultContact.h
+++ b/include/tgbot/types/InlineQueryResultContact.h
@@ -2,6 +2,7 @@
#define TGBOT_INLINEQUERYRESULTCONTACT_H
#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/InputMessageContent.h"
#include <cstdint>
#include <string>
@@ -10,7 +11,9 @@
namespace TgBot {
/**
- * @brief Represents a contact with a phone number
+ * @brief Represents a contact with a phone number.
+ * By default, this contact will be sent by the user.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the contact.
*
* @ingroup types
*/
@@ -22,8 +25,6 @@ public:
InlineQueryResultContact() {
this->type = TYPE;
- this->thumbHeight = 0;
- this->thumbWidth = 0;
}
/**
@@ -47,12 +48,17 @@ public:
std::string vcard;
/**
+ * @brief Optional. Content of the message to be sent instead of the contact
+ */
+ InputMessageContent::Ptr inputMessageContent;
+
+ /**
* @brief Optional. Url of the thumbnail for the result
*/
std::string thumbUrl;
/**
- * @brief Optional. Thumbnail width.
+ * @brief Optional. Thumbnail width
*/
std::int32_t thumbWidth;
diff --git a/include/tgbot/types/InlineQueryResultDocument.h b/include/tgbot/types/InlineQueryResultDocument.h
index 88a8ae1..9e6758c 100644
--- a/include/tgbot/types/InlineQueryResultDocument.h
+++ b/include/tgbot/types/InlineQueryResultDocument.h
@@ -2,15 +2,21 @@
#define TGBOT_INLINEQUERYRESULTDOCUMENT_H
#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/MessageEntity.h"
+#include "tgbot/types/InputMessageContent.h"
#include <cstdint>
#include <string>
#include <memory>
+#include <vector>
namespace TgBot {
/**
* @brief Represents a link to a file.
+ * By default, this file will be sent by the user with an optional caption.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the file.
+ * Currently, only .PDF and .ZIP files can be sent using this method.
*
* @ingroup types
*/
@@ -22,17 +28,36 @@ public:
InlineQueryResultDocument() {
this->type = TYPE;
- this->thumbHeight = 0;
- this->thumbWidth = 0;
}
/**
+ * @brief Title for the result
+ */
+ std::string title;
+
+ /**
+ * @brief Optional. Caption of the document to be sent, 0-1024 characters after entities parsing
+ */
+ std::string caption;
+
+ /**
+ * @brief Optional. Mode for parsing entities in the document caption.
+ * See https://core.telegram.org/bots/api#formatting-options for more details.
+ */
+ std::string parseMode;
+
+ /**
+ * @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ */
+ std::vector<MessageEntity::Ptr> captionEntities;
+
+ /**
* @brief A valid URL for the file
*/
std::string documentUrl;
/**
- * @brief Mime type of the content of the file, either 'application/pdf' or 'application/zip'
+ * @brief Mime type of the content of the file, either “application/pdf” or “application/zip”
*/
std::string mimeType;
@@ -42,12 +67,17 @@ public:
std::string description;
/**
- * @brief Optional. Url of the thumbnail for the result
+ * @brief Optional. Content of the message to be sent instead of the file
+ */
+ InputMessageContent::Ptr inputMessageContent;
+
+ /**
+ * @brief Optional. URL of the thumbnail (jpeg only) for the file
*/
std::string thumbUrl;
/**
- * @brief Optional. Thumbnail width.
+ * @brief Optional. Thumbnail width
*/
std::int32_t thumbWidth;
diff --git a/include/tgbot/types/InlineQueryResultGif.h b/include/tgbot/types/InlineQueryResultGif.h
index 118da7b..05abe36 100644
--- a/include/tgbot/types/InlineQueryResultGif.h
+++ b/include/tgbot/types/InlineQueryResultGif.h
@@ -2,17 +2,20 @@
#define TGBOT_INLINEQUERYRESULTGIF_H
#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/MessageEntity.h"
+#include "tgbot/types/InputMessageContent.h"
#include <cstdint>
#include <string>
#include <memory>
+#include <vector>
namespace TgBot {
/**
* @brief Represents a link to an animated GIF file.
* By default, this animated GIF file will be sent by the user with optional caption.
- * Alternatively, you can use @ref InlineQueryResult::inputMessageContent to send a message with the specified content instead of the animation.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the animation.
*
* @ingroup types
*/
@@ -24,12 +27,11 @@ public:
InlineQueryResultGif() {
this->type = TYPE;
- this->gifWidth = 0;
- this->gifHeight = 0;
}
/**
- * @brief A valid URL for the GIF file. File size must not exceed 1MB
+ * @brief A valid URL for the GIF file.
+ * File size must not exceed 1MB
*/
std::string gifUrl;
@@ -58,6 +60,32 @@ public:
* Defaults to “image/jpeg”
*/
std::string thumbMimeType;
+
+ /**
+ * @brief Optional. Title for the result
+ */
+ std::string title;
+
+ /**
+ * @brief Optional. Caption of the GIF file to be sent, 0-1024 characters after entities parsing
+ */
+ std::string caption;
+
+ /**
+ * @brief Optional. Mode for parsing entities in the caption.
+ * See https://core.telegram.org/bots/api#formatting-options for more details.
+ */
+ std::string parseMode;
+
+ /**
+ * @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ */
+ std::vector<MessageEntity::Ptr> captionEntities;
+
+ /**
+ * @brief Optional. Content of the message to be sent instead of the GIF animation
+ */
+ InputMessageContent::Ptr inputMessageContent;
};
}
diff --git a/include/tgbot/types/InlineQueryResultLocation.h b/include/tgbot/types/InlineQueryResultLocation.h
index 31c27cc..a72350a 100644
--- a/include/tgbot/types/InlineQueryResultLocation.h
+++ b/include/tgbot/types/InlineQueryResultLocation.h
@@ -2,6 +2,7 @@
#define TGBOT_INLINEQUERYRESULTLOCATION_H
#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/InputMessageContent.h"
#include <cstdint>
#include <string>
@@ -11,6 +12,8 @@ namespace TgBot {
/**
* @brief Represents a location on a map.
+ * By default, the location will be sent by the user.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the location.
*
* @ingroup types
*/
@@ -22,8 +25,6 @@ public:
InlineQueryResultLocation() {
this->type = TYPE;
- this->thumbHeight = 0;
- this->thumbWidth = 0;
}
/**
@@ -37,12 +38,44 @@ public:
float longitude;
/**
+ * @brief Location title
+ */
+ std::string title;
+
+ /**
+ * @brief Optional. The radius of uncertainty for the location, measured in meters; 0-1500
+ */
+ float horizontalAccuracy;
+
+ /**
+ * @brief Optional. Period in seconds for which the location can be updated, should be between 60 and 86400.
+ */
+ std::int32_t livePeriod;
+
+ /**
+ * @brief Optional. For live locations, a direction in which the user is moving, in degrees.
+ * Must be between 1 and 360 if specified.
+ */
+ std::int32_t heading;
+
+ /**
+ * @brief 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.
+ */
+ std::int32_t proximityAlertRadius;
+
+ /**
+ * @brief Optional. Content of the message to be sent instead of the location
+ */
+ InputMessageContent::Ptr inputMessageContent;
+
+ /**
* @brief Optional. Url of the thumbnail for the result
*/
std::string thumbUrl;
/**
- * @brief Optional. Thumbnail width.
+ * @brief Optional. Thumbnail width
*/
std::int32_t thumbWidth;
diff --git a/include/tgbot/types/InlineQueryResultMpeg4Gif.h b/include/tgbot/types/InlineQueryResultMpeg4Gif.h
index f6319a9..7543c00 100644
--- a/include/tgbot/types/InlineQueryResultMpeg4Gif.h
+++ b/include/tgbot/types/InlineQueryResultMpeg4Gif.h
@@ -1,16 +1,21 @@
#ifndef TGBOT_INLINEQUERYRESULTMPEG4GIF_H
#define TGBOT_INLINEQUERYRESULTMPEG4GIF_H
+#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/MessageEntity.h"
+#include "tgbot/types/InputMessageContent.h"
+
#include <cstdint>
#include <memory>
#include <string>
+#include <vector>
namespace TgBot {
/**
* @brief Represents a link to a video animation (H.264/MPEG-4 AVC video without sound).
* By default, this animated MPEG-4 file will be sent by the user with optional caption.
- * Alternatively, you can use @ref InlineQueryResult::inputMessageContent to send a message with the specified content instead of the animation.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the animation.
*
* @ingroup types
*/
@@ -22,8 +27,6 @@ public:
InlineQueryResultMpeg4Gif() {
this->type = TYPE;
- this->mpeg4Width = 0;
- this->mpeg4Height = 0;
}
/**
@@ -57,6 +60,32 @@ public:
* Defaults to “image/jpeg”
*/
std::string thumbMimeType;
+
+ /**
+ * @brief Optional. Title for the result
+ */
+ std::string title;
+
+ /**
+ * @brief Optional. Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing
+ */
+ std::string caption;
+
+ /**
+ * @brief Optional. Mode for parsing entities in the caption.
+ * See https://core.telegram.org/bots/api#formatting-options for more details.
+ */
+ std::string parseMode;
+
+ /**
+ * @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ */
+ std::vector<MessageEntity::Ptr> captionEntities;
+
+ /**
+ * @brief Optional. Content of the message to be sent instead of the video animation
+ */
+ InputMessageContent::Ptr inputMessageContent;
};
}
diff --git a/include/tgbot/types/InlineQueryResultPhoto.h b/include/tgbot/types/InlineQueryResultPhoto.h
index 4e03de6..b6ecd76 100644
--- a/include/tgbot/types/InlineQueryResultPhoto.h
+++ b/include/tgbot/types/InlineQueryResultPhoto.h
@@ -2,15 +2,20 @@
#define TGBOT_INLINEQUERYRESULTPHOTO_H
#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/MessageEntity.h"
+#include "tgbot/types/InputMessageContent.h"
#include <cstdint>
#include <string>
#include <memory>
+#include <vector>
namespace TgBot {
/**
* @brief Represents a link to a photo.
+ * By default, this photo will be sent by the user with optional caption.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the photo.
*
* @ingroup types
*/
@@ -22,12 +27,12 @@ public:
InlineQueryResultPhoto() {
this->type = TYPE;
- this->photoWidth = 0;
- this->photoHeight = 0;
}
/**
* @brief A valid URL of the photo.
+ * Photo must be in jpeg format.
+ * Photo size must not exceed 5MB
*/
std::string photoUrl;
@@ -37,19 +42,45 @@ public:
std::string thumbUrl;
/**
- * @brief Optional. Width of the photo.
+ * @brief Optional. Width of the photo
*/
std::int32_t photoWidth;
/**
- * @brief Optional. Height of the photo.
+ * @brief Optional. Height of the photo
*/
std::int32_t photoHeight;
/**
- * @brief Optional. Short description of the result.
+ * @brief Optional. Title for the result
+ */
+ std::string title;
+
+ /**
+ * @brief Optional. Short description of the result
*/
std::string description;
+
+ /**
+ * @brief Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing
+ */
+ std::string caption;
+
+ /**
+ * @brief Optional. Mode for parsing entities in the photo caption.
+ * See https://core.telegram.org/bots/api#formatting-options for more details.
+ */
+ std::string parseMode;
+
+ /**
+ * @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ */
+ std::vector<MessageEntity::Ptr> captionEntities;
+
+ /**
+ * @brief Optional. Content of the message to be sent instead of the photo
+ */
+ InputMessageContent::Ptr inputMessageContent;
};
}
diff --git a/include/tgbot/types/InlineQueryResultVenue.h b/include/tgbot/types/InlineQueryResultVenue.h
index d5edfd4..7a93591 100644
--- a/include/tgbot/types/InlineQueryResultVenue.h
+++ b/include/tgbot/types/InlineQueryResultVenue.h
@@ -2,6 +2,7 @@
#define TGBOT_INLINEQUERYRESULTVENUE_H
#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/InputMessageContent.h"
#include <cstdint>
#include <string>
@@ -11,6 +12,8 @@ namespace TgBot {
/**
* @brief Represents a venue.
+ * By default, the venue will be sent by the user.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the venue.
*
* @ingroup types
*/
@@ -22,8 +25,6 @@ public:
InlineQueryResultVenue() {
this->type = TYPE;
- this->thumbHeight = 0;
- this->thumbWidth = 0;
}
/**
@@ -37,6 +38,11 @@ public:
float longitude;
/**
+ * @brief Title of the venue
+ */
+ std::string title;
+
+ /**
* @brief Address of the venue
*/
std::string address;
@@ -47,17 +53,34 @@ public:
std::string foursquareId;
/**
- * @brief Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
+ * @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. Google Places identifier of the venue
+ */
+ std::string googlePlaceId;
+
+ /**
+ * @brief Optional. Google Places type of the venue.
+ * (See https://developers.google.com/places/web-service/supported_types.)
+ */
+ std::string googlePlaceType;
+
+ /**
+ * @brief Optional. Content of the message to be sent instead of the venue
+ */
+ InputMessageContent::Ptr inputMessageContent;
+
+ /**
* @brief Optional. Url of the thumbnail for the result
*/
std::string thumbUrl;
/**
- * @brief Optional. Thumbnail width.
+ * @brief Optional. Thumbnail width
*/
std::int32_t thumbWidth;
diff --git a/include/tgbot/types/InlineQueryResultVideo.h b/include/tgbot/types/InlineQueryResultVideo.h
index 88c4910..ead6303 100644
--- a/include/tgbot/types/InlineQueryResultVideo.h
+++ b/include/tgbot/types/InlineQueryResultVideo.h
@@ -1,14 +1,23 @@
#ifndef TGBOT_INLINEQUERYRESULTVIDEO_H
#define TGBOT_INLINEQUERYRESULTVIDEO_H
+#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/MessageEntity.h"
+#include "tgbot/types/InputMessageContent.h"
+
#include <cstdint>
#include <memory>
#include <string>
+#include <vector>
namespace TgBot {
/**
- * @brief Represents link to a page containing an embedded video player or a video file.
+ * @brief Represents a link to a page containing an embedded video player or a video file.
+ * By default, this video file will be sent by the user with an optional caption.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the video.
+ *
+ * If an InlineQueryResultVideo message contains an embedded video (e.g., YouTube), you must replace its content using inputMessageContent.
*
* @ingroup types
*/
@@ -20,18 +29,15 @@ public:
InlineQueryResultVideo() {
this->type = TYPE;
- this->videoWidth = 0;
- this->videoHeight = 0;
- this->videoDuration = 0;
};
/**
- * @brief A valid URL for the embedded video player or video file.
+ * @brief A valid URL for the embedded video player or video file
*/
std::string videoUrl;
/**
- * @brief Mime type of the content of video url, "text/html" or "video/mp4".
+ * @brief Mime type of the content of video url, “text/html” or “video/mp4”
*/
std::string mimeType;
@@ -41,25 +47,51 @@ public:
std::string thumbUrl;
/**
- * @brief Optional. Video width.
+ * @brief Title for the result
+ */
+ std::string title;
+
+ /**
+ * @brief Optional. Caption of the video to be sent, 0-1024 characters after entities parsing
+ */
+ std::string caption;
+
+ /**
+ * @brief Optional. Mode for parsing entities in the video caption.
+ * See https://core.telegram.org/bots/api#formatting-options for more details.
+ */
+ std::string parseMode;
+
+ /**
+ * @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ */
+ std::vector<MessageEntity::Ptr> captionEntities;
+
+ /**
+ * @brief Optional. Video width
*/
std::int32_t videoWidth;
/**
- * @brief Optional. Video height.
+ * @brief Optional. Video height
*/
std::int32_t videoHeight;
/**
- * @brief Optional. Video duration.
+ * @brief Optional. Video duration in seconds
*/
std::int32_t videoDuration;
/**
- * @brief Optional. Short description of the result.
+ * @brief Optional. Short description of the result
*/
std::string description;
+ /**
+ * @brief Optional. Content of the message to be sent instead of the video.
+ * This field is required if InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video).
+ */
+ InputMessageContent::Ptr inputMessageContent;
};
}
diff --git a/include/tgbot/types/InlineQueryResultVoice.h b/include/tgbot/types/InlineQueryResultVoice.h
index 2cfdfad..335c2a7 100644
--- a/include/tgbot/types/InlineQueryResultVoice.h
+++ b/include/tgbot/types/InlineQueryResultVoice.h
@@ -1,14 +1,21 @@
#ifndef TGBOT_INLINEQUERYRESULTVOICE_H
#define TGBOT_INLINEQUERYRESULTVOICE_H
+#include "tgbot/types/InlineQueryResult.h"
+#include "tgbot/types/MessageEntity.h"
+#include "tgbot/types/InputMessageContent.h"
+
#include <cstdint>
#include <memory>
#include <string>
+#include <vector>
namespace TgBot {
/**
- * @brief Represents link to a page containing an embedded video player or a video file.
+ * @brief Represents a link to a voice recording in an .OGG container encoded with OPUS.
+ * By default, this voice recording will be sent by the user.
+ * Alternatively, you can use inputMessageContent to send a message with the specified content instead of the the voice message.
*
* @ingroup types
*/
@@ -20,7 +27,6 @@ public:
InlineQueryResultVoice() {
this->type = TYPE;
- this->voiceDuration = 0;
};
/**
@@ -29,9 +35,35 @@ public:
std::string voiceUrl;
/**
+ * @brief Recording title
+ */
+ std::string title;
+
+ /**
+ * @brief Optional. Caption, 0-1024 characters after entities parsing
+ */
+ std::string caption;
+
+ /**
+ * @brief Optional. Mode for parsing entities in the voice message caption.
+ * See https://core.telegram.org/bots/api#formatting-options for more details.
+ */
+ std::string parseMode;
+
+ /**
+ * @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ */
+ std::vector<MessageEntity::Ptr> captionEntities;
+
+ /**
* @brief Optional. Recording duration in seconds
*/
std::int32_t voiceDuration;
+
+ /**
+ * @brief Optional. Content of the message to be sent instead of the voice recording
+ */
+ InputMessageContent::Ptr inputMessageContent;
};
}
diff --git a/include/tgbot/types/InputContactMessageContent.h b/include/tgbot/types/InputContactMessageContent.h
index f46b704..44e8324 100644
--- a/include/tgbot/types/InputContactMessageContent.h
+++ b/include/tgbot/types/InputContactMessageContent.h
@@ -1,6 +1,8 @@
#ifndef TGBOT_INPUTCONTACTMESSAGECONTENT_H
#define TGBOT_INPUTCONTACTMESSAGECONTENT_H
+#include "tgbot/types/InputMessageContent.h"
+
#include <memory>
#include <string>
@@ -13,11 +15,13 @@ namespace TgBot {
*/
class InputContactMessageContent : public InputMessageContent {
public:
+ static const std::string TYPE;
+
typedef std::shared_ptr<InputContactMessageContent> Ptr;
- InputContactMessageContent() :
- InputMessageContent("InputContactMessageContent")
- {}
+ InputContactMessageContent() {
+ this->type = TYPE;
+ }
/**
* @brief Contact's phone number
@@ -38,8 +42,6 @@ public:
* @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/InputInvoiceMessageContent.h b/include/tgbot/types/InputInvoiceMessageContent.h
new file mode 100644
index 0000000..36f9056
--- /dev/null
+++ b/include/tgbot/types/InputInvoiceMessageContent.h
@@ -0,0 +1,140 @@
+#ifndef TGBOT_INPUTINVOICEMESSAGECONTENT_H
+#define TGBOT_INPUTINVOICEMESSAGECONTENT_H
+
+#include "tgbot/types/InputMessageContent.h"
+#include "tgbot/types/LabeledPrice.h"
+
+#include <cstdint>
+#include <memory>
+#include <string>
+#include <vector>
+
+namespace TgBot {
+
+/**
+ * @brief Represents the content of an invoice message to be sent as the result of an inline query.
+ *
+ * @ingroup types
+ */
+class InputInvoiceMessageContent : public InputMessageContent {
+public:
+ static const std::string TYPE;
+
+ typedef std::shared_ptr<InputInvoiceMessageContent> Ptr;
+
+ InputInvoiceMessageContent() {
+ this->type = TYPE;
+ }
+
+ /**
+ * @brief Product name, 1-32 characters
+ */
+ std::string title;
+
+ /**
+ * @brief Product description, 1-255 characters
+ */
+ std::string description;
+
+ /**
+ * @brief Bot-defined invoice payload, 1-128 bytes.
+ * This will not be displayed to the user, use for your internal processes.
+ */
+ std::string payload;
+
+ /**
+ * @brief Payment provider token, obtained via Botfather
+ */
+ std::string providerToken;
+
+ /**
+ * @brief Three-letter ISO 4217 currency code, see https://core.telegram.org/bots/payments#supported-currencies
+ */
+ std::string currency;
+
+ /**
+ * @brief Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
+ */
+ std::vector<LabeledPrice::Ptr> prices;
+
+ /**
+ * @brief 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
+ */
+ std::int32_t maxTipAmount;
+
+ /**
+ * @brief Optional. A JSON-serialized array of suggested amounts of tip 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.
+ */
+ std::vector<std::int32_t> suggestedTipAmounts;
+
+ /**
+ * @brief Optional. A JSON-serialized object for data about the invoice, which will be shared with the payment provider.
+ * A detailed description of the required fields should be provided by the payment provider.
+ */
+ std::string providerData;
+
+ /**
+ * @brief Optional. URL of the product photo for the invoice.
+ * Can be a photo of the goods or a marketing image for a service.
+ * People like it better when they see what they are paying for.
+ */
+ std::string photoUrl;
+
+ /**
+ * @brief Optional. Photo size
+ */
+ std::int32_t photoSize;
+
+ /**
+ * @brief Optional. Photo width
+ */
+ std::int32_t photoWidth;
+
+ /**
+ * @brief Optional. Photo height
+ */
+ std::int32_t photoHeight;
+
+ /**
+ * @brief Optional. Pass True, if you require the user's full name to complete the order
+ */
+ bool needName;
+
+ /**
+ * @brief Optional. Pass True, if you require the user's phone number to complete the order
+ */
+ bool needPhoneNumber;
+
+ /**
+ * @brief Optional. Pass True, if you require the user's email address to complete the order
+ */
+ bool needEmail;
+
+ /**
+ * @brief Optional. Pass True, if you require the user's shipping address to complete the order
+ */
+ bool needShippingAddress;
+
+ /**
+ * @brief Optional. Pass True, if user's phone number should be sent to provider
+ */
+ bool sendPhoneNumberToProvider;
+
+ /**
+ * @brief Optional. Pass True, if user's email address should be sent to provider
+ */
+ bool sendEmailToProvider;
+
+ /**
+ * @brief Optional. Pass True, if the final price depends on the shipping method
+ */
+ bool isFlexible;
+};
+}
+
+#endif //TGBOT_INPUTINVOICEMESSAGECONTENT_H
diff --git a/include/tgbot/types/InputLocationMessageContent.h b/include/tgbot/types/InputLocationMessageContent.h
index 6d46c41..8b9c22f 100644
--- a/include/tgbot/types/InputLocationMessageContent.h
+++ b/include/tgbot/types/InputLocationMessageContent.h
@@ -1,6 +1,8 @@
#ifndef TGBOT_INPUTLOCATIONMESSAGECONTENT_H
#define TGBOT_INPUTLOCATIONMESSAGECONTENT_H
+#include "tgbot/types/InputMessageContent.h"
+
#include <memory>
namespace TgBot {
@@ -12,11 +14,13 @@ namespace TgBot {
*/
class InputLocationMessageContent : public InputMessageContent {
public:
+ static const std::string TYPE;
+
typedef std::shared_ptr<InputLocationMessageContent> Ptr;
- InputLocationMessageContent() :
- InputMessageContent("InputLocationMessageContent")
- {}
+ InputLocationMessageContent() {
+ this->type = TYPE;
+ }
/**
* @brief Latitude of the location in degrees
@@ -28,7 +32,27 @@ public:
*/
float longitude;
- virtual ~InputLocationMessageContent() { }
+ /**
+ * @brief Optional. The radius of uncertainty for the location, measured in meters; 0-1500
+ */
+ float horizontalAccuracy;
+
+ /**
+ * @brief Optional. Period in seconds for which the location can be updated, should be between 60 and 86400.
+ */
+ std::int32_t livePeriod;
+
+ /**
+ * @brief Optional. For live locations, a direction in which the user is moving, in degrees.
+ * Must be between 1 and 360 if specified.
+ */
+ std::int32_t heading;
+
+ /**
+ * @brief 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.
+ */
+ std::int32_t proximityAlertRadius;
};
}
diff --git a/include/tgbot/types/InputMedia.h b/include/tgbot/types/InputMedia.h
index 7740595..c7ff6c0 100644
--- a/include/tgbot/types/InputMedia.h
+++ b/include/tgbot/types/InputMedia.h
@@ -1,14 +1,18 @@
#ifndef TGBOT_INPUTMEDIA_H
#define TGBOT_INPUTMEDIA_H
-#include <cstdint>
+#include "tgbot/types/MessageEntity.h"
+
#include <memory>
#include <string>
+#include <vector>
namespace TgBot {
/**
- * @brief This object represents the content of a media message to be sent.
+ * @brief This abstract class is base of all input media.
+ *
+ * This object represents the content of a media message to be sent.
*
* @ingroup types
*/
@@ -16,70 +20,37 @@ class InputMedia {
public:
typedef std::shared_ptr<InputMedia> Ptr;
- enum class TYPE : std::uint8_t {
- PHOTO,
- VIDEO,
- ANIMATION,
- DOCUMENT,
- AUDIO
- };
+ InputMedia() {}
- /**
- * @brief Type of the result, It should be one of TYPE::*
- */
- TYPE type;
+ virtual ~InputMedia() {}
/**
- * @brief File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
+ * @brief Type of the result
*/
- std::string media;
+ std::string type;
/**
- * @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>.
+ * @brief File to send.
+ * Pass a fileId to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name.
+ * https://core.telegram.org/bots/api#sending-files
*/
- std::string thumb;
+ std::string media;
/**
- * @brief Optional. Caption of the media to be sent, 0-200 characters
+ * @brief Optional. Caption of the media to to be sent, 0-1024 characters after entities parsing
*/
std::string caption;
/**
- * @brief Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
+ * @brief Optional. Mode for parsing entities in the media caption.
+ * See https://core.telegram.org/bots/api#formatting-options for more details.
*/
std::string parseMode;
/**
- * @brief Optional. Media width
- */
- std::int32_t width = 0;
-
- /**
- * @brief Optional. Media height
- */
- std::int32_t height = 0;
-
- /**
- * @brief Optional. Media duration
- */
- std::int32_t duration = 0;
-
- /**
- * @brief Optional. Performer of the audio.
- */
- std::int32_t performer = 0;
-
- /**
- * @brief Optional. Title of the audio.
- */
- std::int32_t title = 0;
-
- /**
- * @brief Optional. Pass True, if the uploaded video is suitable for streaming
+ * @brief Optional. List of special entities that appear in the caption, which can be specified instead of InputMedia::parseMode
*/
- bool supportsStreaming = false;
+ std::vector<MessageEntity::Ptr> captionEntities;
};
}
diff --git a/include/tgbot/types/InputMediaAnimation.h b/include/tgbot/types/InputMediaAnimation.h
index 8bfb85b..b6109a0 100644
--- a/include/tgbot/types/InputMediaAnimation.h
+++ b/include/tgbot/types/InputMediaAnimation.h
@@ -9,16 +9,45 @@
namespace TgBot {
/**
- * @brief Represents a video to be sent.
+ * @brief Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent.
+ *
* @ingroup types
*/
class InputMediaAnimation : public InputMedia {
+
public:
+ static const std::string TYPE;
+
typedef std::shared_ptr<InputMediaAnimation> Ptr;
InputMediaAnimation() {
- this->type = TYPE::ANIMATION;
+ this->type = TYPE;
}
+
+ /**
+ * @brief 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
+ */
+ std::string thumb;
+
+ /**
+ * @brief Optional. Animation width
+ */
+ std::int32_t width;
+
+ /**
+ * @brief Optional. Animation height
+ */
+ std::int32_t height;
+
+ /**
+ * @brief Optional. Animation duration
+ */
+ std::int32_t duration;
};
}
diff --git a/include/tgbot/types/InputMediaAudio.h b/include/tgbot/types/InputMediaAudio.h
index 6a4b653..b46936e 100644
--- a/include/tgbot/types/InputMediaAudio.h
+++ b/include/tgbot/types/InputMediaAudio.h
@@ -9,16 +9,45 @@
namespace TgBot {
/**
- * @brief Represents a video to be sent.
+ * @brief Represents an audio file to be treated as music to be sent.
+ *
* @ingroup types
*/
class InputMediaAudio : public InputMedia {
+
public:
+ static const std::string TYPE;
+
typedef std::shared_ptr<InputMediaAudio> Ptr;
InputMediaAudio() {
- this->type = TYPE::AUDIO;
+ this->type = TYPE;
}
+
+ /**
+ * @brief 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
+ */
+ std::string thumb;
+
+ /**
+ * @brief Optional. Duration of the audio in seconds
+ */
+ std::int32_t duration;
+
+ /**
+ * @brief Optional. Performer of the audio
+ */
+ std::string performer;
+
+ /**
+ * @brief Optional. Title of the audio
+ */
+ std::string title;
};
}
diff --git a/include/tgbot/types/InputMediaDocument.h b/include/tgbot/types/InputMediaDocument.h
index a496d3b..9a6ab10 100644
--- a/include/tgbot/types/InputMediaDocument.h
+++ b/include/tgbot/types/InputMediaDocument.h
@@ -9,16 +9,36 @@
namespace TgBot {
/**
- * @brief Represents a video to be sent.
+ * @brief Represents a general file to be sent.
+ *
* @ingroup types
*/
class InputMediaDocument : public InputMedia {
+
public:
+ static const std::string TYPE;
+
typedef std::shared_ptr<InputMediaDocument> Ptr;
InputMediaDocument() {
- this->type = TYPE::DOCUMENT;
+ this->type = TYPE;
}
+
+ /**
+ * @brief 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
+ */
+ std::string thumb;
+
+ /**
+ * @brief Optional. Disables automatic server-side content type detection for files uploaded using multipart/form-data.
+ * Always true, if the document is sent as part of an album.
+ */
+ bool disableContentTypeDetection;
};
}
diff --git a/include/tgbot/types/InputMediaPhoto.h b/include/tgbot/types/InputMediaPhoto.h
index 6ef0c32..998981d 100644
--- a/include/tgbot/types/InputMediaPhoto.h
+++ b/include/tgbot/types/InputMediaPhoto.h
@@ -10,14 +10,17 @@ namespace TgBot {
/**
* @brief Represents a photo to be sent.
+ *
* @ingroup types
*/
class InputMediaPhoto : public InputMedia {
public:
+ static const std::string TYPE;
+
typedef std::shared_ptr<InputMediaPhoto> Ptr;
InputMediaPhoto() {
- this->type = TYPE::PHOTO;
+ this->type = TYPE;
}
};
}
diff --git a/include/tgbot/types/InputMediaVideo.h b/include/tgbot/types/InputMediaVideo.h
index 1aeaa6b..348d973 100644
--- a/include/tgbot/types/InputMediaVideo.h
+++ b/include/tgbot/types/InputMediaVideo.h
@@ -2,6 +2,7 @@
#define TGBOT_INPUTMEDIAVIDEO_H
#include "tgbot/types/InputMedia.h"
+#include "tgbot/types/InputFile.h"
#include <memory>
#include <string>
@@ -10,15 +11,48 @@ namespace TgBot {
/**
* @brief Represents a video to be sent.
+ *
* @ingroup types
*/
class InputMediaVideo : public InputMedia {
public:
+ static const std::string TYPE;
+
typedef std::shared_ptr<InputMediaVideo> Ptr;
InputMediaVideo() {
- this->type = TYPE::VIDEO;
+ this->type = TYPE;
}
+
+ /**
+ * @brief 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
+ */
+ std::string thumb;
+
+ /**
+ * @brief Optional. Video width
+ */
+ std::int32_t width;
+
+ /**
+ * @brief Optional. Video height
+ */
+ std::int32_t height;
+
+ /**
+ * @brief Optional. Video duration
+ */
+ std::int32_t duration;
+
+ /**
+ * @brief Optional. Pass True, if the uploaded video is suitable for streaming
+ */
+ bool supportsStreaming;
};
}
diff --git a/include/tgbot/types/InputMessageContent.h b/include/tgbot/types/InputMessageContent.h
index 5ecdd92..01bcf77 100644
--- a/include/tgbot/types/InputMessageContent.h
+++ b/include/tgbot/types/InputMessageContent.h
@@ -7,27 +7,24 @@
namespace TgBot {
/**
- * @brief This object represents the content of a message to be sent as a result of an inline query.
+ * @brief This abstract class is base of all message contents.
+ *
+ * This object represents the content of a message to be sent as a result of an inline query.
+ *
* @ingroup types
*/
class InputMessageContent {
public:
typedef std::shared_ptr<InputMessageContent> Ptr;
- InputMessageContent(const std::string &tType):
- type(tType)
- {}
+ InputMessageContent() {}
+
+ virtual ~InputMessageContent() {}
/**
- * May be
- * InputTextMessageContent
- * InputLocationMessageContent
- * InputVenueMessageContent
- * InputContactMessageContent
+ * @brief Type of the content
*/
std::string type;
-
- virtual ~InputMessageContent() { }
};
}
diff --git a/include/tgbot/types/InputTextMessageContent.h b/include/tgbot/types/InputTextMessageContent.h
index 88cb718..de2a88a 100644
--- a/include/tgbot/types/InputTextMessageContent.h
+++ b/include/tgbot/types/InputTextMessageContent.h
@@ -1,8 +1,12 @@
#ifndef TGBOT_INPUTTEXTMESSAGECONTENT_H
#define TGBOT_INPUTTEXTMESSAGECONTENT_H
+#include "tgbot/types/InputMessageContent.h"
+#include "tgbot/types/MessageEntity.h"
+
#include <memory>
#include <string>
+#include <vector>
namespace TgBot {
@@ -13,11 +17,13 @@ namespace TgBot {
*/
class InputTextMessageContent : public InputMessageContent {
public:
+ static const std::string TYPE;
+
typedef std::shared_ptr<InputTextMessageContent> Ptr;
- InputTextMessageContent():
- InputMessageContent("InputTextMessageContent")
- {}
+ InputTextMessageContent() {
+ this->type = TYPE;
+ }
/**
* @brief Text of the message to be sent, 1-4096 characters
@@ -25,16 +31,20 @@ public:
std::string messageText;
/**
- * @brief Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
+ * @brief Optional. Mode for parsing entities in the message text.
+ * See https://core.telegram.org/bots/api#formatting-options for more details.
*/
std::string parseMode;
/**
+ * @brief Optional. List of special entities that appear in message text, which can be specified instead of InputTextMessageContent::parseMode
+ */
+ std::vector<MessageEntity::Ptr> entities;
+
+ /**
* @brief Optional. Disables link previews for links in the sent message
*/
bool disableWebPagePreview;
-
- virtual ~InputTextMessageContent() { }
};
}
diff --git a/include/tgbot/types/InputVenueMessageContent.h b/include/tgbot/types/InputVenueMessageContent.h
index 360a345..41ac5e0 100644
--- a/include/tgbot/types/InputVenueMessageContent.h
+++ b/include/tgbot/types/InputVenueMessageContent.h
@@ -1,6 +1,8 @@
#ifndef TGBOT_INPUTVENUEMESSAGECONTENT_H
#define TGBOT_INPUTVENUEMESSAGECONTENT_H
+#include "tgbot/types/InputMessageContent.h"
+
#include <memory>
#include <string>
@@ -13,11 +15,13 @@ namespace TgBot {
*/
class InputVenueMessageContent : public InputMessageContent {
public:
+ static const std::string TYPE;
+
typedef std::shared_ptr<InputVenueMessageContent> Ptr;
- InputVenueMessageContent() :
- InputMessageContent("InputVenueMessageContent")
- {}
+ InputVenueMessageContent() {
+ this->type = TYPE;
+ }
/**
* @brief Latitude of the location in degrees
@@ -45,15 +49,21 @@ public:
std::string foursquareId;
/**
- * @brief Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
+ * @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”.)
+ * @brief Optional. Google Places identifier of the venue
*/
+ std::string googlePlaceId;
- virtual ~InputVenueMessageContent() { }
+ /**
+ * @brief Optional. Google Places type of the venue.
+ * (See https://developers.google.com/places/web-service/supported_types)
+ */
+ std::string googlePlaceType;
};
}
diff --git a/include/tgbot/types/Location.h b/include/tgbot/types/Location.h
index 1487762..9454272 100644
--- a/include/tgbot/types/Location.h
+++ b/include/tgbot/types/Location.h
@@ -16,14 +16,37 @@ public:
typedef std::shared_ptr<Location> Ptr;
/**
- * @brief Longitude as defined by sender.
+ * @brief Longitude as defined by sender
*/
float longitude;
/**
- * @brief Latitude as defined by sender.
+ * @brief Latitude as defined by sender
*/
float latitude;
+
+ /**
+ * @brief Optional. The radius of uncertainty for the location, measured in meters; 0-1500
+ */
+ float horizontalAccuracy;
+
+ /**
+ * @brief Optional. Time relative to the message sending date, during which the location can be updated, in seconds.
+ * For active live locations only.
+ */
+ std::int32_t livePeriod;
+
+ /**
+ * @brief Optional. The direction in which user is moving, in degrees; 1-360.
+ * For active live locations only.
+ */
+ std::int32_t heading;
+
+ /**
+ * @brief Optional. Maximum distance for proximity alerts about approaching another chat member, in meters.
+ * For sent live locations only.
+ */
+ std::int32_t proximityAlertRadius;
};
}
diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h
index f8f1b13..c918257 100644
--- a/include/tgbot/types/Message.h
+++ b/include/tgbot/types/Message.h
@@ -19,9 +19,15 @@
#include "tgbot/types/Venue.h"
#include "tgbot/types/Voice.h"
#include "tgbot/types/VideoNote.h"
+#include "tgbot/types/MessageAutoDeleteTimerChanged.h"
#include "tgbot/types/Invoice.h"
#include "tgbot/types/SuccessfulPayment.h"
#include "tgbot/types/PassportData.h"
+#include "tgbot/types/ProximityAlertTriggered.h"
+#include "tgbot/types/VoiceChatScheduled.h"
+#include "tgbot/types/VoiceChatStarted.h"
+#include "tgbot/types/VoiceChatEnded.h"
+#include "tgbot/types/VoiceChatParticipantsInvited.h"
#include "tgbot/types/InlineKeyboardMarkup.h"
#include <cstdint>
@@ -46,11 +52,19 @@ public:
std::int32_t messageId;
/**
- * @brief Optional. Sender, empty for messages sent to channels
+ * @brief Optional. Sender of the message; empty for messages sent to channels.
+ * For backward compatibility, the field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.
*/
User::Ptr from;
/**
+ * @brief Optional. Sender of the message, sent on behalf of a chat.
+ * For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group.
+ * For backward compatibility, the field from contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.
+ */
+ Chat::Ptr senderChat;
+
+ /**
* @brief Date the message was sent in Unix time
*/
std::int32_t date;
@@ -66,7 +80,7 @@ public:
User::Ptr forwardFrom;
/**
- * @brief Optional. For messages forwarded from channels, information about the original channel
+ * @brief Optional. For messages forwarded from channels or from anonymous administrators, information about the original sender chat
*/
Chat::Ptr forwardFromChat;
@@ -91,8 +105,13 @@ public:
std::int32_t forwardDate;
/**
+ * @brief Optional. True, if the message is a channel post that was automatically forwarded to the connected discussion group
+ */
+ bool isAutomaticForward;
+
+ /**
* @brief Optional. For replies, the original message.
- * Note that the Message object in this field will not contain further @ref Message::replyToMessage fields even if it itself is a reply.
+ * Note that the Message object in this field will not contain further replyToMessage fields even if it itself is a reply.
*/
Message::Ptr replyToMessage;
@@ -107,12 +126,17 @@ public:
std::int32_t editDate;
/**
+ * @brief Optional. True, if the message can't be forwarded
+ */
+ bool hasProtectedContent;
+
+ /**
* @brief Optional. The unique identifier of a media message group this message belongs to
*/
std::string mediaGroupId;
/**
- * @brief Optional. Signature of the post author for messages in channels
+ * @brief Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group administrator
*/
std::string authorSignature;
@@ -127,9 +151,10 @@ public:
std::vector<MessageEntity::Ptr> entities;
/**
- * @brief Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption
+ * @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
*/
- std::vector<MessageEntity::Ptr> captionEntities;
+ Animation::Ptr animation;
/**
* @brief Optional. Message is an audio file, information about the file
@@ -142,17 +167,6 @@ 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;
-
- /**
* @brief Optional. Message is a photo, available sizes of the photo
*/
std::vector<PhotoSize::Ptr> photo;
@@ -168,19 +182,24 @@ public:
Video::Ptr video;
/**
- * @brief Optional. Message is a voice message, information about the file
+ * @brief Optional. Message is a video note, information about the video message
*/
- Voice::Ptr voice;
+ VideoNote::Ptr videoNote;
/**
- * @brief Optional. Message is a video note, information about the video message
+ * @brief Optional. Message is a voice message, information about the file
*/
- VideoNote::Ptr videoNote;
+ Voice::Ptr voice;
/**
* @brief Optional. Caption for the animation, audio, document, photo, video or voice, 0-1024 characters
*/
std::string caption;
+
+ /**
+ * @brief Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption
+ */
+ std::vector<MessageEntity::Ptr> captionEntities;
/**
* @brief Optional. Message is a shared contact, information about the contact
@@ -188,14 +207,14 @@ public:
Contact::Ptr contact;
/**
- * @brief Optional. Message is a shared location, information about the location
+ * @brief Optional. Message is a dice with random value
*/
- Location::Ptr location;
+ Dice::Ptr dice;
/**
- * @brief Optional. Message is a venue, information about the venue
+ * @brief Optional. Message is a game, information about the game
*/
- Venue::Ptr venue;
+ Game::Ptr game;
/**
* @brief Optional. Message is a native poll, information about the poll
@@ -203,12 +222,18 @@ public:
Poll::Ptr poll;
/**
- * @brief Optional. Message is a dice with random value from 1 to 6
+ * @brief Optional. Message is a venue, information about the venue.
+ * For backward compatibility, when this field is set, the location field will also be set
*/
- Dice::Ptr dice;
+ Venue::Ptr venue;
/**
- * @brief Optional. New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)
+ * @brief Optional. Message is a shared location, information about the location
+ */
+ Location::Ptr location;
+
+ /**
+ * @brief Optional. Optional. New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)
*/
std::vector<User::Ptr> newChatMembers;
@@ -238,16 +263,25 @@ public:
bool groupChatCreated;
/**
- * @brief Optional. Service message: the supergroup has been created
+ * @brief Optional. Service message: the supergroup has been created.
+ * This field can't be received in a message coming through updates, because bot can't be a member of a supergroup when it is created.
+ * It can only be found in replyToMessage if someone replies to a very first message in a directly created supergroup.
*/
bool supergroupChatCreated;
/**
- * @brief Optional. Service message: the channel has been created
+ * @brief Optional. Service message: the channel has been created.
+ * This field can't be received in a message coming through updates, because bot can't be a member of a channel when it is created.
+ * It can only be found in replyToMessage if someone replies to a very first message in a channel.
*/
bool channelChatCreated;
/**
+ * @brief Optional. Service message: auto-delete timer settings changed in the chat
+ */
+ MessageAutoDeleteTimerChanged::Ptr messageAutoDeleteTimerChanged;
+
+ /**
* @brief Optional. The group has been migrated to a supergroup with the specified identifier.
*
* This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it.
@@ -265,22 +299,25 @@ public:
/**
* @brief Optional. Specified message was pinned.
- * Note that the Message object in this field will not contain further @ref Message::replyToMessage fields even if it is itself a reply.
+ * Note that the Message object in this field will not contain further replyToMessage fields even if it is itself a reply.
*/
Message::Ptr pinnedMessage;
/**
- * @brief Optional. Message is an invoice for a payment, information about the invoice
+ * @brief Optional. Message is an invoice for a payment, information about the invoice.
+ * https://core.telegram.org/bots/api#payments
*/
Invoice::Ptr invoice;
/**
* @brief Optional. Message is a service message about a successful payment, information about the payment
+ * https://core.telegram.org/bots/api#payments
*/
SuccessfulPayment::Ptr successfulPayment;
/**
- * @brief Optional. The domain name of the website on which the user has logged in
+ * @brief Optional. The domain name of the website on which the user has logged in.
+ * https://core.telegram.org/widgets/login
*/
std::string connectedWebsite;
@@ -290,17 +327,36 @@ public:
PassportData::Ptr passportData;
/**
- * @brief Optional. Inline keyboard attached to the message.
- * @ref InlineKeyboardButton::loginUrl buttons are represented as ordinary @ref InlineKeyboardButton::url buttons.
+ * @brief Optional. Service message.
+ * A user in the chat triggered another user's proximity alert while sharing Live Location.
*/
- InlineKeyboardMarkup::Ptr replyMarkup;
+ ProximityAlertTriggered::Ptr proximityAlertTriggered;
/**
- * @brief Optional. True, if the message is a channel post that was automatically forwarded to the connected discussion group
- *
- * Note: Added with Bot API 5.5
+ * @brief Optional. Service message: voice chat scheduled
+ */
+ VoiceChatScheduled::Ptr voiceChatScheduled;
+
+ /**
+ * @brief Optional. Service message: voice chat started
+ */
+ VoiceChatStarted::Ptr voiceChatStarted;
+
+ /**
+ * @brief Optional. Service message: voice chat ended
*/
- bool automaticForward;
+ VoiceChatEnded::Ptr voiceChatEnded;
+
+ /**
+ * @brief Optional. Service message: new participants invited to a voice chat
+ */
+ VoiceChatParticipantsInvited::Ptr voiceChatParticipantsInvited;
+
+ /**
+ * @brief Optional. Inline keyboard attached to the message.
+ * loginUrl buttons are represented as ordinary url buttons.
+ */
+ InlineKeyboardMarkup::Ptr replyMarkup;
};
}
diff --git a/include/tgbot/types/MessageAutoDeleteTimerChanged.h b/include/tgbot/types/MessageAutoDeleteTimerChanged.h
new file mode 100644
index 0000000..87adcd5
--- /dev/null
+++ b/include/tgbot/types/MessageAutoDeleteTimerChanged.h
@@ -0,0 +1,26 @@
+#ifndef TGBOT_CPP_MESSAGEAUTODELETETIMERCHANGED_H
+#define TGBOT_CPP_MESSAGEAUTODELETETIMERCHANGED_H
+
+#include <cstdint>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents a service message about a change in auto-delete timer settings.
+ *
+ * @ingroup types
+ */
+class MessageAutoDeleteTimerChanged {
+
+public:
+ typedef std::shared_ptr<MessageAutoDeleteTimerChanged> Ptr;
+
+ /**
+ * @brief New auto-delete time for messages in the chat
+ */
+ std::int32_t messageAutoDeleteTime;
+};
+}
+
+#endif //TGBOT_CPP_MESSAGEAUTODELETETIMERCHANGED_H
diff --git a/include/tgbot/types/MessageId.h b/include/tgbot/types/MessageId.h
new file mode 100644
index 0000000..77feaf2
--- /dev/null
+++ b/include/tgbot/types/MessageId.h
@@ -0,0 +1,25 @@
+#ifndef TGBOT_CPP_MESSAGEID_H
+#define TGBOT_CPP_MESSAGEID_H
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents a unique message identifier.
+ *
+ * @ingroup types
+ */
+class MessageId {
+
+public:
+ typedef std::shared_ptr<MessageId> Ptr;
+
+ /**
+ * @brief Unique message identifier
+ */
+ std::int32_t messageId;
+};
+}
+
+#endif //TGBOT_CPP_MESSAGEID_H
diff --git a/include/tgbot/types/PhotoSize.h b/include/tgbot/types/PhotoSize.h
index 97fdd84..5087f09 100644
--- a/include/tgbot/types/PhotoSize.h
+++ b/include/tgbot/types/PhotoSize.h
@@ -8,7 +8,7 @@
namespace TgBot {
/**
- * @brief This object represents one size of a photo or a @ref File / @ref Sticker thumbnail.
+ * @brief This object represents one size of a photo or a file / sticker thumbnail.
*
* @ingroup types
*/
diff --git a/include/tgbot/types/ProximityAlertTriggered.h b/include/tgbot/types/ProximityAlertTriggered.h
new file mode 100644
index 0000000..1a31bc1
--- /dev/null
+++ b/include/tgbot/types/ProximityAlertTriggered.h
@@ -0,0 +1,37 @@
+#ifndef TGBOT_CPP_PROXIMITYALERTTRIGGERED_H
+#define TGBOT_CPP_PROXIMITYALERTTRIGGERED_H
+
+#include "tgbot/types/User.h"
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents the content of a service message, sent whenever a user in the chat triggers a proximity alert set by another user.
+ *
+ * @ingroup types
+ */
+class ProximityAlertTriggered {
+
+public:
+ typedef std::shared_ptr<ProximityAlertTriggered> Ptr;
+
+ /**
+ * @brief User that triggered the alert
+ */
+ User::Ptr traveler;
+
+ /**
+ * @brief User that set the alert
+ */
+ User::Ptr watcher;
+
+ /**
+ * @brief The distance between the users
+ */
+ std::int32_t distance;
+};
+}
+
+#endif //TGBOT_CPP_PROXIMITYALERTTRIGGERED_H
diff --git a/include/tgbot/types/ReplyKeyboardMarkup.h b/include/tgbot/types/ReplyKeyboardMarkup.h
index 2b65b13..f122934 100644
--- a/include/tgbot/types/ReplyKeyboardMarkup.h
+++ b/include/tgbot/types/ReplyKeyboardMarkup.h
@@ -5,13 +5,13 @@
#include "tgbot/types/KeyboardButton.h"
#include <string>
-#include <vector>
#include <memory>
+#include <vector>
namespace TgBot {
/**
- * @brief This object represents a custom keyboard with reply options.
+ * @brief This object represents a custom keyboard with reply options (see https://core.telegram.org/bots#keyboards for details and examples).
*
* @ingroup types
*/
@@ -21,28 +21,37 @@ public:
typedef std::shared_ptr<ReplyKeyboardMarkup> Ptr;
/**
- * @brief Array of button rows, each represented by an Array of KeyboardButton.
+ * @brief Array of button rows, each represented by an Array of KeyboardButton objects
*/
std::vector<std::vector<KeyboardButton::Ptr>> keyboard;
/**
- * @brief Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard.
+ * @brief Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons).
+ * Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard.
*/
- bool resizeKeyboard = false;
+ bool resizeKeyboard;
/**
- * @brief Optional. Requests clients to hide the keyboard as soon as it's been used. Defaults to false.
+ * @brief Optional. Requests clients to hide the keyboard as soon as it's been used.
+ * The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat – the user can press a special button in the input field to see the custom keyboard again.
+ * Defaults to false
*/
- bool oneTimeKeyboard = false;
+ bool oneTimeKeyboard;
/**
- * @brief Optional. Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
- *
- * Example: A user requests to change the bot‘s language, bot replies to the request with a keyboard to select the new language. Other users in the group don’t see the keyboard.
+ * @brief Optional. The placeholder to be shown in the input field when the keyboard is active; 1-64 characters
*/
- bool selective = false;
-};
+ std::string inputFieldPlaceholder;
+ /**
+ * @brief Optional. Use this parameter if you want to show the keyboard to specific users only.
+ * Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has replyToMessageId), sender of the original message.
+ *
+ * Example: A user requests to change the bot's language, bot replies to the request with a keyboard to select the new language.
+ * Other users in the group don't see the keyboard.
+ */
+ bool selective;
+};
}
#endif //TGBOT_CPP_REPLYKEYBOARDMARKUP_H
diff --git a/include/tgbot/types/Update.h b/include/tgbot/types/Update.h
index f5b0237..6294ff5 100644
--- a/include/tgbot/types/Update.h
+++ b/include/tgbot/types/Update.h
@@ -9,6 +9,8 @@
#include "tgbot/types/PreCheckoutQuery.h"
#include "tgbot/types/Poll.h"
#include "tgbot/types/PollAnswer.h"
+#include "tgbot/types/ChatMemberUpdated.h"
+#include "tgbot/types/ChatJoinRequest.h"
#include <cstdint>
#include <memory>
@@ -61,7 +63,7 @@ public:
/**
* @brief Optional. The result of an inline query that was chosen by a user and sent to their chat partner.
- * Please see the documentation on the feedback collecting for details on how to enable these updates for your bot. (https://core.telegram.org/bots/inline#collecting-feedback)
+ * Please see https://core.telegram.org/bots/inline#collecting-feedback for details on how to enable these updates for your bot. (https://core.telegram.org/bots/inline#collecting-feedback)
*/
ChosenInlineResult::Ptr chosenInlineResult;
@@ -93,6 +95,24 @@ public:
* Bots receive new votes only in polls that were sent by the bot itself.
*/
PollAnswer::Ptr pollAnswer;
+
+ /**
+ * @brief Optional. The bot's chat member status was updated in a chat.
+ * For private chats, this update is received only when the bot is blocked or unblocked by the user.
+ */
+ ChatMemberUpdated::Ptr myChatMember;
+
+ /**
+ * @brief Optional. A chat member's status was updated in a chat.
+ * The bot must be an administrator in the chat and must explicitly specify “chatMember” in the list of allowedUpdates to receive these updates.
+ */
+ ChatMemberUpdated::Ptr chatMember;
+
+ /**
+ * @brief Optional. A request to join the chat has been sent.
+ * The bot must have the canInviteUsers administrator right in the chat to receive these updates.
+ */
+ ChatJoinRequest::Ptr chatJoinRequest;
};
}
diff --git a/include/tgbot/types/Venue.h b/include/tgbot/types/Venue.h
index accce16..ccc4773 100644
--- a/include/tgbot/types/Venue.h
+++ b/include/tgbot/types/Venue.h
@@ -18,7 +18,7 @@ public:
typedef std::shared_ptr<Venue> Ptr;
/**
- * @brief Venue location
+ * @brief Venue location. Can't be a live location
*/
Location::Ptr location;
@@ -42,6 +42,17 @@ public:
* (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
*/
std::string foursquareType;
+
+ /**
+ * @brief Optional. Google Places identifier of the venue
+ */
+ std::string googlePlaceId;
+
+ /**
+ * @brief Optional. Google Places type of the venue.
+ * (See https://developers.google.com/places/web-service/supported_types)
+ */
+ std::string googlePlaceType;
};
}
diff --git a/include/tgbot/types/Video.h b/include/tgbot/types/Video.h
index fac8de5..c1328b5 100644
--- a/include/tgbot/types/Video.h
+++ b/include/tgbot/types/Video.h
@@ -51,6 +51,11 @@ public:
PhotoSize::Ptr thumb;
/**
+ * @brief Optional. Original filename as defined by sender
+ */
+ std::string fileName;
+
+ /**
* @brief Optional. Mime type of a file as defined by sender
*/
std::string mimeType;
diff --git a/include/tgbot/types/VoiceChatEnded.h b/include/tgbot/types/VoiceChatEnded.h
new file mode 100644
index 0000000..883f6a2
--- /dev/null
+++ b/include/tgbot/types/VoiceChatEnded.h
@@ -0,0 +1,26 @@
+#ifndef TGBOT_CPP_VOICECHATENDED_H
+#define TGBOT_CPP_VOICECHATENDED_H
+
+#include <cstdint>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents a service message about a voice chat ended in the chat.
+ *
+ * @ingroup types
+ */
+class VoiceChatEnded {
+
+public:
+ typedef std::shared_ptr<VoiceChatEnded> Ptr;
+
+ /**
+ * @brief This object represents a service message about a voice chat ended in the chat.
+ */
+ std::int32_t duration;
+};
+}
+
+#endif //TGBOT_CPP_VOICECHATENDED_H
diff --git a/include/tgbot/types/VoiceChatParticipantsInvited.h b/include/tgbot/types/VoiceChatParticipantsInvited.h
new file mode 100644
index 0000000..f96c800
--- /dev/null
+++ b/include/tgbot/types/VoiceChatParticipantsInvited.h
@@ -0,0 +1,28 @@
+#ifndef TGBOT_CPP_VOICECHATPARTICIPANTSINVITED_H
+#define TGBOT_CPP_VOICECHATPARTICIPANTSINVITED_H
+
+#include "tgbot/types/User.h"
+
+#include <memory>
+#include <vector>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents a service message about new members invited to a voice chat.
+ *
+ * @ingroup types
+ */
+class VoiceChatParticipantsInvited {
+
+public:
+ typedef std::shared_ptr<VoiceChatParticipantsInvited> Ptr;
+
+ /**
+ * @brief Optional. New members that were invited to the voice chat
+ */
+ std::vector<User::Ptr> users;
+};
+}
+
+#endif //TGBOT_CPP_VOICECHATPARTICIPANTSINVITED_H
diff --git a/include/tgbot/types/VoiceChatScheduled.h b/include/tgbot/types/VoiceChatScheduled.h
new file mode 100644
index 0000000..8611d5f
--- /dev/null
+++ b/include/tgbot/types/VoiceChatScheduled.h
@@ -0,0 +1,26 @@
+#ifndef TGBOT_CPP_VOICECHATSCHEDULED_H
+#define TGBOT_CPP_VOICECHATSCHEDULED_H
+
+#include <cstdint>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents a service message about a voice chat scheduled in the chat.
+ *
+ * @ingroup types
+ */
+class VoiceChatScheduled {
+
+public:
+ typedef std::shared_ptr<VoiceChatScheduled> Ptr;
+
+ /**
+ * @brief Point in time (Unix timestamp) when the voice chat is supposed to be started by a chat administrator
+ */
+ std::int32_t startDate;
+};
+}
+
+#endif //TGBOT_CPP_VOICECHATSCHEDULED_H
diff --git a/include/tgbot/types/VoiceChatStarted.h b/include/tgbot/types/VoiceChatStarted.h
new file mode 100644
index 0000000..3d4b2e6
--- /dev/null
+++ b/include/tgbot/types/VoiceChatStarted.h
@@ -0,0 +1,21 @@
+#ifndef TGBOT_CPP_VOICECHATSTARTED_H
+#define TGBOT_CPP_VOICECHATSTARTED_H
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents a service message about a voice chat started in the chat.
+ * Currently holds no information.
+ *
+ * @ingroup types
+ */
+class VoiceChatStarted {
+
+public:
+ typedef std::shared_ptr<VoiceChatStarted> Ptr;
+};
+}
+
+#endif //TGBOT_CPP_VOICECHATSTARTED_H
diff --git a/include/tgbot/types/WebhookInfo.h b/include/tgbot/types/WebhookInfo.h
index 5252409..8139edc 100644
--- a/include/tgbot/types/WebhookInfo.h
+++ b/include/tgbot/types/WebhookInfo.h
@@ -18,7 +18,7 @@ public:
typedef std::shared_ptr<WebhookInfo> Ptr;
/**
- * @brief Webhook URL, may be empty if webhook is not set up.
+ * @brief Webhook URL, may be empty if webhook is not set up
*/
std::string url;
@@ -33,12 +33,17 @@ public:
std::int32_t pendingUpdateCount;
/**
+ * @brief Optional. Currently used webhook IP address
+ */
+ std::string ipAddress;
+
+ /**
* @brief Optional. Unix time for the most recent error that happened when trying to deliver an update via webhook
*/
std::int32_t lastErrorDate;
/**
- * @brief Optional. Error message in human - readable format for the most recent error that happened when trying to deliver an update via webhook
+ * @brief Optional. Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook
*/
std::string lastErrorMessage;
diff --git a/src/Api.cpp b/src/Api.cpp
index 070d72e..c1c86d2 100644
--- a/src/Api.cpp
+++ b/src/Api.cpp
@@ -40,15 +40,22 @@ vector<Update::Ptr> Api::getUpdates(std::int32_t offset, std::int32_t limit, std
return _tgTypeParser.parseJsonAndGetArray<Update>(&TgTypeParser::parseJsonAndGetUpdate, sendRequest("getUpdates", args));
}
-void Api::setWebhook(const string& url, const InputFile::Ptr certificate, std::int32_t maxConnection, const StringArrayPtr& allowedUpdates) const {
+bool Api::setWebhook(const std::string& url,
+ InputFile::Ptr certificate,
+ std::int32_t maxConnection,
+ const StringArrayPtr& allowedUpdates,
+ const std::string& ipAddress,
+ bool dropPendingUpdates) const {
vector<HttpReqArg> args;
- args.reserve(4);
- if (!url.empty()) {
- args.emplace_back("url", url);
- }
+ args.reserve(6);
+
+ args.emplace_back("url", url);
if (certificate != nullptr) {
args.emplace_back("certificate", certificate->data, true, certificate->mimeType, certificate->fileName);
}
+ if (!ipAddress.empty()) {
+ args.emplace_back("ip_address", ipAddress);
+ }
if (maxConnection != 40) {
args.emplace_back("max_connections", maxConnection);
}
@@ -59,11 +66,21 @@ void Api::setWebhook(const string& url, const InputFile::Ptr certificate, std::i
}, *allowedUpdates);
args.emplace_back("allowed_updates", allowedUpdatesJson);
}
+ if (dropPendingUpdates) {
+ args.emplace_back("drop_pending_updates", dropPendingUpdates);
+ }
- sendRequest("setWebhook", args);
+ return sendRequest("setWebhook").get<bool>("", false);
}
-bool Api::deleteWebhook() const {
+bool Api::deleteWebhook(bool dropPendingUpdates) const {
+ vector<HttpReqArg> args;
+ args.reserve(1);
+
+ if (dropPendingUpdates) {
+ args.emplace_back("drop_pending_updates", dropPendingUpdates);
+ }
+
return sendRequest("deleteWebhook").get<bool>("", false);
}
@@ -84,17 +101,26 @@ User::Ptr Api::getMe() const {
return _tgTypeParser.parseJsonAndGetUser(sendRequest("getMe"));
}
-Message::Ptr Api::sendMessage(boost::variant<std::int64_t, const std::string&> chatId, const std::string& text, bool disableWebPagePreview,
- std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const std::string& parseMode,
- bool disableNotification) const {
+Message::Ptr Api::sendMessage(boost::variant<std::int64_t, const std::string&> chatId,
+ const std::string& text,
+ bool disableWebPagePreview,
+ std::int32_t replyToMessageId,
+ GenericReply::Ptr replyMarkup,
+ const std::string& parseMode,
+ bool disableNotification,
+ const std::vector<MessageEntity::Ptr>& entities,
+ bool allowSendingWithoutReply) const {
vector<HttpReqArg> args;
- args.reserve(7);
+ args.reserve(9);
args.emplace_back("chat_id", chatId);
args.emplace_back("text", text);
if (!parseMode.empty()) {
args.emplace_back("parse_mode", parseMode);
}
+ if (!entities.empty()) {
+ args.emplace_back("entities", _tgTypeParser.parseArray<MessageEntity>(&TgTypeParser::parseMessageEntity, entities));
+ }
if (disableWebPagePreview) {
args.emplace_back("disable_web_page_preview", disableWebPagePreview);
}
@@ -104,6 +130,9 @@ Message::Ptr Api::sendMessage(boost::variant<std::int64_t, const std::string&> c
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
}
@@ -123,37 +152,101 @@ Message::Ptr Api::forwardMessage(std::int64_t chatId, std::int64_t fromChatId, s
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("forwardMessage", args));
}
-Message::Ptr Api::sendPhoto(std::int64_t chatId, boost::variant<InputFile::Ptr, std::string> photo, const string& caption, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
+MessageId::Ptr Api::copyMessage(std::int64_t chatId, std::int64_t fromChatId, std::int32_t messageId,
+ const std::string& caption, const std::string& parseMode, const std::vector<MessageEntity::Ptr>& captionEntities,
+ bool disableNotification, std::int32_t replyToMessageId, bool allowSendingWithoutReply,
+ GenericReply::Ptr replyMarkup) const {
vector<HttpReqArg> args;
- args.reserve(7);
+ args.reserve(10);
+
args.emplace_back("chat_id", chatId);
- 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));
- }
+ args.emplace_back("from_chat_id", fromChatId);
+ args.emplace_back("message_id", messageId);
if (!caption.empty()) {
args.emplace_back("caption", caption);
}
+ if (!parseMode.empty()) {
+ args.emplace_back("parse_mode", parseMode);
+ }
+ if (!captionEntities.empty()) {
+ args.emplace_back("caption_entities", _tgTypeParser.parseArray<MessageEntity>(&TgTypeParser::parseMessageEntity, captionEntities));
+ }
+ if (disableNotification) {
+ args.emplace_back("disable_notification", disableNotification);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
}
+
+ return _tgTypeParser.parseJsonAndGetMessageId(sendRequest("copyMessage", args));
+}
+
+Message::Ptr Api::sendPhoto(std::int64_t chatId,
+ boost::variant<InputFile::Ptr, 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 {
+ vector<HttpReqArg> args;
+ args.reserve(9);
+
+ args.emplace_back("chat_id", chatId);
+ 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));
+ }
+ if (!caption.empty()) {
+ args.emplace_back("caption", caption);
+ }
if (!parseMode.empty()) {
args.emplace_back("parse_mode", parseMode);
}
+ if (!captionEntities.empty()) {
+ args.emplace_back("caption_entities", _tgTypeParser.parseArray<MessageEntity>(&TgTypeParser::parseMessageEntity, captionEntities));
+ }
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (replyToMessageId) {
+ args.emplace_back("reply_to_message_id", replyToMessageId);
+ }
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
+ if (replyMarkup) {
+ args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
+ }
+
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendPhoto", args));
}
-Message::Ptr Api::sendAudio(std::int64_t chatId, boost::variant<InputFile::Ptr, std::string> audio, const string& caption, std::int32_t duration, const string& performer, const string& title, boost::variant<InputFile::Ptr, std::string> thumb, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
+Message::Ptr Api::sendAudio(std::int64_t chatId,
+ boost::variant<InputFile::Ptr, 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,
+ std::int32_t replyToMessageId,
+ GenericReply::Ptr replyMarkup,
+ const std::string& parseMode,
+ bool disableNotification,
+ const std::vector<MessageEntity::Ptr>& captionEntities,
+ bool allowSendingWithoutReply) const {
vector<HttpReqArg> args;
- args.reserve(11);
+ args.reserve(13);
+
args.emplace_back("chat_id", chatId);
if (audio.which() == 0 /* InputFile::Ptr */) {
auto file = boost::get<InputFile::Ptr>(audio);
@@ -164,6 +257,12 @@ Message::Ptr Api::sendAudio(std::int64_t chatId, boost::variant<InputFile::Ptr,
if (!caption.empty()) {
args.emplace_back("caption", caption);
}
+ if (!parseMode.empty()) {
+ args.emplace_back("parse_mode", parseMode);
+ }
+ if (!captionEntities.empty()) {
+ args.emplace_back("caption_entities", _tgTypeParser.parseArray<MessageEntity>(&TgTypeParser::parseMessageEntity, captionEntities));
+ }
if (duration) {
args.emplace_back("duration", duration);
}
@@ -182,24 +281,36 @@ Message::Ptr Api::sendAudio(std::int64_t chatId, boost::variant<InputFile::Ptr,
args.emplace_back("thumb", thumbStr);
}
}
+ if (disableNotification) {
+ args.emplace_back("disable_notification", disableNotification);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
}
- if (!parseMode.empty()) {
- args.emplace_back("parse_mode", parseMode);
- }
- if (disableNotification) {
- args.emplace_back("disable_notification", disableNotification);
- }
+
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendAudio", args));
}
-Message::Ptr Api::sendDocument(std::int64_t chatId, boost::variant<InputFile::Ptr, std::string> document, boost::variant<InputFile::Ptr, std::string> thumb, const string& caption, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
+Message::Ptr Api::sendDocument(std::int64_t chatId,
+ boost::variant<InputFile::Ptr, std::string> document,
+ boost::variant<InputFile::Ptr, 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 disableContentTypeDetection,
+ bool allowSendingWithoutReply) const {
vector<HttpReqArg> args;
- args.reserve(8);
+ args.reserve(11);
+
args.emplace_back("chat_id", chatId);
if (document.which() == 0 /* InputFile::Ptr */) {
auto file = boost::get<InputFile::Ptr>(document);
@@ -219,24 +330,48 @@ Message::Ptr Api::sendDocument(std::int64_t chatId, boost::variant<InputFile::Pt
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 (!captionEntities.empty()) {
+ args.emplace_back("caption_entities", _tgTypeParser.parseArray<MessageEntity>(&TgTypeParser::parseMessageEntity, captionEntities));
+ }
+ if (disableContentTypeDetection) {
+ args.emplace_back("disable_content_type_detection", disableContentTypeDetection);
+ }
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (replyToMessageId) {
+ args.emplace_back("reply_to_message_id", replyToMessageId);
+ }
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
+ if (replyMarkup) {
+ args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
+ }
+
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendDocument", args));
}
-Message::Ptr Api::sendVideo(std::int64_t chatId, boost::variant<InputFile::Ptr, 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 string& caption, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
+Message::Ptr Api::sendVideo(std::int64_t chatId,
+ boost::variant<InputFile::Ptr, 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,
+ std::int32_t replyToMessageId,
+ GenericReply::Ptr replyMarkup,
+ const std::string& parseMode,
+ bool disableNotification,
+ const std::vector<MessageEntity::Ptr>& captionEntities,
+ bool allowSendingWithoutReply) const {
vector<HttpReqArg> args;
- args.reserve(12);
+ args.reserve(14);
+
args.emplace_back("chat_id", chatId);
if (video.which() == 0 /* InputFile::Ptr */) {
auto file = boost::get<InputFile::Ptr>(video);
@@ -244,9 +379,6 @@ Message::Ptr Api::sendVideo(std::int64_t chatId, boost::variant<InputFile::Ptr,
} else /* std::string */ {
args.emplace_back("video", boost::get<std::string>(video));
}
- if (supportsStreaming) {
- args.emplace_back("supports_streaming", supportsStreaming);
- }
if (duration) {
args.emplace_back("duration", duration);
}
@@ -268,24 +400,47 @@ Message::Ptr Api::sendVideo(std::int64_t chatId, boost::variant<InputFile::Ptr,
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 (!captionEntities.empty()) {
+ args.emplace_back("caption_entities", _tgTypeParser.parseArray<MessageEntity>(&TgTypeParser::parseMessageEntity, captionEntities));
+ }
+ if (supportsStreaming) {
+ args.emplace_back("supports_streaming", supportsStreaming);
+ }
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (replyToMessageId) {
+ args.emplace_back("reply_to_message_id", replyToMessageId);
+ }
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
+ if (replyMarkup) {
+ args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
+ }
+
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVideo", args));
}
-Message::Ptr Api::sendAnimation(std::int64_t chatId, boost::variant<InputFile::Ptr, std::string> animation, std::int32_t duration, std::int32_t width, std::int32_t height, boost::variant<InputFile::Ptr, std::string> thumb, const string& caption, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
+Message::Ptr Api::sendAnimation(std::int64_t chatId,
+ boost::variant<InputFile::Ptr, std::string> animation,
+ std::int32_t duration,
+ std::int32_t width,
+ std::int32_t height,
+ boost::variant<InputFile::Ptr, 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 {
vector<HttpReqArg> args;
- args.reserve(11);
+ args.reserve(13);
+
args.emplace_back("chat_id", chatId);
if (animation.which() == 0 /* InputFile::Ptr */) {
auto file = boost::get<InputFile::Ptr>(animation);
@@ -314,24 +469,41 @@ Message::Ptr Api::sendAnimation(std::int64_t chatId, boost::variant<InputFile::P
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 (!captionEntities.empty()) {
+ args.emplace_back("caption_entities", _tgTypeParser.parseArray<MessageEntity>(&TgTypeParser::parseMessageEntity, captionEntities));
+ }
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (replyToMessageId) {
+ args.emplace_back("reply_to_message_id", replyToMessageId);
+ }
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
+ if (replyMarkup) {
+ args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
+ }
+
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendAnimation", args));
}
-Message::Ptr Api::sendVoice(std::int64_t chatId, boost::variant<InputFile::Ptr, std::string> voice, const string& caption, int duration, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
+Message::Ptr Api::sendVoice(std::int64_t chatId,
+ boost::variant<InputFile::Ptr, std::string> voice,
+ const std::string& caption,
+ std::int32_t duration,
+ std::int32_t replyToMessageId,
+ GenericReply::Ptr replyMarkup,
+ const std::string& parseMode,
+ bool disableNotification,
+ const std::vector<MessageEntity::Ptr>& captionEntities,
+ bool allowSendingWithoutReply) const {
vector<HttpReqArg> args;
- args.reserve(8);
+ args.reserve(10);
+
args.emplace_back("chat_id", chatId);
if (voice.which() == 0 /* InputFile::Ptr */) {
auto file = boost::get<InputFile::Ptr>(voice);
@@ -342,27 +514,43 @@ Message::Ptr Api::sendVoice(std::int64_t chatId, boost::variant<InputFile::Ptr,
if (!caption.empty()) {
args.emplace_back("caption", caption);
}
+ if (!parseMode.empty()) {
+ args.emplace_back("parse_mode", parseMode);
+ }
+ if (!captionEntities.empty()) {
+ args.emplace_back("caption_entities", _tgTypeParser.parseArray<MessageEntity>(&TgTypeParser::parseMessageEntity, captionEntities));
+ }
if (duration) {
args.emplace_back("duration", duration);
}
+ if (disableNotification) {
+ args.emplace_back("disable_notification", disableNotification);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
}
- if (!parseMode.empty()) {
- args.emplace_back("parse_mode", parseMode);
- }
- if (disableNotification) {
- args.emplace_back("disable_notification", disableNotification);
- }
+
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVoice", args));
}
-Message::Ptr Api::sendVideoNote(std::int64_t chatId, boost::variant<InputFile::Ptr, std::string> videoNote, std::int64_t replyToMessageId, bool disableNotification, std::int32_t duration, std::int32_t length, boost::variant<InputFile::Ptr, std::string> thumb, const GenericReply::Ptr replyMarkup) const {
+Message::Ptr Api::sendVideoNote(std::int64_t chatId,
+ boost::variant<InputFile::Ptr, std::string> videoNote,
+ std::int64_t replyToMessageId,
+ bool disableNotification,
+ std::int32_t duration,
+ std::int32_t length,
+ boost::variant<InputFile::Ptr, std::string> thumb,
+ GenericReply::Ptr replyMarkup,
+ bool allowSendingWithoutReply) const {
vector<HttpReqArg> args;
- args.reserve(8);
+ args.reserve(9);
+
args.emplace_back("chat_id", chatId);
if (videoNote.which() == 0 /* InputFile::Ptr */) {
auto file = boost::get<InputFile::Ptr>(videoNote);
@@ -370,9 +558,6 @@ Message::Ptr Api::sendVideoNote(std::int64_t chatId, boost::variant<InputFile::P
} else /* std::string */ {
args.emplace_back("video_note", boost::get<std::string>(videoNote));
}
- if (disableNotification) {
- args.emplace_back("disable_notification", disableNotification);
- }
if (duration) {
args.emplace_back("duration", duration);
}
@@ -388,52 +573,99 @@ Message::Ptr Api::sendVideoNote(std::int64_t chatId, boost::variant<InputFile::P
args.emplace_back("thumb", thumbStr);
}
}
- if (replyMarkup) {
- args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
+ if (disableNotification) {
+ args.emplace_back("disable_notification", disableNotification);
}
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
+ if (replyMarkup) {
+ args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
+ }
+
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVideoNote", args));
}
-vector<Message::Ptr> Api::sendMediaGroup(std::int64_t chatId, const vector<InputMedia::Ptr>& media, bool disableNotification, std::int32_t replyToMessageId) const {
+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<HttpReqArg> args;
- args.reserve(4);
+ args.reserve(5);
+
args.emplace_back("chat_id", chatId);
- string mediaJson = _tgTypeParser.parseArray<InputMedia>(&TgTypeParser::parseInputMedia, media);
- args.emplace_back("media", mediaJson);
- args.emplace_back("disable_notification", disableNotification);
- args.emplace_back("reply_to_message_id", replyToMessageId);
+ args.emplace_back("media", _tgTypeParser.parseArray<InputMedia>(&TgTypeParser::parseInputMedia, media));
+ if (disableNotification) {
+ args.emplace_back("disable_notification", disableNotification);
+ }
+ if (replyToMessageId != 0) {
+ args.emplace_back("reply_to_message_id", replyToMessageId);
+ }
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
+
return _tgTypeParser.parseJsonAndGetArray<Message>(&TgTypeParser::parseJsonAndGetMessage, sendRequest("sendMediaGroup", args));
}
-Message::Ptr Api::sendLocation(std::int64_t chatId, float latitude, float longitude, std::uint32_t livePeriod, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendLocation(std::int64_t chatId,
+ float latitude,
+ float longitude,
+ std::uint32_t livePeriod,
+ std::int32_t replyToMessageId,
+ GenericReply::Ptr replyMarkup,
+ bool disableNotification,
+ float horizontalAccuracy,
+ std::uint32_t heading,
+ std::uint32_t proximityAlertRadius,
+ bool allowSendingWithoutReply) const {
vector<HttpReqArg> args;
- args.reserve(7);
+ args.reserve(11);
+
args.emplace_back("chat_id", chatId);
args.emplace_back("latitude", latitude);
args.emplace_back("longitude", longitude);
+ if (horizontalAccuracy) {
+ args.emplace_back("horizontal_accuracy", horizontalAccuracy);
+ }
if (livePeriod) {
args.emplace_back("live_period", livePeriod);
}
+ if (heading) {
+ args.emplace_back("heading", heading);
+ }
+ if (proximityAlertRadius) {
+ args.emplace_back("proximity_alert_radius", proximityAlertRadius);
+ }
+ if (disableNotification) {
+ args.emplace_back("disable_notification", disableNotification);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
}
- if (disableNotification) {
- args.emplace_back("disable_notification", disableNotification);
- }
+
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendLocation", args));
}
-Message::Ptr Api::editMessageLiveLocation(float latitude, float longitude, std::int64_t chatId, std::int32_t messageId, std::int32_t inlineMessageId, const InlineKeyboardMarkup::Ptr replyMarkup) const {
+Message::Ptr Api::editMessageLiveLocation(float latitude,
+ float longitude,
+ std::int64_t chatId,
+ std::int32_t messageId,
+ std::int32_t inlineMessageId,
+ InlineKeyboardMarkup::Ptr replyMarkup,
+ float horizontalAccuracy,
+ std::int32_t heading,
+ std::int32_t proximityAlertRadius) const {
vector<HttpReqArg> args;
- args.reserve(6);
- args.emplace_back("latitude", latitude);
- args.emplace_back("longitude", longitude);
+ args.reserve(9);
+
if (chatId) {
args.emplace_back("chat_id", chatId);
}
@@ -443,9 +675,21 @@ Message::Ptr Api::editMessageLiveLocation(float latitude, float longitude, std::
if (inlineMessageId) {
args.emplace_back("inline_message_id", inlineMessageId);
}
+ args.emplace_back("latitude", latitude);
+ args.emplace_back("longitude", longitude);
+ if (horizontalAccuracy) {
+ args.emplace_back("horizontal_accuracy", horizontalAccuracy);
+ }
+ if (heading) {
+ args.emplace_back("heading", heading);
+ }
+ if (proximityAlertRadius) {
+ args.emplace_back("proximity_alert_radius", proximityAlertRadius);
+ }
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseInlineKeyboardMarkup(replyMarkup));
}
+
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("editMessageLiveLocation", args));
}
@@ -467,9 +711,22 @@ Message::Ptr Api::stopMessageLiveLocation(std::int64_t chatId, std::int32_t mess
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("editMessageLiveLocation", args));
}
-Message::Ptr Api::sendVenue(std::int64_t chatId, float latitude, float longitude, const string& title, const string& address, const string& foursquareId, const string& foursquareType, bool disableNotification, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const {
+Message::Ptr Api::sendVenue(std::int64_t chatId,
+ float latitude,
+ float longitude,
+ const std::string& title,
+ const std::string& address,
+ const std::string& foursquareId,
+ const std::string& foursquareType,
+ bool disableNotification,
+ std::int32_t replyToMessageId,
+ GenericReply::Ptr replyMarkup,
+ const std::string& googlePlaceId,
+ const std::string& googlePlaceType,
+ bool allowSendingWithoutReply) const {
vector<HttpReqArg> args;
- args.reserve(10);
+ args.reserve(13);
+
args.emplace_back("chat_id", chatId);
args.emplace_back("latitude", latitude);
args.emplace_back("longitude", longitude);
@@ -481,21 +738,40 @@ Message::Ptr Api::sendVenue(std::int64_t chatId, float latitude, float longitude
if (!foursquareType.empty()) {
args.emplace_back("foursquare_type", foursquareType);
}
+ if (!googlePlaceId.empty()) {
+ args.emplace_back("google_place_id", googlePlaceId);
+ }
+ if (!googlePlaceType.empty()) {
+ args.emplace_back("google_place_type", googlePlaceType);
+ }
+ if (disableNotification) {
+ args.emplace_back("disable_notification", disableNotification);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
}
- if (disableNotification) {
- args.emplace_back("disable_notification", disableNotification);
- }
+
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVenue", args));
}
-Message::Ptr Api::sendContact(std::int64_t chatId, const string& phoneNumber, const string& firstName, const string& lastName, const string& vcard, bool disableNotification, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const {
+Message::Ptr Api::sendContact(std::int64_t chatId,
+ const std::string& phoneNumber,
+ const std::string& firstName,
+ const std::string& lastName,
+ const std::string& vcard,
+ bool disableNotification,
+ std::int32_t replyToMessageId,
+ GenericReply::Ptr replyMarkup,
+ bool allowSendingWithoutReply) const {
vector<HttpReqArg> args;
- args.reserve(8);
+ args.reserve(9);
+
args.emplace_back("chat_id", chatId);
args.emplace_back("phone_number", phoneNumber);
args.emplace_back("first_name", firstName);
@@ -505,25 +781,41 @@ Message::Ptr Api::sendContact(std::int64_t chatId, const string& phoneNumber, co
if (!vcard.empty()) {
args.emplace_back("vcard", vcard);
}
+ if (disableNotification) {
+ args.emplace_back("disable_notification", disableNotification);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
}
- if (disableNotification) {
- args.emplace_back("disable_notification", disableNotification);
- }
+
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendContact", args));
}
-Message::Ptr Api::sendPoll(std::int64_t chatId, const std::string& question, const std::vector<std::string>& options,
- bool isAnonymous, const std::string& type, bool allowsMultipleAnswers,
- std::int32_t correctOptionId, const std::string& explanation, const std::string& explanationParseMode,
- std::int32_t openPeriod, std::int64_t closeDate, bool isClosed,
- bool disableNotification, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup) const {
- vector<HttpReqArg> args;
- args.reserve(15);
+Message::Ptr Api::sendPoll(std::int64_t chatId,
+ const std::string& question,
+ const std::vector<std::string>& options,
+ bool disableNotification,
+ std::int32_t replyToMessageId,
+ GenericReply::Ptr replyMarkup,
+ bool isAnonymous,
+ const std::string& type,
+ bool allowsMultipleAnswers,
+ std::int32_t correctOptionId,
+ const std::string& explanation,
+ const std::string& explanationParseMode,
+ const std::vector<MessageEntity::Ptr>& explanationEntities,
+ std::int32_t openPeriod,
+ std::int32_t closeDate,
+ bool isClosed,
+ bool allowSendingWithoutReply) const {
+ vector<HttpReqArg> args;
+ args.reserve(17);
args.emplace_back("chat_id", chatId);
args.emplace_back("question", question);
@@ -548,6 +840,9 @@ Message::Ptr Api::sendPoll(std::int64_t chatId, const std::string& question, con
if (!explanationParseMode.empty()) {
args.emplace_back("explanation_parse_mode", explanationParseMode);
}
+ if (!explanationEntities.empty()) {
+ args.emplace_back("explanation_entities", _tgTypeParser.parseArray<MessageEntity>(&TgTypeParser::parseMessageEntity, explanationEntities));
+ }
if (openPeriod != 0) {
args.emplace_back("open_period", openPeriod);
}
@@ -563,6 +858,9 @@ Message::Ptr Api::sendPoll(std::int64_t chatId, const std::string& question, con
if (replyToMessageId != 0) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
}
@@ -570,21 +868,24 @@ Message::Ptr Api::sendPoll(std::int64_t chatId, const std::string& question, con
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendPoll", args));
}
-Message::Ptr Api::sendDice(std::int64_t chatId, const std::string& emoji, bool disableNotification,
- std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup) const {
+Message::Ptr Api::sendDice(std::int64_t chatId,
+ bool disableNotification,
+ std::int32_t replyToMessageId,
+ GenericReply::Ptr replyMarkup,
+ const std::string& emoji,
+ bool allowSendingWithoutReply) const {
vector<HttpReqArg> args;
- args.reserve(5);
+ args.reserve(6);
args.emplace_back("chat_id", chatId);
- if (disableNotification) {
- args.emplace_back("disable_notification", disableNotification);
- }
if (!emoji.empty()) {
args.emplace_back("emoji", emoji);
}
+ args.emplace_back("disable_notification", disableNotification);
if (replyToMessageId != 0) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
}
@@ -592,12 +893,15 @@ Message::Ptr Api::sendDice(std::int64_t chatId, const std::string& emoji, bool d
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendDice", args));
}
-void Api::sendChatAction(std::int64_t chatId, const string& action) const {
+bool Api::sendChatAction(std::int64_t chatId,
+ const std::string& action) const {
vector<HttpReqArg> args;
args.reserve(2);
+
args.emplace_back("chat_id", chatId);
args.emplace_back("action", action);
- sendRequest("sendChatAction", args);
+
+ return sendRequest("sendChatAction", args).get<bool>("", false);
}
UserProfilePhotos::Ptr Api::getUserProfilePhotos(std::int64_t userId, std::int32_t offset, std::int32_t limit) const {
@@ -631,22 +935,29 @@ string Api::downloadFile(const string& filePath, const std::vector<HttpReqArg>&
return serverResponse;
}
-bool Api::kickChatMember(std::int64_t chatId, std::int64_t userId, std::uint64_t untilDate) const {
+bool Api::banChatMember(std::int64_t chatId,
+ std::int64_t userId,
+ std::uint64_t untilDate,
+ bool revokeMessages) const {
vector<HttpReqArg> args;
- args.reserve(3);
+ args.reserve(4);
+
args.emplace_back("chat_id", chatId);
args.emplace_back("user_id", userId);
- if (untilDate) {
- args.emplace_back("until_date", untilDate);
- }
- return sendRequest("kickChatMember", args).get<bool>("", false);
+ args.emplace_back("until_date", untilDate);
+ args.emplace_back("revoke_messages", revokeMessages);
+
+ return sendRequest("banChatMember", args).get<bool>("", false);
}
-bool Api::unbanChatMember(std::int64_t chatId, std::int64_t userId) const {
+bool Api::unbanChatMember(std::int64_t chatId, std::int64_t userId, bool onlyIfBanned) const {
vector<HttpReqArg> args;
- args.reserve(2);
+ args.reserve(3);
+
args.emplace_back("chat_id", chatId);
args.emplace_back("user_id", userId);
+ args.emplace_back("only_if_banned", onlyIfBanned);
+
return sendRequest("unbanChatMember", args).get<bool>("", false);
}
@@ -664,14 +975,29 @@ bool Api::restrictChatMember(std::int64_t chatId, std::int64_t userId, TgBot::Ch
return sendRequest("restrictChatMember", args).get<bool>("", false);
}
-bool Api::promoteChatMember(std::int64_t chatId, std::int64_t userId, bool canChangeInfo, bool canPostMessages,
- bool canEditMessages, bool canDeleteMessages, bool canInviteUsers, bool canPinMessages, bool canPromoteMembers) const {
+bool Api::promoteChatMember(std::int64_t chatId,
+ std::int64_t userId,
+ bool canChangeInfo,
+ bool canPostMessages,
+ bool canEditMessages,
+ bool canDeleteMessages,
+ bool canInviteUsers,
+ bool canPinMessages,
+ bool canPromoteMembers,
+ bool isAnonymous,
+ bool canManageChat,
+ bool canManageVoiceChats,
+ bool canRestrictMembers) const {
vector<HttpReqArg> args;
- args.reserve(9);
+ args.reserve(13);
+
args.emplace_back("chat_id", chatId);
args.emplace_back("user_id", userId);
- if (canChangeInfo) {
- args.emplace_back("can_change_info", canChangeInfo);
+ if (isAnonymous) {
+ args.emplace_back("is_anonymous", isAnonymous);
+ }
+ if (canManageChat) {
+ args.emplace_back("can_manage_chat", canManageChat);
}
if (canPostMessages) {
args.emplace_back("can_post_messages", canPostMessages);
@@ -682,15 +1008,25 @@ bool Api::promoteChatMember(std::int64_t chatId, std::int64_t userId, bool canCh
if (canDeleteMessages) {
args.emplace_back("can_delete_messages", canDeleteMessages);
}
+ if (canManageVoiceChats) {
+ args.emplace_back("can_manage_voice_chats", canManageVoiceChats);
+ }
+ if (canRestrictMembers) {
+ args.emplace_back("can_restrict_members", canRestrictMembers);
+ }
+ if (canPromoteMembers) {
+ args.emplace_back("can_promote_members", canPromoteMembers);
+ }
+ if (canChangeInfo) {
+ args.emplace_back("can_change_info", canChangeInfo);
+ }
if (canInviteUsers) {
args.emplace_back("can_invite_users", canInviteUsers);
}
if (canPinMessages) {
args.emplace_back("can_pin_messages", canPinMessages);
}
- if (canPromoteMembers) {
- args.emplace_back("can_promote_members", canPromoteMembers);
- }
+
return sendRequest("promoteChatMember", args).get<bool>("", false);
}
@@ -705,6 +1041,28 @@ bool Api::setChatAdministratorCustomTitle(std::int64_t chatId, std::int64_t user
return sendRequest("setChatAdministratorCustomTitle", args).get<bool>("", false);
}
+bool Api::banChatSenderChat(std::int64_t chatId,
+ std::int64_t senderChatId) const {
+ vector<HttpReqArg> args;
+ args.reserve(2);
+
+ args.emplace_back("chat_id", chatId);
+ args.emplace_back("sender_chat_id", senderChatId);
+
+ return sendRequest("banChatSenderChat", args).get<bool>("", false);
+}
+
+bool Api::unbanChatSenderChat(std::int64_t chatId,
+ std::int64_t senderChatId) const {
+ vector<HttpReqArg> args;
+ args.reserve(2);
+
+ args.emplace_back("chat_id", chatId);
+ args.emplace_back("sender_chat_id", senderChatId);
+
+ return sendRequest("unbanChatSenderChat", args).get<bool>("", false);
+}
+
bool Api::setChatPermissions(std::int64_t chatId, ChatPermissions::Ptr permissions) const {
vector<HttpReqArg> args;
args.reserve(2);
@@ -720,6 +1078,91 @@ string Api::exportChatInviteLink(std::int64_t chatId) const {
return sendRequest("exportChatInviteLink", args).get("", "");
}
+ChatInviteLink::Ptr Api::createChatInviteLink(std::int64_t chatId,
+ std::int32_t expireDate,
+ std::int32_t memberLimit,
+ const std::string& name,
+ bool createsJoinRequest) const {
+ vector<HttpReqArg> args;
+ args.reserve(5);
+
+ args.emplace_back("chat_id", chatId);
+ if (!name.empty()) {
+ args.emplace_back("name", name);
+ }
+ if (expireDate != 0) {
+ args.emplace_back("expire_date", expireDate);
+ }
+ if (memberLimit != 0) {
+ args.emplace_back("member_limit", memberLimit);
+ }
+ if (createsJoinRequest) {
+ args.emplace_back("createsJoinRequest", createsJoinRequest);
+ }
+
+ return _tgTypeParser.parseJsonAndGetChatInviteLink(sendRequest("createChatInviteLink", args));
+}
+
+ChatInviteLink::Ptr Api::editChatInviteLink(std::int64_t chatId,
+ std::string inviteLink,
+ std::int32_t expireDate,
+ std::int32_t memberLimit,
+ const std::string& name,
+ bool createsJoinRequest) const {
+ vector<HttpReqArg> args;
+ args.reserve(6);
+
+ args.emplace_back("chat_id", chatId);
+ args.emplace_back("invite_link", inviteLink);
+ if (!name.empty()) {
+ args.emplace_back("name", name);
+ }
+ if (expireDate != 0) {
+ args.emplace_back("expire_date", expireDate);
+ }
+ if (memberLimit != 0) {
+ args.emplace_back("member_limit", memberLimit);
+ }
+ if (createsJoinRequest) {
+ args.emplace_back("createsJoinRequest", createsJoinRequest);
+ }
+
+ return _tgTypeParser.parseJsonAndGetChatInviteLink(sendRequest("editChatInviteLink", args));
+}
+
+ChatInviteLink::Ptr Api::revokeChatInviteLink(std::int64_t chatId,
+ std::string inviteLink) const {
+ vector<HttpReqArg> args;
+ args.reserve(2);
+
+ args.emplace_back("chat_id", chatId);
+ args.emplace_back("invite_link", inviteLink);
+
+ return _tgTypeParser.parseJsonAndGetChatInviteLink(sendRequest("revokeChatInviteLink", args));
+}
+
+bool Api::approveChatJoinRequest(std::int64_t chatId,
+ std::int64_t userId) const {
+ vector<HttpReqArg> args;
+ args.reserve(2);
+
+ args.emplace_back("chat_id", chatId);
+ args.emplace_back("user_id", userId);
+
+ return sendRequest("approveChatJoinRequest", args).get<bool>("", false);
+}
+
+bool Api::declineChatJoinRequest(std::int64_t chatId,
+ std::int64_t userId) const {
+ vector<HttpReqArg> args;
+ args.reserve(2);
+
+ args.emplace_back("chat_id", chatId);
+ args.emplace_back("user_id", userId);
+
+ return sendRequest("declineChatJoinRequest", args).get<bool>("", false);
+}
+
bool Api::setChatPhoto(std::int64_t chatId, const InputFile::Ptr photo) const {
vector<HttpReqArg> args;
args.reserve(2);
@@ -762,13 +1205,25 @@ bool Api::pinChatMessage(std::int64_t chatId, std::int32_t messageId, bool disab
return sendRequest("pinChatMessage", args).get<bool>("", false);
}
-bool Api::unpinChatMessage(std::int64_t chatId) const {
+bool Api::unpinChatMessage(std::int64_t chatId, std::int32_t messageId) const {
vector<HttpReqArg> args;
- args.reserve(1);
+ args.reserve(2);
+
args.emplace_back("chat_id", chatId);
+ args.emplace_back("message_id", messageId);
+
return sendRequest("unpinChatMessage", args).get<bool>("", false);
}
+bool Api::unpinAllChatMessages(std::int64_t chatId) const {
+ vector<HttpReqArg> args;
+ args.reserve(1);
+
+ args.emplace_back("chat_id", chatId);
+
+ return sendRequest("unpinAllChatMessages", args).get<bool>("", false);
+}
+
bool Api::leaveChat(std::int64_t chatId) const {
vector<HttpReqArg> args;
args.reserve(1);
@@ -779,7 +1234,9 @@ bool Api::leaveChat(std::int64_t chatId) const {
Chat::Ptr Api::getChat(std::int64_t chatId) const {
vector<HttpReqArg> args;
args.reserve(1);
+
args.emplace_back("chat_id", chatId);
+
return _tgTypeParser.parseJsonAndGetChat(sendRequest("getChat", args));
}
@@ -790,11 +1247,13 @@ vector<ChatMember::Ptr> Api::getChatAdministrators(std::int64_t chatId) const {
return _tgTypeParser.parseJsonAndGetArray<ChatMember>(&TgTypeParser::parseJsonAndGetChatMember, sendRequest("getChatAdministrators", args));
}
-int32_t Api::getChatMembersCount(std::int64_t chatId) const {
+int32_t Api::getChatMemberCount(std::int64_t chatId) const {
vector<HttpReqArg> args;
args.reserve(1);
+
args.emplace_back("chat_id", chatId);
- return sendRequest("getChatMembersCount", args).get<int32_t>("", 0);
+
+ return sendRequest("getChatMemberCount", args).get<int32_t>("", 0);
}
ChatMember::Ptr Api::getChatMember(std::int64_t chatId, std::int64_t userId) const {
@@ -839,26 +1298,64 @@ bool Api::answerCallbackQuery(const string& callbackQueryId, const string& text,
return sendRequest("answerCallbackQuery", args).get<bool>("", false);
}
-bool Api::setMyCommands(const std::vector<BotCommand::Ptr>& commands) const {
+bool Api::setMyCommands(const std::vector<BotCommand::Ptr>& commands,
+ BotCommandScope::Ptr scope,
+ const std::string& languageCode) const {
vector<HttpReqArg> args;
- args.reserve(5);
+ args.reserve(3);
- string commandsJson = _tgTypeParser.parseArray<BotCommand>(&TgTypeParser::parseBotCommand, commands);
- args.emplace_back("commands", commandsJson);
+ args.emplace_back("commands", _tgTypeParser.parseArray<BotCommand>(&TgTypeParser::parseBotCommand, commands));
+ if (scope != nullptr) {
+ args.emplace_back("scope", _tgTypeParser.parseBotCommandScope(scope));
+ }
+ if (!languageCode.empty()) {
+ args.emplace_back("language_code", languageCode);
+ }
return sendRequest("setMyCommands", args).get<bool>("", false);
}
-std::vector<BotCommand::Ptr> Api::getMyCommands() const {
- return _tgTypeParser.parseJsonAndGetArray<BotCommand>(&TgTypeParser::parseJsonAndGetBotCommand, sendRequest("getMyCommands"));
+bool Api::deleteMyCommands(BotCommandScope::Ptr scope,
+ const std::string& languageCode) const {
+ vector<HttpReqArg> args;
+ args.reserve(2);
+
+ if (scope != nullptr) {
+ args.emplace_back("scope", _tgTypeParser.parseBotCommandScope(scope));
+ }
+ if (!languageCode.empty()) {
+ args.emplace_back("language_code", languageCode);
+ }
+
+ return sendRequest("deleteMyCommands", args).get<bool>("", false);
}
-Message::Ptr Api::editMessageText(const string& text, std::int64_t chatId, std::int32_t messageId, const string& inlineMessageId,
- const string& parseMode, bool disableWebPagePreview, const GenericReply::Ptr replyMarkup) const {
+std::vector<BotCommand::Ptr> Api::getMyCommands(BotCommandScope::Ptr scope,
+ const std::string& languageCode) const {
+ vector<HttpReqArg> args;
+ args.reserve(2);
+;
+ if (scope != nullptr) {
+ args.emplace_back("scope", _tgTypeParser.parseBotCommandScope(scope));
+ }
+ if (!languageCode.empty()) {
+ args.emplace_back("language_code", languageCode);
+ }
+
+ return _tgTypeParser.parseJsonAndGetArray<BotCommand>(&TgTypeParser::parseJsonAndGetBotCommand, sendRequest("getMyCommands", args));
+}
+Message::Ptr Api::editMessageText(const std::string& text,
+ std::int64_t chatId,
+ std::int32_t messageId,
+ const std::string& inlineMessageId,
+ const std::string& parseMode,
+ bool disableWebPagePreview,
+ GenericReply::Ptr replyMarkup,
+ const std::vector<MessageEntity::Ptr>& entities) const {
vector<HttpReqArg> args;
- args.reserve(7);
- args.emplace_back("text", text);
+ args.reserve(8);
+
if (chatId) {
args.emplace_back("chat_id", chatId);
}
@@ -868,15 +1365,20 @@ Message::Ptr Api::editMessageText(const string& text, std::int64_t chatId, std::
if (!inlineMessageId.empty()) {
args.emplace_back("inline_message_id", inlineMessageId);
}
+ args.emplace_back("text", text);
if (!parseMode.empty()) {
args.emplace_back("parse_mode", parseMode);
}
+ if (!entities.empty()) {
+ args.emplace_back("entities", _tgTypeParser.parseArray<MessageEntity>(&TgTypeParser::parseMessageEntity, entities));
+ }
if (disableWebPagePreview) {
args.emplace_back("disable_web_page_preview", disableWebPagePreview);
}
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
}
+
ptree p = sendRequest("editMessageText", args);
if (p.get_child_optional("message_id")) {
return _tgTypeParser.parseJsonAndGetMessage(p);
@@ -885,25 +1387,38 @@ Message::Ptr Api::editMessageText(const string& text, std::int64_t chatId, std::
}
}
-Message::Ptr Api::editMessageCaption(std::int64_t chatId, std::int32_t messageId, const string& caption,
- const string& inlineMessageId, const GenericReply::Ptr replyMarkup) const {
+Message::Ptr Api::editMessageCaption(std::int64_t chatId,
+ std::int32_t messageId,
+ const std::string& caption,
+ const std::string& inlineMessageId,
+ GenericReply::Ptr replyMarkup,
+ const std::string& parseMode,
+ const std::vector<MessageEntity::Ptr>& captionEntities) const {
vector<HttpReqArg> args;
- args.reserve(5);
+ args.reserve(7);
+
if (chatId) {
args.emplace_back("chat_id", chatId);
}
if (messageId) {
args.emplace_back("message_id", messageId);
}
+ if (!inlineMessageId.empty()) {
+ args.emplace_back("inline_message_id", inlineMessageId);
+ }
if (!caption.empty()) {
args.emplace_back("caption", caption);
}
- if (!inlineMessageId.empty()) {
- args.emplace_back("inline_message_id", inlineMessageId);
+ if (!parseMode.empty()) {
+ args.emplace_back("parse_mode", parseMode);
+ }
+ if (!captionEntities.empty()) {
+ args.emplace_back("caption_entities", _tgTypeParser.parseArray<MessageEntity>(&TgTypeParser::parseMessageEntity, captionEntities));
}
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
}
+
ptree p = sendRequest("editMessageCaption", args);
if (p.get_child_optional("message_id")) {
return _tgTypeParser.parseJsonAndGetMessage(p);
@@ -978,9 +1493,15 @@ void Api::deleteMessage(std::int64_t chatId, std::int32_t messageId) const {
sendRequest("deleteMessage", { HttpReqArg("chat_id", chatId), HttpReqArg("message_id", messageId) });
}
-Message::Ptr Api::sendSticker(std::int64_t chatId, boost::variant<InputFile::Ptr, std::string> sticker, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendSticker(std::int64_t chatId,
+ boost::variant<InputFile::Ptr, std::string> sticker,
+ std::int32_t replyToMessageId,
+ GenericReply::Ptr replyMarkup,
+ bool disableNotification,
+ bool allowSendingWithoutReply) const {
vector<HttpReqArg> args;
- args.reserve(5);
+ args.reserve(6);
+
args.emplace_back("chat_id", chatId);
if (sticker.which() == 0 /* InputFile::Ptr */) {
auto file = boost::get<InputFile::Ptr>(sticker);
@@ -988,22 +1509,28 @@ Message::Ptr Api::sendSticker(std::int64_t chatId, boost::variant<InputFile::Ptr
} else /* std::string */ {
args.emplace_back("sticker", boost::get<std::string>(sticker));
}
+ if (disableNotification) {
+ args.emplace_back("disable_notification", disableNotification);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
}
- if (disableNotification) {
- args.emplace_back("disable_notification", disableNotification);
- }
+
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendSticker", args));
}
StickerSet::Ptr Api::getStickerSet(const string& name) const {
vector<HttpReqArg> args;
args.reserve(1);
+
args.emplace_back("name", name);
+
return _tgTypeParser.parseJsonAndGetStickerSet(sendRequest("getStickerSet", args));
}
@@ -1015,9 +1542,14 @@ File::Ptr Api::uploadStickerFile(std::int64_t userId, const InputFile::Ptr pngSt
return _tgTypeParser.parseJsonAndGetFile(sendRequest("uploadStickerFile", args));
}
-bool Api::createNewStickerSet(std::int64_t userId, const std::string& name, const std::string& title,
- const std::string& emojis, boost::variant<InputFile::Ptr, std::string> pngSticker, boost::variant<InputFile::Ptr, std::string> tgsSticker,
- bool containsMasks, MaskPosition::Ptr maskPosition) const {
+bool Api::createNewStickerSet(std::int64_t userId,
+ const std::string& name,
+ const std::string& title,
+ const std::string& emojis,
+ bool containsMasks,
+ MaskPosition::Ptr maskPosition,
+ boost::variant<InputFile::Ptr, std::string> pngSticker,
+ boost::variant<InputFile::Ptr, std::string> tgsSticker) const {
vector<HttpReqArg> args;
args.reserve(8);
@@ -1047,8 +1579,12 @@ bool Api::createNewStickerSet(std::int64_t userId, const std::string& name, cons
return sendRequest("createNewStickerSet", args).get<bool>("", false);
}
-bool Api::addStickerToSet(std::int64_t userId, const std::string& name, const std::string& emojis,
- boost::variant<InputFile::Ptr, std::string> pngSticker, boost::variant<InputFile::Ptr, std::string> tgsSticker, MaskPosition::Ptr maskPosition) const {
+bool Api::addStickerToSet(std::int64_t userId,
+ const std::string& name,
+ const std::string& emojis,
+ MaskPosition::Ptr maskPosition,
+ boost::variant<InputFile::Ptr, std::string> pngSticker,
+ boost::variant<InputFile::Ptr, std::string> tgsSticker) const {
vector<HttpReqArg> args;
args.reserve(6);
@@ -1130,23 +1666,51 @@ 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, const std::string& title, const std::string& description, const std::string& payload,
- const std::string& providerToken, const std::string& startParameter, const std::string& currency, const std::vector<LabeledPrice::Ptr>& prices,
- const std::string& providerData, const std::string& photoUrl, std::int32_t photoSize,
- std::int32_t photoWidth, std::int32_t photoHeight, bool needName,
- bool needPhoneNumber, bool needEmail, bool needShippingAddress,
- bool sendPhoneNumberToProvider, bool sendEmailToProvider, bool isFlexible,
- std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
- vector<HttpReqArg> args;
- args.reserve(23);
+Message::Ptr Api::sendInvoice(std::int64_t chatId,
+ const std::string& title,
+ const std::string& description,
+ const std::string& payload,
+ const std::string& providerToken,
+ const std::string& currency,
+ const std::vector<LabeledPrice::Ptr>& prices,
+ const std::string& providerData,
+ const std::string& photoUrl,
+ std::int32_t photoSize,
+ std::int32_t photoWidth,
+ std::int32_t photoHeight,
+ bool needName,
+ bool needPhoneNumber,
+ bool needEmail,
+ bool needShippingAddress,
+ bool sendPhoneNumberToProvider,
+ bool sendEmailToProvider,
+ bool isFlexible,
+ std::int32_t replyToMessageId,
+ GenericReply::Ptr replyMarkup,
+ bool disableNotification,
+ bool allowSendingWithoutReply,
+ std::int32_t maxTipAmount,
+ const std::vector<std::int32_t>& suggestedTipAmounts,
+ const std::string& startParameter) const {
+ vector<HttpReqArg> args;
+ args.reserve(26);
+
args.emplace_back("chat_id", chatId);
args.emplace_back("title", title);
args.emplace_back("description", description);
args.emplace_back("payload", payload);
args.emplace_back("provider_token", providerToken);
- args.emplace_back("start_parameter", startParameter);
args.emplace_back("currency", currency);
args.emplace_back("prices", _tgTypeParser.parseArray<LabeledPrice>(&TgTypeParser::parseLabeledPrice, prices));
+ args.emplace_back("max_tip_amount", maxTipAmount);
+ if (!suggestedTipAmounts.empty()) {
+ args.emplace_back("suggested_tip_amounts", _tgTypeParser.parseArray<std::int32_t>([] (const std::int32_t& option) -> std::int32_t {
+ return option;
+ }, suggestedTipAmounts));
+ }
+ if (!startParameter.empty()) {
+ args.emplace_back("start_parameter", startParameter);
+ }
if (!providerData.empty()) {
args.emplace_back("provider_data", providerData);
}
@@ -1183,15 +1747,19 @@ Message::Ptr Api::sendInvoice(std::int64_t chatId, const std::string& title, con
if (isFlexible) {
args.emplace_back("is_flexible", isFlexible);
}
+ if (disableNotification) {
+ args.emplace_back("disable_notification", disableNotification);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
}
- if (disableNotification) {
- args.emplace_back("disable_notification", disableNotification);
- }
+
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendInvoice", args));
}
@@ -1230,20 +1798,30 @@ bool Api::setPassportDataErrors(std::int64_t userId, const std::vector<PassportE
return sendRequest("setPassportDataErrors", args).get<bool>("", false);
}
-Message::Ptr Api::sendGame(std::int64_t chatId, const std::string& gameShortName, std::int32_t replyToMessageId, const InlineKeyboardMarkup::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendGame(std::int64_t chatId,
+ const std::string& gameShortName,
+ std::int32_t replyToMessageId,
+ InlineKeyboardMarkup::Ptr replyMarkup,
+ bool disableNotification,
+ bool allowSendingWithoutReply) const {
vector<HttpReqArg> args;
- args.reserve(5);
+ args.reserve(6);
+
args.emplace_back("chat_id", chatId);
args.emplace_back("game_short_name", gameShortName);
+ if (disableNotification) {
+ args.emplace_back("disable_notification", disableNotification);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
}
- if (disableNotification) {
- args.emplace_back("disable_notification", disableNotification);
- }
+
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendGame", args));
}
@@ -1270,17 +1848,14 @@ Message::Ptr Api::setGameScore(std::int64_t userId, std::int32_t score, bool for
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("setGameScore", args));
}
-vector<GameHighScore::Ptr> Api::getGameHighScores(std::int64_t userId, std::int32_t score, bool force, bool disableEditMessage, std::int64_t chatId, std::int32_t messageId, const std::string& inlineMessageId) const {
+vector<GameHighScore::Ptr> Api::getGameHighScores(std::int64_t userId,
+ std::int64_t chatId,
+ std::int32_t messageId,
+ const std::string& inlineMessageId) const {
vector<HttpReqArg> args;
- args.reserve(7);
+ args.reserve(4);
+
args.emplace_back("user_id", userId);
- args.emplace_back("score", score);
- if (force) {
- args.emplace_back("force", force);
- }
- if (disableEditMessage) {
- args.emplace_back("disable_edit_message", disableEditMessage);
- }
if (chatId) {
args.emplace_back("chat_id", chatId);
}
@@ -1290,6 +1865,7 @@ vector<GameHighScore::Ptr> Api::getGameHighScores(std::int64_t userId, std::int3
if (!inlineMessageId.empty()) {
args.emplace_back("inline_message_id", inlineMessageId);
}
+
return _tgTypeParser.parseJsonAndGetArray<GameHighScore>(&TgTypeParser::parseJsonAndGetGameHighScore, sendRequest("getGameHighScores", args));
}
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp
index 89cdd4c..e8a81d7 100644
--- a/src/TgTypeParser.cpp
+++ b/src/TgTypeParser.cpp
@@ -3,15 +3,12 @@
#include <memory>
#include <string>
-using namespace std;
-using namespace boost::property_tree;
-
namespace TgBot {
-Chat::Ptr TgTypeParser::parseJsonAndGetChat(const ptree& data) const {
- auto result(make_shared<Chat>());
- result->id = data.get<int64_t>("id", 0);
- string type = data.get<string>("type", "");
+Chat::Ptr TgTypeParser::parseJsonAndGetChat(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<Chat>());
+ result->id = data.get<std::int64_t>("id", 0);
+ std::string type = data.get<std::string>("type", "");
if (type == "private") {
result->type = Chat::Type::Private;
} else if (type == "group") {
@@ -21,26 +18,32 @@ Chat::Ptr TgTypeParser::parseJsonAndGetChat(const ptree& data) const {
} else if (type == "channel") {
result->type = Chat::Type::Channel;
}
- result->title = data.get<string>("title", "");
- result->username = data.get<string>("username", "");
- result->firstName = data.get<string>("first_name", "");
- result->lastName = data.get<string>("last_name", "");
+ result->title = data.get<std::string>("title", "");
+ result->username = data.get<std::string>("username", "");
+ result->firstName = data.get<std::string>("first_name", "");
+ result->lastName = data.get<std::string>("last_name", "");
result->photo = tryParseJson<ChatPhoto>(&TgTypeParser::parseJsonAndGetChatPhoto, data, "photo");
- result->description = data.get<string>("description", "");
- result->inviteLink = data.get<string>("invite_link", "");
+ result->bio = data.get<std::string>("bio", "");
+ result->hasPrivateForwards = data.get<bool>("has_private_forwards", false);
+ result->description = data.get<std::string>("description", "");
+ result->inviteLink = data.get<std::string>("invite_link", "");
result->pinnedMessage = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "pinned_message");
result->permissions = tryParseJson<ChatPermissions>(&TgTypeParser::parseJsonAndGetChatPermissions, data, "permissions");
- result->slowModeDelay = data.get<int32_t>("slow_mode_delay", 0);
- result->stickerSetName = data.get<string>("sticker_set_name", "");
+ result->slowModeDelay = data.get<std::int32_t>("slow_mode_delay", 0);
+ result->messageAutoDeleteTime = data.get<std::int32_t>("message_auto_delete_time", 0);
+ result->hasProtectedContent = data.get<bool>("has_protected_content", false);
+ result->stickerSetName = data.get<std::string>("sticker_set_name", "");
result->canSetStickerSet = data.get<bool>("can_set_sticker_set", false);
+ result->linkedChatId = data.get<std::int64_t>("linked_chat_id", 0);
+ result->location = tryParseJson<ChatLocation>(&TgTypeParser::parseJsonAndGetChatLocation, data, "location");
return result;
}
-string TgTypeParser::parseChat(const Chat::Ptr& object) const {
+std::string TgTypeParser::parseChat(const Chat::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "id", object->id);
if (object->type == Chat::Type::Private) {
@@ -57,37 +60,43 @@ string TgTypeParser::parseChat(const Chat::Ptr& object) const {
appendToJson(result, "first_name", object->firstName);
appendToJson(result, "last_name", object->lastName);
appendToJson(result, "photo", parseChatPhoto(object->photo));
+ appendToJson(result, "bio", object->bio);
+ appendToJson(result, "has_private_forwards", object->hasPrivateForwards);
appendToJson(result, "description", object->description);
appendToJson(result, "invite_link", object->inviteLink);
appendToJson(result, "pinned_message", parseMessage(object->pinnedMessage));
appendToJson(result, "permissions", parseChatPermissions(object->permissions));
appendToJson(result, "slow_mode_delay", object->slowModeDelay);
+ appendToJson(result, "message_auto_delete_time", object->messageAutoDeleteTime);
+ appendToJson(result, "has_protected_content", object->hasProtectedContent);
appendToJson(result, "sticker_set_name", object->stickerSetName);
appendToJson(result, "can_set_sticker_set", object->canSetStickerSet);
+ appendToJson(result, "linked_chat_id", object->linkedChatId);
+ appendToJson(result, "location", parseChatLocation(object->location));
removeLastComma(result);
result += '}';
return result;
}
-User::Ptr TgTypeParser::parseJsonAndGetUser(const ptree& data) const {
- auto result(make_shared<User>());
- result->id = data.get<int64_t>("id", 0);
+User::Ptr TgTypeParser::parseJsonAndGetUser(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<User>());
+ result->id = data.get<std::int64_t>("id", 0);
result->isBot = data.get<bool>("is_bot", false);
- result->firstName = data.get<string>("first_name", "");
- result->lastName = data.get<string>("last_name", "");
- result->username = data.get<string>("username", "");
- result->languageCode = data.get<string>("language_code", "");
+ result->firstName = data.get<std::string>("first_name", "");
+ result->lastName = data.get<std::string>("last_name", "");
+ result->username = data.get<std::string>("username", "");
+ result->languageCode = data.get<std::string>("language_code", "");
result->canJoinGroups = data.get<bool>("can_join_groups", false);
result->canReadAllGroupMessages = data.get<bool>("can_read_all_group_messages", false);
result->supportsInlineQueries = data.get<bool>("supports_inline_queries", false);
return result;
}
-string TgTypeParser::parseUser(const User::Ptr& object) const {
+std::string TgTypeParser::parseUser(const User::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "id", object->id);
appendToJson(result, "is_bot", object->isBot);
@@ -103,22 +112,22 @@ string TgTypeParser::parseUser(const User::Ptr& object) const {
return result;
}
-MessageEntity::Ptr TgTypeParser::parseJsonAndGetMessageEntity(const ptree& data) const{
- auto result(make_shared<MessageEntity>());
- result->type = data.get<string>("type", "");
- result->offset = data.get<int32_t>("offset", 0);
- result->length = data.get<int32_t>("length", 0);
- result->url = data.get<string>("url", "");
+MessageEntity::Ptr TgTypeParser::parseJsonAndGetMessageEntity(const boost::property_tree::ptree& data) const{
+ auto result(std::make_shared<MessageEntity>());
+ result->type = data.get<std::string>("type", "");
+ result->offset = data.get<std::int32_t>("offset", 0);
+ result->length = data.get<std::int32_t>("length", 0);
+ result->url = data.get<std::string>("url", "");
result->user = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "user");
- result->language = data.get<string>("language", "");
+ result->language = data.get<std::string>("language", "");
return result;
}
-string TgTypeParser::parseMessageEntity(const MessageEntity::Ptr& object) const {
+std::string TgTypeParser::parseMessageEntity(const MessageEntity::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "type", object->type);
appendToJson(result, "offset", object->offset);
@@ -131,69 +140,79 @@ string TgTypeParser::parseMessageEntity(const MessageEntity::Ptr& object) const
return result;
}
-Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const {
- auto result(make_shared<Message>());
- result->messageId = data.get<int32_t>("message_id", 0);
+Message::Ptr TgTypeParser::parseJsonAndGetMessage(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<Message>());
+ result->messageId = data.get<std::int32_t>("message_id", 0);
result->from = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "from");
- result->date = data.get<int32_t>("date", 0);
+ result->senderChat = tryParseJson<Chat>(&TgTypeParser::parseJsonAndGetChat, data, "sender_chat");
+ result->date = data.get<std::int32_t>("date", 0);
result->chat = parseJsonAndGetChat(data.find("chat")->second);
result->forwardFrom = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "forward_from");
result->forwardFromChat = tryParseJson<Chat>(&TgTypeParser::parseJsonAndGetChat, data, "forward_from_chat");
- result->forwardFromMessageId = data.get<int32_t>("forward_from_message_id", 0);
- result->forwardSignature = data.get<string>("forward_signature", "");
- result->forwardSenderName = data.get<string>("forward_sender_name", "");
- result->forwardDate = data.get<int32_t>("forward_date", 0);
+ result->forwardFromMessageId = data.get<std::int32_t>("forward_from_message_id", 0);
+ result->forwardSignature = data.get<std::string>("forward_signature", "");
+ result->forwardSenderName = data.get<std::string>("forward_sender_name", "");
+ result->forwardDate = data.get<std::int32_t>("forward_date", 0);
+ result->isAutomaticForward = data.get<bool>("is_automatic_forward", false);
result->replyToMessage = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "reply_to_message");
result->viaBot = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "via_bot");
- result->editDate = data.get<int32_t>("edit_date", 0);
- result->mediaGroupId = data.get<string>("media_group_id", "");
- result->authorSignature = data.get<string>("author_signature", "");
- result->text = data.get<string>("text", "");
+ result->editDate = data.get<std::int32_t>("edit_date", 0);
+ result->hasProtectedContent = data.get<bool>("has_protected_content", false);
+ result->mediaGroupId = data.get<std::string>("media_group_id", "");
+ result->authorSignature = data.get<std::string>("author_signature", "");
+ result->text = data.get<std::string>("text", "");
result->entities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "entities");
- result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
+ result->animation = tryParseJson<Animation>(&TgTypeParser::parseJsonAndGetAnimation, data, "animation");
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");
result->video = tryParseJson<Video>(&TgTypeParser::parseJsonAndGetVideo, data, "video");
- result->voice = tryParseJson<Voice>(&TgTypeParser::parseJsonAndGetVoice, data, "voice");
result->videoNote = tryParseJson<VideoNote>(&TgTypeParser::parseJsonAndGetVideoNote, data, "video_note");
- result->caption = data.get<string>("caption", "");
+ result->voice = tryParseJson<Voice>(&TgTypeParser::parseJsonAndGetVoice, data, "voice");
+ result->caption = data.get<std::string>("caption", "");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
result->contact = tryParseJson<Contact>(&TgTypeParser::parseJsonAndGetContact, data, "contact");
- result->location = tryParseJson<Location>(&TgTypeParser::parseJsonAndGetLocation, data, "location");
- result->venue = tryParseJson<Venue>(&TgTypeParser::parseJsonAndGetVenue, data, "venue");
- result->poll = tryParseJson<Poll>(&TgTypeParser::parseJsonAndGetPoll, data, "poll");
result->dice = tryParseJson<Dice>(&TgTypeParser::parseJsonAndGetDice, data, "dice");
+ result->game = tryParseJson<Game>(&TgTypeParser::parseJsonAndGetGame, data, "game");
+ result->poll = tryParseJson<Poll>(&TgTypeParser::parseJsonAndGetPoll, data, "poll");
+ result->venue = tryParseJson<Venue>(&TgTypeParser::parseJsonAndGetVenue, data, "venue");
+ result->location = tryParseJson<Location>(&TgTypeParser::parseJsonAndGetLocation, data, "location");
result->newChatMembers = parseJsonAndGetArray<User>(&TgTypeParser::parseJsonAndGetUser, data, "new_chat_members");
result->leftChatMember = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "left_chat_member");
- result->newChatTitle = data.get<string>("new_chat_title", "");
+ result->newChatTitle = data.get<std::string>("new_chat_title", "");
result->newChatPhoto = parseJsonAndGetArray<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "new_chat_photo");
result->deleteChatPhoto = data.get<bool>("delete_chat_photo", false);
result->groupChatCreated = data.get<bool>("group_chat_created", false);
result->supergroupChatCreated = data.get<bool>("supergroup_chat_created", false);
result->channelChatCreated = data.get<bool>("channel_chat_created", false);
- result->migrateToChatId = data.get<int64_t>("migrate_to_chat_id", 0);
- result->migrateFromChatId = data.get<int64_t>("migrate_from_chat_id", 0);
+ result->messageAutoDeleteTimerChanged = tryParseJson<MessageAutoDeleteTimerChanged>(&TgTypeParser::parseJsonAndGetMessageAutoDeleteTimerChanged, data, "message_auto_delete_timer_changed");
+ result->migrateToChatId = data.get<std::int64_t>("migrate_to_chat_id", 0);
+ result->migrateFromChatId = data.get<std::int64_t>("migrate_from_chat_id", 0);
result->pinnedMessage = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "pinned_message");
result->invoice = tryParseJson<Invoice>(&TgTypeParser::parseJsonAndGetInvoice, data, "invoice");
result->successfulPayment = tryParseJson<SuccessfulPayment>(&TgTypeParser::parseJsonAndGetSuccessfulPayment, data, "successful_payment");
- result->connectedWebsite = data.get<string>("connected_website", "");
+ result->connectedWebsite = data.get<std::string>("connected_website", "");
+ result->passportData = tryParseJson<PassportData>(&TgTypeParser::parseJsonAndGetPassportData, data, "passport_data");
result->passportData = tryParseJson<PassportData>(&TgTypeParser::parseJsonAndGetPassportData, data, "passport_data");
+ result->proximityAlertTriggered = tryParseJson<ProximityAlertTriggered>(&TgTypeParser::parseJsonAndGetProximityAlertTriggered, data, "proximity_alert_triggered");
+ result->voiceChatScheduled = tryParseJson<VoiceChatScheduled>(&TgTypeParser::parseJsonAndGetVoiceChatScheduled, data, "voice_chat_scheduled");
+ result->voiceChatStarted = tryParseJson<VoiceChatStarted>(&TgTypeParser::parseJsonAndGetVoiceChatStarted, data, "voice_chat_started");
+ result->voiceChatEnded = tryParseJson<VoiceChatEnded>(&TgTypeParser::parseJsonAndGetVoiceChatEnded, data, "voice_chat_ended");
+ result->voiceChatParticipantsInvited = tryParseJson<VoiceChatParticipantsInvited>(&TgTypeParser::parseJsonAndGetVoiceChatParticipantsInvited, data, "voice_chat_participants_invited");
result->replyMarkup = tryParseJson<InlineKeyboardMarkup>(&TgTypeParser::parseJsonAndGetInlineKeyboardMarkup, data, "reply_markup");
- result->automaticForward = data.get<bool>("is_automatic_forward", false);
return result;
}
-string TgTypeParser::parseMessage(const Message::Ptr& object) const {
+std::string TgTypeParser::parseMessage(const Message::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "message_id", object->messageId);
appendToJson(result, "from", parseUser(object->from));
+ appendToJson(result, "sender_chat", parseChat(object->senderChat));
appendToJson(result, "date", object->date);
appendToJson(result, "chat", parseChat(object->chat));
appendToJson(result, "forward_from", parseUser(object->forwardFrom));
@@ -202,29 +221,31 @@ string TgTypeParser::parseMessage(const Message::Ptr& object) const {
appendToJson(result, "forward_signature", object->forwardSignature);
appendToJson(result, "forward_sender_name", object->forwardSenderName);
appendToJson(result, "forward_date", object->forwardDate);
+ appendToJson(result, "is_automatic_forward", object->isAutomaticForward);
appendToJson(result, "reply_to_message", parseMessage(object->replyToMessage));
appendToJson(result, "via_bot", parseUser(object->viaBot));
appendToJson(result, "edit_date", object->editDate);
+ appendToJson(result, "has_protected_content", object->hasProtectedContent);
appendToJson(result, "media_group_id", object->mediaGroupId);
appendToJson(result, "author_signature", object->authorSignature);
appendToJson(result, "text", object->text);
appendToJson(result, "entities", parseArray(&TgTypeParser::parseMessageEntity, object->entities));
- appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
+ appendToJson(result, "animation", parseAnimation(object->animation));
appendToJson(result, "audio", parseAudio(object->audio));
appendToJson(result, "document", parseDocument(object->document));
- appendToJson(result, "animation", parseAnimation(object->animation));
- appendToJson(result, "game", parseGame(object->game));
appendToJson(result, "photo", parseArray(&TgTypeParser::parsePhotoSize, object->photo));
appendToJson(result, "sticker", parseSticker(object->sticker));
appendToJson(result, "video", parseVideo(object->video));
- appendToJson(result, "voice", parseVoice(object->voice));
appendToJson(result, "video_note", parseVideoNote(object->videoNote));
+ appendToJson(result, "voice", parseVoice(object->voice));
appendToJson(result, "caption", object->caption);
+ appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
appendToJson(result, "contact", parseContact(object->contact));
- appendToJson(result, "location", parseLocation(object->location));
- appendToJson(result, "venue", parseVenue(object->venue));
- appendToJson(result, "poll", parsePoll(object->poll));
appendToJson(result, "dice", parseDice(object->dice));
+ appendToJson(result, "game", parseGame(object->game));
+ appendToJson(result, "poll", parsePoll(object->poll));
+ appendToJson(result, "venue", parseVenue(object->venue));
+ appendToJson(result, "location", parseLocation(object->location));
appendToJson(result, "new_chat_members", parseArray(&TgTypeParser::parseUser, object->newChatMembers));
appendToJson(result, "left_chat_member", parseUser(object->leftChatMember));
appendToJson(result, "new_chat_title", object->newChatTitle);
@@ -233,6 +254,7 @@ string TgTypeParser::parseMessage(const Message::Ptr& object) const {
appendToJson(result, "group_chat_created", object->groupChatCreated);
appendToJson(result, "supergroup_chat_created", object->supergroupChatCreated);
appendToJson(result, "channel_chat_created", object->channelChatCreated);
+ appendToJson(result, "message_auto_delete_timer_changed", parseMessageAutoDeleteTimerChanged(object->messageAutoDeleteTimerChanged));
appendToJson(result, "migrate_to_chat_id", object->migrateToChatId);
appendToJson(result, "migrate_from_chat_id", object->migrateFromChatId);
appendToJson(result, "pinned_message", parseMessage(object->pinnedMessage));
@@ -240,28 +262,50 @@ string TgTypeParser::parseMessage(const Message::Ptr& object) const {
appendToJson(result, "successful_payment", parseSuccessfulPayment(object->successfulPayment));
appendToJson(result, "connected_website", object->connectedWebsite);
appendToJson(result, "passport_data", parsePassportData(object->passportData));
+ appendToJson(result, "proximity_alert_triggered", parseProximityAlertTriggered(object->proximityAlertTriggered));
+ appendToJson(result, "voice_chat_scheduled", parseVoiceChatScheduled(object->voiceChatScheduled));
+ appendToJson(result, "voice_chat_started", parseVoiceChatStarted(object->voiceChatStarted));
+ appendToJson(result, "voice_chat_ended", parseVoiceChatEnded(object->voiceChatEnded));
+ appendToJson(result, "voice_chat_participants_invited", parseVoiceChatParticipantsInvited(object->voiceChatParticipantsInvited));
appendToJson(result, "reply_markup", parseInlineKeyboardMarkup(object->replyMarkup));
- appendToJson(result, "is_automatic_forward", object->automaticForward);
removeLastComma(result);
result += '}';
return result;
}
-PhotoSize::Ptr TgTypeParser::parseJsonAndGetPhotoSize(const ptree& data) const {
- auto result(make_shared<PhotoSize>());
- result->fileId = data.get<string>("file_id", "");
- result->fileUniqueId = data.get<string>("file_unique_id", "");
- result->width = data.get<int32_t>("width", 0);
- result->height = data.get<int32_t>("height", 0);
- result->fileSize = data.get<int32_t>("file_size", 0);
+MessageId::Ptr TgTypeParser::parseJsonAndGetMessageId(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<MessageId>());
+ result->messageId = data.get<std::int32_t>("message_id", 0);
return result;
}
-string TgTypeParser::parsePhotoSize(const PhotoSize::Ptr& object) const {
+std::string TgTypeParser::parseMessageId(const MessageId::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
+ result += '{';
+ appendToJson(result, "message_id", object->messageId);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+PhotoSize::Ptr TgTypeParser::parseJsonAndGetPhotoSize(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<PhotoSize>());
+ result->fileId = data.get<std::string>("file_id", "");
+ result->fileUniqueId = data.get<std::string>("file_unique_id", "");
+ result->width = data.get<std::int32_t>("width", 0);
+ result->height = data.get<std::int32_t>("height", 0);
+ result->fileSize = data.get<std::int32_t>("file_size", 0);
+ return result;
+}
+
+std::string TgTypeParser::parsePhotoSize(const PhotoSize::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
result += '{';
appendToJson(result, "file_id", object->fileId);
appendToJson(result, "file_unique_id", object->fileUniqueId);
@@ -273,30 +317,32 @@ string TgTypeParser::parsePhotoSize(const PhotoSize::Ptr& object) const {
return result;
}
-Audio::Ptr TgTypeParser::parseJsonAndGetAudio(const ptree& data) const {
- auto result(make_shared<Audio>());
- result->fileId = data.get<string>("file_id", "");
- result->fileUniqueId = data.get<string>("file_unique_id", "");
- result->duration = data.get<int32_t>("duration", 0);
- result->performer = data.get<string>("performer", "");
- result->title = data.get<string>("title", "");
- result->mimeType = data.get<string>("mime_type", "");
- result->fileSize = data.get<int32_t>("file_size", 0);
+Audio::Ptr TgTypeParser::parseJsonAndGetAudio(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<Audio>());
+ result->fileId = data.get<std::string>("file_id", "");
+ result->fileUniqueId = data.get<std::string>("file_unique_id", "");
+ result->duration = data.get<std::int32_t>("duration", 0);
+ result->performer = data.get<std::string>("performer", "");
+ result->title = data.get<std::string>("title", "");
+ result->fileName = data.get<std::string>("file_name", "");
+ result->mimeType = data.get<std::string>("mime_type", "");
+ result->fileSize = data.get<std::int32_t>("file_size", 0);
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
return result;
}
-string TgTypeParser::parseAudio(const Audio::Ptr& object) const {
+std::string TgTypeParser::parseAudio(const Audio::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "file_id", object->fileId);
appendToJson(result, "file_unique_id", object->fileUniqueId);
appendToJson(result, "duration", object->duration);
appendToJson(result, "performer", object->performer);
appendToJson(result, "title", object->title);
+ appendToJson(result, "file_name", object->fileName);
appendToJson(result, "mime_type", object->mimeType);
appendToJson(result, "file_size", object->fileSize);
appendToJson(result, "thumb", parsePhotoSize(object->thumb));
@@ -305,22 +351,22 @@ string TgTypeParser::parseAudio(const Audio::Ptr& object) const {
return result;
}
-Document::Ptr TgTypeParser::parseJsonAndGetDocument(const ptree& data) const {
- auto result(make_shared<Document>());
- result->fileId = data.get<string>("file_id", "");
- result->fileUniqueId = data.get<string>("file_unique_id", "");
+Document::Ptr TgTypeParser::parseJsonAndGetDocument(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<Document>());
+ result->fileId = data.get<std::string>("file_id", "");
+ result->fileUniqueId = data.get<std::string>("file_unique_id", "");
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
- result->fileName = data.get<string>("file_name", "");
- result->mimeType = data.get<string>("mime_type", "");
- result->fileSize = data.get<int32_t>("file_size", 0);
+ result->fileName = data.get<std::string>("file_name", "");
+ result->mimeType = data.get<std::string>("mime_type", "");
+ result->fileSize = data.get<std::int32_t>("file_size", 0);
return result;
}
-string TgTypeParser::parseDocument(const Document::Ptr& object) const {
+std::string TgTypeParser::parseDocument(const Document::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "file_id", object->fileId);
appendToJson(result, "file_unique_id", object->fileUniqueId);
@@ -333,26 +379,26 @@ string TgTypeParser::parseDocument(const Document::Ptr& object) const {
return result;
}
-Sticker::Ptr TgTypeParser::parseJsonAndGetSticker(const ptree& data) const {
- auto result(make_shared<Sticker>());
- result->fileId = data.get<string>("file_id", "");
- result->fileUniqueId = data.get<string>("file_unique_id", "");
- result->width = data.get<int32_t>("width", 0);
- result->height = data.get<int32_t>("height", 0);
+Sticker::Ptr TgTypeParser::parseJsonAndGetSticker(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<Sticker>());
+ result->fileId = data.get<std::string>("file_id", "");
+ result->fileUniqueId = data.get<std::string>("file_unique_id", "");
+ result->width = data.get<std::int32_t>("width", 0);
+ result->height = data.get<std::int32_t>("height", 0);
result->isAnimated = data.get<bool>("is_animated", false);
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
- result->emoji = data.get<string>("emoji", "");
- result->setName = data.get<string>("set_name", "");
+ result->emoji = data.get<std::string>("emoji", "");
+ result->setName = data.get<std::string>("set_name", "");
result->maskPosition = tryParseJson<MaskPosition>(&TgTypeParser::parseJsonAndGetMaskPosition, data, "mask_position");
- result->fileSize = data.get<int32_t>("file_size", 0);
+ result->fileSize = data.get<std::int32_t>("file_size", 0);
return result;
}
-string TgTypeParser::parseSticker(const Sticker::Ptr& object) const {
+std::string TgTypeParser::parseSticker(const Sticker::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "file_id", object->fileId);
appendToJson(result, "file_unique_id", object->fileUniqueId);
@@ -369,10 +415,10 @@ string TgTypeParser::parseSticker(const Sticker::Ptr& object) const {
return result;
}
-StickerSet::Ptr TgTypeParser::parseJsonAndGetStickerSet(const ptree& data) const {
- auto result(make_shared<StickerSet>());
- result->name = data.get<string>("name", "");
- result->title = data.get<string>("title", "");
+StickerSet::Ptr TgTypeParser::parseJsonAndGetStickerSet(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<StickerSet>());
+ result->name = data.get<std::string>("name", "");
+ result->title = data.get<std::string>("title", "");
result->isAnimated = data.get<bool>("is_animated", false);
result->containsMasks = data.get<bool>("contains_masks", false);
result->stickers = parseJsonAndGetArray<Sticker>(&TgTypeParser::parseJsonAndGetSticker, data, "stickers");
@@ -380,11 +426,11 @@ StickerSet::Ptr TgTypeParser::parseJsonAndGetStickerSet(const ptree& data) const
return result;
}
-string TgTypeParser::parseStickerSet(const StickerSet::Ptr& object) const {
+std::string TgTypeParser::parseStickerSet(const StickerSet::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "name", object->name);
appendToJson(result, "title", object->title);
@@ -397,8 +443,8 @@ string TgTypeParser::parseStickerSet(const StickerSet::Ptr& object) const {
return result;
}
-MaskPosition::Ptr TgTypeParser::parseJsonAndGetMaskPosition(const ptree& data) const {
- auto result(make_shared<MaskPosition>());
+MaskPosition::Ptr TgTypeParser::parseJsonAndGetMaskPosition(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<MaskPosition>());
result->point = data.get("point", "");
result->xShift = data.get<float>("x_shift", 0);
result->yShift = data.get<float>("y_shift", 0);
@@ -406,11 +452,11 @@ MaskPosition::Ptr TgTypeParser::parseJsonAndGetMaskPosition(const ptree& data) c
return result;
}
-string TgTypeParser::parseMaskPosition(const MaskPosition::Ptr& object) const {
+std::string TgTypeParser::parseMaskPosition(const MaskPosition::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "point", object->point);
appendToJson(result, "x_shift", object->xShift);
@@ -421,29 +467,29 @@ string TgTypeParser::parseMaskPosition(const MaskPosition::Ptr& object) const {
return result;
}
-Poll::Ptr TgTypeParser::parseJsonAndGetPoll(const ptree& data) const {
- auto result(make_shared<Poll>());
- result->id = data.get<string>("id", "");
- result->question = data.get<string>("question", "");
+Poll::Ptr TgTypeParser::parseJsonAndGetPoll(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<Poll>());
+ result->id = data.get<std::string>("id", "");
+ result->question = data.get<std::string>("question", "");
result->options = parseJsonAndGetArray<PollOption>(&TgTypeParser::parseJsonAndGetPollOption, data, "options");
- result->totalVoterCount = data.get<int32_t>("total_voter_count", 0);
+ result->totalVoterCount = data.get<std::int32_t>("total_voter_count", 0);
result->isClosed = data.get<bool>("is_closed", false);
result->isAnonymous = data.get<bool>("is_anonymous", true);
- result->type = data.get<string>("type", "");
+ result->type = data.get<std::string>("type", "");
result->allowsMultipleAnswers = data.get<bool>("allows_multiple_answers", false);
- result->correctOptionId = data.get<int32_t>("correct_option_id", 0);
- result->explanation = data.get<string>("explanation", "");
+ result->correctOptionId = data.get<std::int32_t>("correct_option_id", 0);
+ result->explanation = data.get<std::string>("explanation", "");
result->explanationEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "explanation_entities");
- result->openPeriod = data.get<int32_t>("open_period", 0);
- result->closeDate = data.get<int64_t>("close_date", 0);
+ result->openPeriod = data.get<std::int32_t>("open_period", 0);
+ result->closeDate = data.get<std::int64_t>("close_date", 0);
return result;
}
-string TgTypeParser::parsePoll(const Poll::Ptr& object) const {
+std::string TgTypeParser::parsePoll(const Poll::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "id", object->id);
appendToJson(result, "question", object->question);
@@ -463,18 +509,18 @@ string TgTypeParser::parsePoll(const Poll::Ptr& object) const {
return result;
}
-Dice::Ptr TgTypeParser::parseJsonAndGetDice(const ptree& data) const {
- auto result(make_shared<Dice>());
- result->emoji = data.get<string>("emoji", "");
- result->value = data.get<int8_t>("value", 0);
+Dice::Ptr TgTypeParser::parseJsonAndGetDice(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<Dice>());
+ result->emoji = data.get<std::string>("emoji", "");
+ result->value = data.get<std::int32_t>("value", 0);
return result;
}
-string TgTypeParser::parseDice(const Dice::Ptr& object) const {
+std::string TgTypeParser::parseDice(const Dice::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "emoji", object->emoji);
appendToJson(result, "value", object->value);
@@ -483,21 +529,21 @@ string TgTypeParser::parseDice(const Dice::Ptr& object) const {
return result;
}
-PollAnswer::Ptr TgTypeParser::parseJsonAndGetPollAnswer(const ptree& data) const {
- auto result(make_shared<PollAnswer>());
- result->pollId = data.get<string>("poll_id", "");
+PollAnswer::Ptr TgTypeParser::parseJsonAndGetPollAnswer(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<PollAnswer>());
+ result->pollId = data.get<std::string>("poll_id", "");
result->user = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "user");
- result->optionIds = parseJsonAndGetArray<std::int32_t>([] (const ptree& innerData)->std::int32_t {
+ result->optionIds = parseJsonAndGetArray<std::int32_t>([] (const boost::property_tree::ptree& innerData)->std::int32_t {
return innerData.get<std::int32_t>(0);
}, data, "option_ids");
return result;
}
-string TgTypeParser::parsePollAnswer(const PollAnswer::Ptr& object) const {
+std::string TgTypeParser::parsePollAnswer(const PollAnswer::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "poll_id", object->pollId);
appendToJson(result, "user", parseUser(object->user));
@@ -509,18 +555,18 @@ string TgTypeParser::parsePollAnswer(const PollAnswer::Ptr& object) const {
return result;
}
-PollOption::Ptr TgTypeParser::parseJsonAndGetPollOption(const ptree& data) const {
- auto result(make_shared<PollOption>());
+PollOption::Ptr TgTypeParser::parseJsonAndGetPollOption(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<PollOption>());
result->text = data.get("text", "");
result->voterCount = data.get("voter_count", 0);
return result;
}
-string TgTypeParser::parsePollOption(const PollOption::Ptr& object) const {
+std::string TgTypeParser::parsePollOption(const PollOption::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "text", object->text);
appendToJson(result, "voter_count", object->voterCount);
@@ -529,8 +575,8 @@ string TgTypeParser::parsePollOption(const PollOption::Ptr& object) const {
return result;
}
-ChatPermissions::Ptr TgTypeParser::parseJsonAndGetChatPermissions(const ptree& data) const {
- auto result(make_shared<ChatPermissions>());
+ChatPermissions::Ptr TgTypeParser::parseJsonAndGetChatPermissions(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<ChatPermissions>());
result->canSendMessages = data.get<bool>("can_send_messages");
result->canSendMediaMessages = data.get<bool>("can_send_media_messages");
result->canSendPolls = data.get<bool>("can_send_polls");
@@ -542,11 +588,11 @@ ChatPermissions::Ptr TgTypeParser::parseJsonAndGetChatPermissions(const ptree& d
return result;
}
-string TgTypeParser::parseChatPermissions(const ChatPermissions::Ptr& object) const {
+std::string TgTypeParser::parseChatPermissions(const ChatPermissions::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "can_send_messages", object->canSendMessages);
appendToJson(result, "can_send_media_messages", object->canSendMediaMessages);
@@ -561,24 +607,45 @@ string TgTypeParser::parseChatPermissions(const ChatPermissions::Ptr& object) co
return result;
}
-Video::Ptr TgTypeParser::parseJsonAndGetVideo(const ptree& data) const {
- auto result(make_shared<Video>());
- result->fileId = data.get<string>("file_id", "");
- result->fileUniqueId = data.get<string>("file_unique_id", "");
- result->width = data.get<int32_t>("width", 0);
- result->height = data.get<int32_t>("height", 0);
- result->duration = data.get<int32_t>("duration", 0);
+ChatLocation::Ptr TgTypeParser::parseJsonAndGetChatLocation(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<ChatLocation>());
+ result->location = tryParseJson<Location>(&TgTypeParser::parseJsonAndGetLocation, data, "location");
+ result->address = data.get<std::string>("address", "");
+ return result;
+}
+
+std::string TgTypeParser::parseChatLocation(const ChatLocation::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "location", parseLocation(object->location));
+ appendToJson(result, "address", object->address);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+Video::Ptr TgTypeParser::parseJsonAndGetVideo(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<Video>());
+ result->fileId = data.get<std::string>("file_id", "");
+ result->fileUniqueId = data.get<std::string>("file_unique_id", "");
+ result->width = data.get<std::int32_t>("width", 0);
+ result->height = data.get<std::int32_t>("height", 0);
+ result->duration = data.get<std::int32_t>("duration", 0);
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
- result->mimeType = data.get<string>("mime_type", "");
- result->fileSize = data.get<int32_t>("file_size", 0);
+ result->fileName = data.get<std::string>("file_name", "");
+ result->mimeType = data.get<std::string>("mime_type", "");
+ result->fileSize = data.get<std::int32_t>("file_size", 0);
return result;
}
-string TgTypeParser::parseVideo(const Video::Ptr& object) const {
+std::string TgTypeParser::parseVideo(const Video::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "file_id", object->fileId);
appendToJson(result, "file_unique_id", object->fileUniqueId);
@@ -586,6 +653,7 @@ string TgTypeParser::parseVideo(const Video::Ptr& object) const {
appendToJson(result, "height", object->height);
appendToJson(result, "duration", object->duration);
appendToJson(result, "thumb", parsePhotoSize(object->thumb));
+ appendToJson(result, "file_name", object->fileName);
appendToJson(result, "mime_type", object->mimeType);
appendToJson(result, "file_size", object->fileSize);
removeLastComma(result);
@@ -593,21 +661,21 @@ string TgTypeParser::parseVideo(const Video::Ptr& object) const {
return result;
}
-Voice::Ptr TgTypeParser::parseJsonAndGetVoice(const ptree& data) const {
- auto result(make_shared<Voice>());
- result->fileId = data.get<string>("file_id", "");
- result->fileUniqueId = data.get<string>("file_unique_id", "");
- result->duration = data.get<int32_t>("duration", 0);
- result->mimeType = data.get<string>("mime_type", "");
- result->fileSize = data.get<int32_t>("file_size", 0);
+Voice::Ptr TgTypeParser::parseJsonAndGetVoice(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<Voice>());
+ result->fileId = data.get<std::string>("file_id", "");
+ result->fileUniqueId = data.get<std::string>("file_unique_id", "");
+ result->duration = data.get<std::int32_t>("duration", 0);
+ result->mimeType = data.get<std::string>("mime_type", "");
+ result->fileSize = data.get<std::int32_t>("file_size", 0);
return result;
}
-string TgTypeParser::parseVoice(const Voice::Ptr& object) const {
+std::string TgTypeParser::parseVoice(const Voice::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "file_id", object->fileId);
appendToJson(result, "file_unique_id", object->fileUniqueId);
@@ -619,22 +687,22 @@ string TgTypeParser::parseVoice(const Voice::Ptr& object) const {
return result;
}
-VideoNote::Ptr TgTypeParser::parseJsonAndGetVideoNote(const ptree& data) const {
- auto result(make_shared<VideoNote>());
- result->fileId = data.get<string>("file_id", "");
- result->fileUniqueId = data.get<string>("file_unique_id", "");
- result->length = data.get<int32_t>("length", 0);
- result->duration = data.get<int32_t>("duration", 0);
+VideoNote::Ptr TgTypeParser::parseJsonAndGetVideoNote(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<VideoNote>());
+ result->fileId = data.get<std::string>("file_id", "");
+ result->fileUniqueId = data.get<std::string>("file_unique_id", "");
+ result->length = data.get<std::int32_t>("length", 0);
+ result->duration = data.get<std::int32_t>("duration", 0);
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
result->fileSize = data.get("file_size", 0);
return result;
}
-string TgTypeParser::parseVideoNote(const VideoNote::Ptr& object) const {
+std::string TgTypeParser::parseVideoNote(const VideoNote::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "file_id", object->fileId);
appendToJson(result, "file_unique_id", object->fileUniqueId);
@@ -647,8 +715,8 @@ string TgTypeParser::parseVideoNote(const VideoNote::Ptr& object) const {
return result;
}
-Game::Ptr TgTypeParser::parseJsonAndGetGame(const ptree& data) const {
- auto result(make_shared<Game>());
+Game::Ptr TgTypeParser::parseJsonAndGetGame(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<Game>());
result->title = data.get("title", "");
result->description = data.get("description", "");
result->photo = parseJsonAndGetArray<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "photo");
@@ -658,11 +726,11 @@ Game::Ptr TgTypeParser::parseJsonAndGetGame(const ptree& data) const {
return result;
}
-string TgTypeParser::parseGame(const Game::Ptr& object) const {
+std::string TgTypeParser::parseGame(const Game::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "title", object->title);
appendToJson(result, "description", object->description);
@@ -675,19 +743,19 @@ string TgTypeParser::parseGame(const Game::Ptr& object) const {
return result;
}
-GameHighScore::Ptr TgTypeParser::parseJsonAndGetGameHighScore(const ptree& data) const {
- auto result(make_shared<GameHighScore>());
+GameHighScore::Ptr TgTypeParser::parseJsonAndGetGameHighScore(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<GameHighScore>());
result->position = data.get("position", "");
result->user = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "user");
- result->score = data.get<int32_t>("score", 0);
+ result->score = data.get<std::int32_t>("score", 0);
return result;
}
-string TgTypeParser::parseGameHighScore(const GameHighScore::Ptr& object) const {
+std::string TgTypeParser::parseGameHighScore(const GameHighScore::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "position", object->position);
appendToJson(result, "user", parseUser(object->user));
@@ -697,25 +765,25 @@ string TgTypeParser::parseGameHighScore(const GameHighScore::Ptr& object) const
return result;
}
-Animation::Ptr TgTypeParser::parseJsonAndGetAnimation(const ptree& data) const {
- auto result(make_shared<Animation>());
- result->fileId = data.get<string>("file_id", "");
- result->fileUniqueId = data.get<string>("file_unique_id", "");
- result->width = data.get<int32_t>("width", 0);
- result->height = data.get<int32_t>("height", 0);
- result->duration = data.get<int32_t>("duration", 0);
+Animation::Ptr TgTypeParser::parseJsonAndGetAnimation(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<Animation>());
+ result->fileId = data.get<std::string>("file_id", "");
+ result->fileUniqueId = data.get<std::string>("file_unique_id", "");
+ result->width = data.get<std::int32_t>("width", 0);
+ result->height = data.get<std::int32_t>("height", 0);
+ result->duration = data.get<std::int32_t>("duration", 0);
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
- result->fileName = data.get<string>("file_name", "");
- result->mimeType = data.get<string>("mime_type", "");
- result->fileSize = data.get<int32_t>("file_size", 0);
+ result->fileName = data.get<std::string>("file_name", "");
+ result->mimeType = data.get<std::string>("mime_type", "");
+ result->fileSize = data.get<std::int32_t>("file_size", 0);
return result;
}
-string TgTypeParser::parseAnimation(const Animation::Ptr& object) const {
+std::string TgTypeParser::parseAnimation(const Animation::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "file_id", object->fileId);
appendToJson(result, "file_unique_id", object->fileUniqueId);
@@ -731,21 +799,21 @@ string TgTypeParser::parseAnimation(const Animation::Ptr& object) const {
return result;
}
-Contact::Ptr TgTypeParser::parseJsonAndGetContact(const ptree& data) const {
- auto result(make_shared<Contact>());
- result->phoneNumber = data.get<string>("phone_number");
- result->firstName = data.get<string>("first_name");
+Contact::Ptr TgTypeParser::parseJsonAndGetContact(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<Contact>());
+ result->phoneNumber = data.get<std::string>("phone_number");
+ result->firstName = data.get<std::string>("first_name");
result->lastName = data.get("last_name", "");
result->userId = data.get("user_id", 0);
result->vcard = data.get("vcard", "");
return result;
}
-string TgTypeParser::parseContact(const Contact::Ptr& object) const {
+std::string TgTypeParser::parseContact(const Contact::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "phone_number", object->phoneNumber);
appendToJson(result, "first_name", object->firstName);
@@ -757,55 +825,173 @@ string TgTypeParser::parseContact(const Contact::Ptr& object) const {
return result;
}
-Location::Ptr TgTypeParser::parseJsonAndGetLocation(const ptree& data) const {
- auto result(make_shared<Location>());
+Location::Ptr TgTypeParser::parseJsonAndGetLocation(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<Location>());
result->longitude = data.get<float>("longitude", 0);
result->latitude = data.get<float>("latitude", 0);
+ result->horizontalAccuracy = data.get<float>("horizontal_accuracy", 0);
+ result->livePeriod = data.get<std::int32_t>("live_period", 0);
+ result->heading = data.get<std::int32_t>("heading", 0);
+ result->proximityAlertRadius = data.get<std::int32_t>("proximity_alert_radius", 0);
return result;
}
-string TgTypeParser::parseLocation(const Location::Ptr& object) const {
+std::string TgTypeParser::parseLocation(const Location::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "longitude", object->longitude);
appendToJson(result, "latitude", object->latitude);
+ appendToJson(result, "horizontal_accuracy", object->horizontalAccuracy);
+ appendToJson(result, "live_period", object->livePeriod);
+ appendToJson(result, "heading", object->heading);
+ appendToJson(result, "proximity_alert_radius", object->proximityAlertRadius);
removeLastComma(result);
result += '}';
return result;
}
-Venue::Ptr TgTypeParser::parseJsonAndGetVenue(const ptree& data) const {
- auto result(make_shared<Venue>());
+Venue::Ptr TgTypeParser::parseJsonAndGetVenue(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<Venue>());
result->location = tryParseJson<Location>(&TgTypeParser::parseJsonAndGetLocation, data, "location");
- 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", "");
+ result->title = data.get<std::string>("title", "");
+ result->address = data.get<std::string>("address", "");
+ result->foursquareId = data.get<std::string>("foursquare_id", "");
+ result->foursquareType = data.get<std::string>("foursquare_type", "");
+ result->googlePlaceId = data.get<std::string>("google_place_id", "");
+ result->googlePlaceType = data.get<std::string>("google_place_type", "");
return result;
}
-string TgTypeParser::parseVenue(const Venue::Ptr& object) const {
+std::string TgTypeParser::parseVenue(const Venue::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "location", parseLocation(object->location));
appendToJson(result, "title", object->title);
appendToJson(result, "address", object->address);
appendToJson(result, "foursquare_id", object->foursquareId);
appendToJson(result, "foursquare_type", object->foursquareType);
+ appendToJson(result, "google_place_id", object->googlePlaceId);
+ appendToJson(result, "google_place_type", object->googlePlaceType);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+ProximityAlertTriggered::Ptr TgTypeParser::parseJsonAndGetProximityAlertTriggered(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<ProximityAlertTriggered>());
+ result->traveler = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "traveler");
+ result->watcher = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "watcher");
+ result->distance = data.get<std::int32_t>("distance", 0);
+ return result;
+}
+
+std::string TgTypeParser::parseProximityAlertTriggered(const ProximityAlertTriggered::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "traveler", parseUser(object->traveler));
+ appendToJson(result, "watcher", parseUser(object->watcher));
+ appendToJson(result, "distance", object->distance);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+MessageAutoDeleteTimerChanged::Ptr TgTypeParser::parseJsonAndGetMessageAutoDeleteTimerChanged(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<MessageAutoDeleteTimerChanged>());
+ result->messageAutoDeleteTime = data.get<std::int32_t>("message_auto_delete_time", 0);
+ return result;
+}
+
+std::string TgTypeParser::parseMessageAutoDeleteTimerChanged(const MessageAutoDeleteTimerChanged::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "message_auto_delete_time", object->messageAutoDeleteTime);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+VoiceChatScheduled::Ptr TgTypeParser::parseJsonAndGetVoiceChatScheduled(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<VoiceChatScheduled>());
+ result->startDate = data.get<std::int32_t>("start_date", 0);
+ return result;
+}
+
+std::string TgTypeParser::parseVoiceChatScheduled(const VoiceChatScheduled::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "start_date", object->startDate);
removeLastComma(result);
result += '}';
return result;
}
-Update::Ptr TgTypeParser::parseJsonAndGetUpdate(const ptree& data) const {
- auto result(make_shared<Update>());
- result->updateId = data.get<int32_t>("update_id", 0);
+VoiceChatStarted::Ptr TgTypeParser::parseJsonAndGetVoiceChatStarted(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<VoiceChatStarted>());
+ return result;
+}
+
+std::string TgTypeParser::parseVoiceChatStarted(const VoiceChatStarted::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ return "{}";
+}
+
+VoiceChatEnded::Ptr TgTypeParser::parseJsonAndGetVoiceChatEnded(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<VoiceChatEnded>());
+ result->duration = data.get<std::int32_t>("duration", 0);
+ return result;
+}
+
+std::string TgTypeParser::parseVoiceChatEnded(const VoiceChatEnded::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "duration", object->duration);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+VoiceChatParticipantsInvited::Ptr TgTypeParser::parseJsonAndGetVoiceChatParticipantsInvited(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<VoiceChatParticipantsInvited>());
+ result->users = parseJsonAndGetArray<User>(&TgTypeParser::parseJsonAndGetUser, data, "users");
+ return result;
+}
+
+std::string TgTypeParser::parseVoiceChatParticipantsInvited(const VoiceChatParticipantsInvited::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "users", parseArray(&TgTypeParser::parseUser, object->users));
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+Update::Ptr TgTypeParser::parseJsonAndGetUpdate(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<Update>());
+ result->updateId = data.get<std::int32_t>("update_id", 0);
result->message = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "message");
result->editedMessage = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "edited_message");
result->channelPost = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "channel_post");
@@ -817,14 +1003,17 @@ Update::Ptr TgTypeParser::parseJsonAndGetUpdate(const ptree& data) const {
result->preCheckoutQuery = tryParseJson<PreCheckoutQuery>(&TgTypeParser::parseJsonAndGetPreCheckoutQuery, data, "pre_checkout_query");
result->poll = tryParseJson<Poll>(&TgTypeParser::parseJsonAndGetPoll, data, "poll");
result->pollAnswer = tryParseJson<PollAnswer>(&TgTypeParser::parseJsonAndGetPollAnswer, data, "poll_answer");
+ result->myChatMember = tryParseJson<ChatMemberUpdated>(&TgTypeParser::parseJsonAndGetChatMemberUpdated, data, "my_chat_member");
+ result->chatMember = tryParseJson<ChatMemberUpdated>(&TgTypeParser::parseJsonAndGetChatMemberUpdated, data, "chat_member");
+ result->chatJoinRequest = tryParseJson<ChatJoinRequest>(&TgTypeParser::parseJsonAndGetChatJoinRequest, data, "chat_join_request");
return result;
}
-string TgTypeParser::parseUpdate(const Update::Ptr& object) const {
+std::string TgTypeParser::parseUpdate(const Update::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "update_id", object->updateId);
appendToJson(result, "message", parseMessage(object->message));
@@ -838,23 +1027,26 @@ string TgTypeParser::parseUpdate(const Update::Ptr& object) const {
appendToJson(result, "pre_checkout_query", parsePreCheckoutQuery(object->preCheckoutQuery));
appendToJson(result, "poll", parsePoll(object->poll));
appendToJson(result, "poll_answer", parsePollAnswer(object->pollAnswer));
+ appendToJson(result, "my_chat_member", parseChatMemberUpdated(object->myChatMember));
+ appendToJson(result, "chat_member", parseChatMemberUpdated(object->chatMember));
+ appendToJson(result, "chat_join_request", parseChatJoinRequest(object->chatJoinRequest));
removeLastComma(result);
result += '}';
return result;
}
-UserProfilePhotos::Ptr TgTypeParser::parseJsonAndGetUserProfilePhotos(const ptree& data) const {
- auto result(make_shared<UserProfilePhotos>());
- result->totalCount = data.get<int32_t>("total_count");
+UserProfilePhotos::Ptr TgTypeParser::parseJsonAndGetUserProfilePhotos(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<UserProfilePhotos>());
+ result->totalCount = data.get<std::int32_t>("total_count");
result->photos = parseJsonAndGet2DArray<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "photos");
return result;
}
-string TgTypeParser::parseUserProfilePhotos(const UserProfilePhotos::Ptr& object) const {
+std::string TgTypeParser::parseUserProfilePhotos(const UserProfilePhotos::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "total_count", object->totalCount);
appendToJson(result, "photos", parse2DArray(&TgTypeParser::parsePhotoSize, object->photos));
@@ -863,123 +1055,191 @@ string TgTypeParser::parseUserProfilePhotos(const UserProfilePhotos::Ptr& object
return result;
}
-InputMedia::Ptr TgTypeParser::parseJsonAndGetInputMedia(const ptree& data) const {
- string type = data.get("type", "");
- if (type == "photo") {
- auto result(make_shared<InputMediaPhoto>());
- 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") {
- auto result(make_shared<InputMediaVideo>());
- 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);
- return result;
+InputMedia::Ptr TgTypeParser::parseJsonAndGetInputMedia(const boost::property_tree::ptree& data) const {
+ std::string type = data.get<std::string>("type", "");
+ InputMedia::Ptr result;
+ if (type == InputMediaPhoto::TYPE) {
+ result = std::static_pointer_cast<InputMedia>(parseJsonAndGetInputMediaPhoto(data));
+ } else if (type == InputMediaVideo::TYPE) {
+ result = std::static_pointer_cast<InputMedia>(parseJsonAndGetInputMediaVideo(data));
+ } else if (type == InputMediaAnimation::TYPE) {
+ result = std::static_pointer_cast<InputMedia>(parseJsonAndGetInputMediaAnimation(data));
+ } else if (type == InputMediaAudio::TYPE) {
+ result = std::static_pointer_cast<InputMedia>(parseJsonAndGetInputMediaAudio(data));
+ } else if (type == InputMediaDocument::TYPE) {
+ result = std::static_pointer_cast<InputMedia>(parseJsonAndGetInputMediaDocument(data));
} else {
- return nullptr;
+ result = std::make_shared<InputMedia>();
}
+
+ result->type = data.get<std::string>("type", "");
+ result->media = data.get<std::string>("media", "");
+ result->caption = data.get<std::string>("caption", "");
+ result->parseMode = data.get<std::string>("parse_mode", "");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
+
+ return result;
}
-string TgTypeParser::parseInputMedia(const InputMedia::Ptr& object) const {
+std::string TgTypeParser::parseInputMedia(const InputMedia::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
- 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, "type", object->type);
appendToJson(result, "media", object->media);
appendToJson(result, "caption", object->caption);
appendToJson(result, "parse_mode", object->parseMode);
- if (object->width) {
- appendToJson(result, "width", object->width);
+ appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
+
+ if (object->type == InputMediaPhoto::TYPE) {
+ result += parseInputMediaPhoto(std::static_pointer_cast<InputMediaPhoto>(object));
+ } else if (object->type == InputMediaVideo::TYPE) {
+ result += parseInputMediaVideo(std::static_pointer_cast<InputMediaVideo>(object));
+ } else if (object->type == InputMediaAnimation::TYPE) {
+ result += parseInputMediaAnimation(std::static_pointer_cast<InputMediaAnimation>(object));
+ } else if (object->type == InputMediaAudio::TYPE) {
+ result += parseInputMediaAudio(std::static_pointer_cast<InputMediaAudio>(object));
+ } else if (object->type == InputMediaDocument::TYPE) {
+ result += parseInputMediaDocument(std::static_pointer_cast<InputMediaDocument>(object));
}
- if (object->height) {
- appendToJson(result, "height", object->height);
+
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+InputMediaPhoto::Ptr TgTypeParser::parseJsonAndGetInputMediaPhoto(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetInputMedia().
+ auto result(std::make_shared<InputMediaPhoto>());
+ return result;
+}
+
+std::string TgTypeParser::parseInputMediaPhoto(const InputMediaPhoto::Ptr& object) const {
+ if (!object) {
+ return "";
}
- if (object->duration) {
- appendToJson(result, "duration", object->duration);
+ // This function will be called by parseInputMedia(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ // The last comma will be erased by parseInputMedia().
+ return result;
+}
+
+InputMediaVideo::Ptr TgTypeParser::parseJsonAndGetInputMediaVideo(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetInputMedia().
+ auto result(std::make_shared<InputMediaVideo>());
+ result->thumb = data.get<std::string>("thumb", "");
+ result->width = data.get<std::int32_t>("width", 0);
+ result->height = data.get<std::int32_t>("height", 0);
+ result->duration = data.get<std::int32_t>("duration", 0);
+ result->supportsStreaming = data.get<bool>("supports_streaming", false);
+ return result;
+}
+
+std::string TgTypeParser::parseInputMediaVideo(const InputMediaVideo::Ptr& object) const {
+ if (!object) {
+ return "";
}
- if (object->performer) {
- appendToJson(result, "performer", object->performer);
+ // This function will be called by parseInputMedia(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ appendToJson(result, "thumb", object->thumb);
+ appendToJson(result, "width", object->width);
+ appendToJson(result, "height", object->height);
+ appendToJson(result, "duration", object->duration);
+ appendToJson(result, "supports_streaming", object->supportsStreaming);
+ // The last comma will be erased by parseInputMedia().
+ return result;
+}
+
+InputMediaAnimation::Ptr TgTypeParser::parseJsonAndGetInputMediaAnimation(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetInputMedia().
+ auto result(std::make_shared<InputMediaAnimation>());
+ result->thumb = data.get<std::string>("thumb", "");
+ result->width = data.get<std::int32_t>("width", 0);
+ result->height = data.get<std::int32_t>("height", 0);
+ result->duration = data.get<std::int32_t>("duration", 0);
+ return result;
+}
+
+std::string TgTypeParser::parseInputMediaAnimation(const InputMediaAnimation::Ptr& object) const {
+ if (!object) {
+ return "";
}
- if (object->supportsStreaming) {
- appendToJson(result, "supports_streaming", object->supportsStreaming);
+ // This function will be called by parseInputMedia(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ appendToJson(result, "thumb", object->thumb);
+ appendToJson(result, "width", object->width);
+ appendToJson(result, "height", object->height);
+ appendToJson(result, "duration", object->duration);
+ // The last comma will be erased by parseInputMedia().
+ return result;
+}
+
+InputMediaAudio::Ptr TgTypeParser::parseJsonAndGetInputMediaAudio(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetInputMedia().
+ auto result(std::make_shared<InputMediaAudio>());
+ result->thumb = data.get<std::string>("thumb", "");
+ result->duration = data.get<std::int32_t>("duration", 0);
+ result->performer = data.get<std::string>("performer", "");
+ result->title = data.get<std::string>("title", "");
+ return result;
+}
+
+std::string TgTypeParser::parseInputMediaAudio(const InputMediaAudio::Ptr& object) const {
+ if (!object) {
+ return "";
}
- removeLastComma(result);
- result += '}';
+ // This function will be called by parseInputMedia(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ appendToJson(result, "thumb", object->thumb);
+ appendToJson(result, "duration", object->duration);
+ appendToJson(result, "performer", object->performer);
+ appendToJson(result, "title", object->title);
+ // The last comma will be erased by parseInputMedia().
+ return result;
+}
+
+InputMediaDocument::Ptr TgTypeParser::parseJsonAndGetInputMediaDocument(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetInputMedia().
+ auto result(std::make_shared<InputMediaDocument>());
+ result->thumb = data.get<std::string>("thumb", "");
+ result->disableContentTypeDetection = data.get<bool>("disable_content_type_detection", false);
+ return result;
+}
+
+std::string TgTypeParser::parseInputMediaDocument(const InputMediaDocument::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseInputMedia(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ appendToJson(result, "thumb", object->thumb);
+ appendToJson(result, "disable_content_type_detection", object->disableContentTypeDetection);
+ // The last comma will be erased by parseInputMedia().
return result;
}
-File::Ptr TgTypeParser::parseJsonAndGetFile(const ptree& data) const {
- auto result(make_shared<File>());
- result->fileId = data.get<string>("file_id", "");
- result->fileUniqueId = data.get<string>("file_unique_id", "");
- result->fileSize = data.get<int32_t>("file_size", 0);
- result->filePath = data.get<string>("file_path", "");
+File::Ptr TgTypeParser::parseJsonAndGetFile(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<File>());
+ result->fileId = data.get<std::string>("file_id", "");
+ result->fileUniqueId = data.get<std::string>("file_unique_id", "");
+ result->fileSize = data.get<std::int32_t>("file_size", 0);
+ result->filePath = data.get<std::string>("file_path", "");
return result;
}
-string TgTypeParser::parseFile(const File::Ptr& object) const {
+std::string TgTypeParser::parseFile(const File::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "file_id", object->fileId);
appendToJson(result, "file_unique_id", object->fileUniqueId);
@@ -991,12 +1251,13 @@ string TgTypeParser::parseFile(const File::Ptr& object) const {
}
ReplyKeyboardMarkup::Ptr TgTypeParser::parseJsonAndGetReplyKeyboardMarkup(const boost::property_tree::ptree& data) const {
- auto result(make_shared<ReplyKeyboardMarkup>());
+ auto result(std::make_shared<ReplyKeyboardMarkup>());
for (const auto& item : data.find("keyboard")->second){
result->keyboard.push_back(parseJsonAndGetArray<KeyboardButton>(&TgTypeParser::parseJsonAndGetKeyboardButton, item.second));
}
result->resizeKeyboard = data.get<bool>("resize_keyboard", false);
result->oneTimeKeyboard = data.get<bool>("one_time_keyboard", false);
+ result->inputFieldPlaceholder = data.get<std::string>("input_field_placeholder", "");
result->selective = data.get<bool>("selective", false);
return result;
}
@@ -1005,7 +1266,7 @@ std::string TgTypeParser::parseReplyKeyboardMarkup(const ReplyKeyboardMarkup::Pt
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
result += R"("keyboard":[)";
for (const auto& item : object->keyboard) {
@@ -1022,26 +1283,27 @@ std::string TgTypeParser::parseReplyKeyboardMarkup(const ReplyKeyboardMarkup::Pt
result += "],";
appendToJson(result, "resize_keyboard", object->resizeKeyboard);
appendToJson(result, "one_time_keyboard", object->oneTimeKeyboard);
+ appendToJson(result, "input_field_placeholder", object->inputFieldPlaceholder);
appendToJson(result, "selective", object->selective);
removeLastComma(result);
result += '}';
return result;
}
-KeyboardButton::Ptr TgTypeParser::parseJsonAndGetKeyboardButton(const ptree& data) const {
- auto result(make_shared<KeyboardButton>());
- result->text = data.get<string>("text", "");
+KeyboardButton::Ptr TgTypeParser::parseJsonAndGetKeyboardButton(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<KeyboardButton>());
+ result->text = data.get<std::string>("text", "");
result->requestContact = data.get<bool>("request_contact", false);
result->requestLocation = data.get<bool>("request_location", false);
result->requestPoll = tryParseJson<KeyboardButtonPollType>(&TgTypeParser::parseJsonAndGetKeyboardButtonPollType, data, "request_poll");
return result;
}
-string TgTypeParser::parseKeyboardButton(const KeyboardButton::Ptr& object) const {
+std::string TgTypeParser::parseKeyboardButton(const KeyboardButton::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "text", object->text);
appendToJson(result, "request_contact", object->requestContact);
@@ -1052,17 +1314,17 @@ string TgTypeParser::parseKeyboardButton(const KeyboardButton::Ptr& object) cons
return result;
}
-KeyboardButtonPollType::Ptr TgTypeParser::parseJsonAndGetKeyboardButtonPollType(const ptree& data) const {
- auto result(make_shared<KeyboardButtonPollType>());
- result->type = data.get<string>("type", "");
+KeyboardButtonPollType::Ptr TgTypeParser::parseJsonAndGetKeyboardButtonPollType(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<KeyboardButtonPollType>());
+ result->type = data.get<std::string>("type", "");
return result;
}
-string TgTypeParser::parseKeyboardButtonPollType(const KeyboardButtonPollType::Ptr& object) const {
+std::string TgTypeParser::parseKeyboardButtonPollType(const KeyboardButtonPollType::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "type", object->type);
removeLastComma(result);
@@ -1071,7 +1333,7 @@ string TgTypeParser::parseKeyboardButtonPollType(const KeyboardButtonPollType::P
}
ReplyKeyboardRemove::Ptr TgTypeParser::parseJsonAndGetReplyKeyboardRemove(const boost::property_tree::ptree& data) const {
- auto result(make_shared<ReplyKeyboardRemove>());
+ auto result(std::make_shared<ReplyKeyboardRemove>());
result->selective = data.get<bool>("selective", false);
return result;
}
@@ -1080,7 +1342,7 @@ std::string TgTypeParser::parseReplyKeyboardRemove(const ReplyKeyboardRemove::Pt
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "remove_keyboard", object->removeKeyboard);
appendToJson(result, "selective", object->selective);
@@ -1090,8 +1352,9 @@ std::string TgTypeParser::parseReplyKeyboardRemove(const ReplyKeyboardRemove::Pt
}
ForceReply::Ptr TgTypeParser::parseJsonAndGetForceReply(const boost::property_tree::ptree& data) const {
- auto result(make_shared<ForceReply>());
- result->selective = data.get<bool>("selective");
+ auto result(std::make_shared<ForceReply>());
+ result->inputFieldPlaceholder = data.get<std::string>("input_field_placeholder", "");
+ result->selective = data.get<bool>("selective", false);
return result;
}
@@ -1099,83 +1362,292 @@ std::string TgTypeParser::parseForceReply(const ForceReply::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "force_reply", object->forceReply);
+ appendToJson(result, "input_field_placeholder", object->inputFieldPlaceholder);
appendToJson(result, "selective", object->selective);
removeLastComma(result);
result += '}';
return result;
}
-ChatMember::Ptr TgTypeParser::parseJsonAndGetChatMember(const ptree& data) const {
- auto result(make_shared<ChatMember>());
+ChatMember::Ptr TgTypeParser::parseJsonAndGetChatMember(const boost::property_tree::ptree& data) const {
+ std::string status = data.get<std::string>("status", "");
+ ChatMember::Ptr result;
+
+ if (status == ChatMemberOwner::STATUS) {
+ result = std::static_pointer_cast<ChatMember>(parseJsonAndGetChatMemberOwner(data));
+ } else if (status == ChatMemberAdministrator::STATUS) {
+ result = std::static_pointer_cast<ChatMember>(parseJsonAndGetChatMemberAdministrator(data));
+ } else if (status == ChatMemberMember::STATUS) {
+ result = std::static_pointer_cast<ChatMember>(parseJsonAndGetChatMemberMember(data));
+ } else if (status == ChatMemberRestricted::STATUS) {
+ result = std::static_pointer_cast<ChatMember>(parseJsonAndGetChatMemberRestricted(data));
+ } else if (status == ChatMemberLeft::STATUS) {
+ result = std::static_pointer_cast<ChatMember>(parseJsonAndGetChatMemberLeft(data));
+ } else if (status == ChatMemberBanned::STATUS) {
+ result = std::static_pointer_cast<ChatMember>(parseJsonAndGetChatMemberBanned(data));
+ } else {
+ result = std::make_shared<ChatMember>();
+ }
+
+ result->status = status;
result->user = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "user");
- result->status = data.get<string>("status", "");
- result->customTitle = data.get<string>("custom_title", "");
- result->untilDate = data.get<uint64_t>("until_date", 0);
+
+ return result;
+}
+
+std::string TgTypeParser::parseChatMember(const ChatMember::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "status", object->status);
+ appendToJson(result, "user", parseUser(object->user));
+
+ if (object->status == ChatMemberOwner::STATUS) {
+ result += parseChatMemberOwner(std::static_pointer_cast<ChatMemberOwner>(object));
+ } else if (object->status == ChatMemberAdministrator::STATUS) {
+ result += parseChatMemberAdministrator(std::static_pointer_cast<ChatMemberAdministrator>(object));
+ } else if (object->status == ChatMemberMember::STATUS) {
+ result += parseChatMemberMember(std::static_pointer_cast<ChatMemberMember>(object));
+ } else if (object->status == ChatMemberRestricted::STATUS) {
+ result += parseChatMemberRestricted(std::static_pointer_cast<ChatMemberRestricted>(object));
+ } else if (object->status == ChatMemberLeft::STATUS) {
+ result += parseChatMemberLeft(std::static_pointer_cast<ChatMemberLeft>(object));
+ } else if (object->status == ChatMemberBanned::STATUS) {
+ result += parseChatMemberBanned(std::static_pointer_cast<ChatMemberBanned>(object));
+ }
+
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+ChatMemberOwner::Ptr TgTypeParser::parseJsonAndGetChatMemberOwner(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetChatMember().
+ auto result(std::make_shared<ChatMemberOwner>());
+ result->customTitle = data.get<std::string>("custom_title", "");
+ result->isAnonymous = data.get<bool>("is_anonymous", false);
+ return result;
+}
+
+std::string TgTypeParser::parseChatMemberOwner(const ChatMemberOwner::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseChatMember(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ appendToJson(result, "custom_title", object->customTitle);
+ appendToJson(result, "is_anonymous", object->isAnonymous);
+ // The last comma will be erased by parseChatMember().
+ return result;
+}
+
+ChatMemberAdministrator::Ptr TgTypeParser::parseJsonAndGetChatMemberAdministrator(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetChatMember().
+ auto result(std::make_shared<ChatMemberAdministrator>());
result->canBeEdited = data.get<bool>("can_be_edited", false);
+ result->customTitle = data.get<std::string>("custom_title", "");
+ result->isAnonymous = data.get<bool>("is_anonymous", false);
+ result->canManageChat = data.get<bool>("can_manage_chat", false);
result->canPostMessages = data.get<bool>("can_post_messages", false);
result->canEditMessages = data.get<bool>("can_edit_messages", false);
result->canDeleteMessages = data.get<bool>("can_delete_messages", false);
+ result->canManageVoiceChats = data.get<bool>("can_manage_voice_chats", false);
result->canRestrictMembers = data.get<bool>("can_restrict_members", false);
result->canPromoteMembers = data.get<bool>("can_promote_members", false);
result->canChangeInfo = data.get<bool>("can_change_info", false);
result->canInviteUsers = data.get<bool>("can_invite_users", false);
result->canPinMessages = data.get<bool>("can_pin_messages", false);
- result->isMember = data.get<bool>("is_member", false);
- result->canSendMessages = data.get<bool>("can_send_messages", false);
- result->canSendMediaMessages = data.get<bool>("can_send_media_messages", false);
- 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);
return result;
}
-string TgTypeParser::parseChatMember(const ChatMember::Ptr& object) const {
+std::string TgTypeParser::parseChatMemberAdministrator(const ChatMemberAdministrator::Ptr& object) const {
if (!object) {
return "";
}
- string result;
- result += '{';
- appendToJson(result, "user", parseUser(object->user));
- appendToJson(result, "status", object->status);
- appendToJson(result, "custom_title", object->customTitle);
- appendToJson(result, "until_date", object->untilDate);
+ // This function will be called by parseChatMember(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "can_be_edited", object->canBeEdited);
+ appendToJson(result, "custom_title", object->customTitle);
+ appendToJson(result, "is_anonymous", object->isAnonymous);
+ appendToJson(result, "can_manage_chat", object->canManageChat);
appendToJson(result, "can_post_messages", object->canPostMessages);
appendToJson(result, "can_edit_messages", object->canEditMessages);
appendToJson(result, "can_delete_messages", object->canDeleteMessages);
+ appendToJson(result, "can_manage_voice_chats", object->canManageVoiceChats);
appendToJson(result, "can_restrict_members", object->canRestrictMembers);
appendToJson(result, "can_promote_members", object->canPromoteMembers);
appendToJson(result, "can_change_info", object->canChangeInfo);
appendToJson(result, "can_invite_users", object->canInviteUsers);
appendToJson(result, "can_pin_messages", object->canPinMessages);
+ // The last comma will be erased by parseChatMember().
+ return result;
+}
+
+ChatMemberMember::Ptr TgTypeParser::parseJsonAndGetChatMemberMember(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetChatMember().
+ auto result(std::make_shared<ChatMemberMember>());
+ return result;
+}
+
+std::string TgTypeParser::parseChatMemberMember(const ChatMemberMember::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseChatMember(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ // The last comma will be erased by parseChatMember().
+ return result;
+}
+
+ChatMemberRestricted::Ptr TgTypeParser::parseJsonAndGetChatMemberRestricted(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetChatMember().
+ auto result(std::make_shared<ChatMemberRestricted>());
+ result->isMember = data.get<bool>("is_member", false);
+ result->canChangeInfo = data.get<bool>("can_change_info", false);
+ result->canInviteUsers = data.get<bool>("can_invite_users", false);
+ result->canPinMessages = data.get<bool>("can_pin_messages", false);
+ result->canSendMessages = data.get<bool>("can_send_messages", false);
+ result->canSendMediaMessages = data.get<bool>("can_send_media_messages", false);
+ 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);
+ return result;
+}
+
+std::string TgTypeParser::parseChatMemberRestricted(const ChatMemberRestricted::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseChatMember(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "is_member", object->isMember);
+ appendToJson(result, "can_change_info", object->canChangeInfo);
+ appendToJson(result, "can_invite_users", object->canInviteUsers);
+ appendToJson(result, "can_pin_messages", object->canPinMessages);
appendToJson(result, "can_send_messages", object->canSendMessages);
appendToJson(result, "can_send_media_messages", object->canSendMediaMessages);
appendToJson(result, "can_send_polls", object->canSendPolls);
appendToJson(result, "can_send_other_messages", object->canSendOtherMessages);
appendToJson(result, "can_add_web_page_previews", object->canAddWebPagePreviews);
+ appendToJson(result, "until_date", object->untilDate);
+ // The last comma will be erased by parseChatMember().
+ return result;
+}
+
+ChatMemberLeft::Ptr TgTypeParser::parseJsonAndGetChatMemberLeft(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetChatMember().
+ auto result(std::make_shared<ChatMemberLeft>());
+ return result;
+}
+
+std::string TgTypeParser::parseChatMemberLeft(const ChatMemberLeft::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseChatMember(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ // The last comma will be erased by parseChatMember().
+ return result;
+}
+
+ChatMemberBanned::Ptr TgTypeParser::parseJsonAndGetChatMemberBanned(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetChatMember().
+ auto result(std::make_shared<ChatMemberBanned>());
+ result->untilDate = data.get<uint32_t>("until_date", 0);
+ return result;
+}
+
+std::string TgTypeParser::parseChatMemberBanned(const ChatMemberBanned::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseChatMember(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ appendToJson(result, "until_date", object->untilDate);
+ // The last comma will be erased by parseChatMember().
+ return result;
+}
+
+ChatMemberUpdated::Ptr TgTypeParser::parseJsonAndGetChatMemberUpdated(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<ChatMemberUpdated>());
+ result->chat = tryParseJson<Chat>(&TgTypeParser::parseJsonAndGetChat, data, "chat");
+ result->from = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "from");
+ result->date = data.get<uint32_t>("date", 0);
+ result->oldChatMember = tryParseJson<ChatMember>(&TgTypeParser::parseJsonAndGetChatMember, data, "old_chat_member");
+ result->newChatMember = tryParseJson<ChatMember>(&TgTypeParser::parseJsonAndGetChatMember, data, "new_chat_member");
+ result->inviteLink = tryParseJson<ChatInviteLink>(&TgTypeParser::parseJsonAndGetChatInviteLink, data, "invite_link");
+ return result;
+}
+
+std::string TgTypeParser::parseChatMemberUpdated(const ChatMemberUpdated::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "chat", parseChat(object->chat));
+ appendToJson(result, "from", parseUser(object->from));
+ appendToJson(result, "date", object->date);
+ appendToJson(result, "old_chat_member", parseChatMember(object->oldChatMember));
+ appendToJson(result, "new_chat_member", parseChatMember(object->newChatMember));
+ appendToJson(result, "invite_link", parseChatInviteLink(object->inviteLink));
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+ChatJoinRequest::Ptr TgTypeParser::parseJsonAndGetChatJoinRequest(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<ChatJoinRequest>());
+ result->chat = tryParseJson<Chat>(&TgTypeParser::parseJsonAndGetChat, data, "chat");
+ result->from = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "from");
+ result->date = data.get<std::int32_t>("date", 0);
+ result->bio = data.get<std::string>("bio", "");
+ result->inviteLink = tryParseJson<ChatInviteLink>(&TgTypeParser::parseJsonAndGetChatInviteLink, data, "invite_link");
+ return result;
+}
+
+std::string TgTypeParser::parseChatJoinRequest(const ChatJoinRequest::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "chat", parseChat(object->chat));
+ appendToJson(result, "from", parseUser(object->from));
+ appendToJson(result, "date", object->date);
+ appendToJson(result, "bio", object->bio);
+ appendToJson(result, "invite_link", parseChatInviteLink(object->inviteLink));
removeLastComma(result);
result += '}';
return result;
}
-ChatPhoto::Ptr TgTypeParser::parseJsonAndGetChatPhoto(const ptree& data) const {
- auto result(make_shared<ChatPhoto>());
- result->smallFileId = data.get<string>("small_file_id", "");
- result->smallFileUniqueId = data.get<string>("small_file_unique_id", "");
- result->bigFileId = data.get<string>("big_file_id", "");
- result->bigFileUniqueId = data.get<string>("big_file_unique_id", "");
+ChatPhoto::Ptr TgTypeParser::parseJsonAndGetChatPhoto(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<ChatPhoto>());
+ result->smallFileId = data.get<std::string>("small_file_id", "");
+ result->smallFileUniqueId = data.get<std::string>("small_file_unique_id", "");
+ result->bigFileId = data.get<std::string>("big_file_id", "");
+ result->bigFileUniqueId = data.get<std::string>("big_file_unique_id", "");
return result;
}
-string TgTypeParser::parseChatPhoto(const ChatPhoto::Ptr& object) const {
+std::string TgTypeParser::parseChatPhoto(const ChatPhoto::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "small_file_id", object->smallFileId);
appendToJson(result, "small_file_unique_id", object->smallFileUniqueId);
@@ -1186,10 +1658,44 @@ string TgTypeParser::parseChatPhoto(const ChatPhoto::Ptr& object) const {
return result;
}
+ChatInviteLink::Ptr TgTypeParser::parseJsonAndGetChatInviteLink(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<ChatInviteLink>());
+ result->inviteLink = data.get<std::string>("invite_link", "");
+ result->creator = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "creator");
+ result->createsJoinRequest = data.get<bool>("creates_join_request", false);
+ 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);
+ return result;
+}
+
+std::string TgTypeParser::parseChatInviteLink(const ChatInviteLink::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "invite_link", object->inviteLink);
+ appendToJson(result, "creator", parseUser(object->creator));
+ appendToJson(result, "creates_join_request", object->createsJoinRequest);
+ appendToJson(result, "is_primary", object->isPrimary);
+ appendToJson(result, "is_revoked", object->isRevoked);
+ appendToJson(result, "name", object->name);
+ appendToJson(result, "expire_date", object->expireDate);
+ appendToJson(result, "member_limit", object->memberLimit);
+ appendToJson(result, "pending_join_request_count", object->pendingJoinRequestCount);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
ResponseParameters::Ptr TgTypeParser::parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const {
- auto result(make_shared<ResponseParameters>());
- result->migrateToChatId = data.get<int64_t>("migrate_to_chat_id", 0);
- result->retryAfter = data.get<int32_t>("retry_after", 0);
+ auto result(std::make_shared<ResponseParameters>());
+ result->migrateToChatId = data.get<std::int64_t>("migrate_to_chat_id", 0);
+ result->retryAfter = data.get<std::int32_t>("retry_after", 0);
return result;
}
@@ -1197,7 +1703,7 @@ std::string TgTypeParser::parseResponseParameters(const ResponseParameters::Ptr&
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "migrate_to_chat_id", object->migrateToChatId);
appendToJson(result, "retry_after", object->retryAfter);
@@ -1208,41 +1714,41 @@ std::string TgTypeParser::parseResponseParameters(const ResponseParameters::Ptr&
GenericReply::Ptr TgTypeParser::parseJsonAndGetGenericReply(const boost::property_tree::ptree& data) const {
if (data.find("force_reply") != data.not_found()) {
- return static_pointer_cast<GenericReply>(parseJsonAndGetForceReply(data));
+ return std::static_pointer_cast<GenericReply>(parseJsonAndGetForceReply(data));
} else if (data.find("remove_keyboard") != data.not_found()) {
- return static_pointer_cast<GenericReply>(parseJsonAndGetReplyKeyboardRemove(data));
+ return std::static_pointer_cast<GenericReply>(parseJsonAndGetReplyKeyboardRemove(data));
} else if (data.find("keyboard") != data.not_found()) {
- return static_pointer_cast<GenericReply>(parseJsonAndGetReplyKeyboardMarkup(data));
+ return std::static_pointer_cast<GenericReply>(parseJsonAndGetReplyKeyboardMarkup(data));
} else if (data.find("inline_keyboard") != data.not_found()) {
- return static_pointer_cast<GenericReply>(parseJsonAndGetInlineKeyboardMarkup(data));
+ return std::static_pointer_cast<GenericReply>(parseJsonAndGetInlineKeyboardMarkup(data));
}
- return make_shared<GenericReply>();
+ return std::make_shared<GenericReply>();
}
std::string TgTypeParser::parseGenericReply(const GenericReply::Ptr& object) const {
if (!object) {
return "";
}
- if (dynamic_pointer_cast<ForceReply>(object) != nullptr) {
- return parseForceReply(static_pointer_cast<ForceReply>(object));
- } else if (dynamic_pointer_cast<ReplyKeyboardRemove>(object) != nullptr) {
- return parseReplyKeyboardRemove(static_pointer_cast<ReplyKeyboardRemove>(object));
- } else if (dynamic_pointer_cast<ReplyKeyboardMarkup>(object) != nullptr){
- return parseReplyKeyboardMarkup(static_pointer_cast<ReplyKeyboardMarkup>(object));
- } else if (dynamic_pointer_cast<InlineKeyboardMarkup>(object) != nullptr){
- return parseInlineKeyboardMarkup(static_pointer_cast<InlineKeyboardMarkup>(object));
+ if (std::dynamic_pointer_cast<ForceReply>(object) != nullptr) {
+ return parseForceReply(std::static_pointer_cast<ForceReply>(object));
+ } else if (std::dynamic_pointer_cast<ReplyKeyboardRemove>(object) != nullptr) {
+ return parseReplyKeyboardRemove(std::static_pointer_cast<ReplyKeyboardRemove>(object));
+ } else if (std::dynamic_pointer_cast<ReplyKeyboardMarkup>(object) != nullptr){
+ return parseReplyKeyboardMarkup(std::static_pointer_cast<ReplyKeyboardMarkup>(object));
+ } else if (std::dynamic_pointer_cast<InlineKeyboardMarkup>(object) != nullptr){
+ return parseInlineKeyboardMarkup(std::static_pointer_cast<InlineKeyboardMarkup>(object));
}
return "";
}
InlineQuery::Ptr TgTypeParser::parseJsonAndGetInlineQuery(const boost::property_tree::ptree& data) const {
- auto result(make_shared<InlineQuery>());
- result->id = data.get<string>("id");
+ auto result(std::make_shared<InlineQuery>());
+ result->id = data.get<std::string>("id", "");
result->from = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "from");
+ result->query = data.get<std::string>("query", "");
+ result->offset = data.get<std::string>("offset", "");
+ result->chatType = data.get<std::string>("chat_type", "");
result->location = tryParseJson<Location>(&TgTypeParser::parseJsonAndGetLocation, data, "location");
- result->query = data.get<string>("query");
- result->offset = data.get<string>("offset");
-
return result;
}
@@ -1250,149 +1756,143 @@ std::string TgTypeParser::parseInlineQuery(const InlineQuery::Ptr& object) const
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "id", object->id);
appendToJson(result, "from", parseUser(object->from));
- appendToJson(result, "location", parseLocation(object->location));
appendToJson(result, "query", object->query);
appendToJson(result, "offset", object->offset);
+ appendToJson(result, "chat_type", object->chatType);
+ appendToJson(result, "location", parseLocation(object->location));
removeLastComma(result);
result += '}';
return result;
}
-InlineQueryResult::Ptr TgTypeParser::parseJsonAndGetInlineQueryResult(const ptree& data) const {
- string type = data.get<string>("type", "");
+InlineQueryResult::Ptr TgTypeParser::parseJsonAndGetInlineQueryResult(const boost::property_tree::ptree& data) const {
+ std::string type = data.get<std::string>("type", "");
InlineQueryResult::Ptr result;
if (type == InlineQueryResultCachedAudio::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultCachedAudio(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultCachedAudio(data));
} else if (type == InlineQueryResultCachedDocument::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultCachedDocument(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultCachedDocument(data));
} else if (type == InlineQueryResultCachedGif::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultCachedGif(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultCachedGif(data));
} else if (type == InlineQueryResultCachedMpeg4Gif::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultCachedMpeg4Gif(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultCachedMpeg4Gif(data));
} else if (type == InlineQueryResultCachedPhoto::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultCachedPhoto(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultCachedPhoto(data));
} else if (type == InlineQueryResultCachedSticker::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultCachedSticker(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultCachedSticker(data));
} else if (type == InlineQueryResultCachedVideo::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultCachedVideo(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultCachedVideo(data));
} else if (type == InlineQueryResultCachedVoice::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultCachedVoice(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultCachedVoice(data));
} else if (type == InlineQueryResultArticle::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultArticle(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultArticle(data));
} else if (type == InlineQueryResultAudio::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultAudio(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultAudio(data));
} else if (type == InlineQueryResultContact::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultContact(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultContact(data));
} else if (type == InlineQueryResultGame::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultGame(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultGame(data));
} else if (type == InlineQueryResultDocument::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultDocument(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultDocument(data));
} else if (type == InlineQueryResultLocation::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultLocation(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultLocation(data));
} else if (type == InlineQueryResultVenue::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultVenue(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultVenue(data));
} else if (type == InlineQueryResultVoice::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultVoice(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultVoice(data));
} else if (type == InlineQueryResultPhoto::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultPhoto(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultPhoto(data));
} else if (type == InlineQueryResultGif::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultGif(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultGif(data));
} else if (type == InlineQueryResultMpeg4Gif::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultMpeg4Gif(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultMpeg4Gif(data));
} else if (type == InlineQueryResultVideo::TYPE) {
- result = static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultVideo(data));
+ result = std::static_pointer_cast<InlineQueryResult>(parseJsonAndGetInlineQueryResultVideo(data));
} else {
- result = make_shared<InlineQueryResult>();
+ result = std::make_shared<InlineQueryResult>();
}
- result->id = data.get<string>("id", "");
- result->title = data.get<string>("title", "");
- result->caption = data.get<string>("caption", "");
- result->parseMode = data.get<string>("parse_mode", "");
+ result->type = type;
+ result->id = data.get<std::string>("id", "");
result->replyMarkup = tryParseJson<InlineKeyboardMarkup>(&TgTypeParser::parseJsonAndGetInlineKeyboardMarkup, data, "reply_markup");
- result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
return result;
}
-string TgTypeParser::parseInlineQueryResult(const InlineQueryResult::Ptr& object) const {
+std::string TgTypeParser::parseInlineQueryResult(const InlineQueryResult::Ptr& object) const {
if (!object){
return "";
}
- string result;
+ std::string result;
result += '{';
- appendToJson(result, "id", object->id);
appendToJson(result, "type", object->type);
- appendToJson(result, "title", object->title);
- appendToJson(result, "caption", object->caption);
- appendToJson(result, "parse_mode", object->parseMode);
+ appendToJson(result, "id", object->id);
appendToJson(result, "reply_markup", parseInlineKeyboardMarkup(object->replyMarkup));
- appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
if (object->type == InlineQueryResultCachedAudio::TYPE) {
- result += parseInlineQueryResultCachedAudio(static_pointer_cast<InlineQueryResultCachedAudio>(object));
+ result += parseInlineQueryResultCachedAudio(std::static_pointer_cast<InlineQueryResultCachedAudio>(object));
}
else if (object->type == InlineQueryResultCachedDocument::TYPE) {
- result += parseInlineQueryResultCachedDocument(static_pointer_cast<InlineQueryResultCachedDocument>(object));
+ result += parseInlineQueryResultCachedDocument(std::static_pointer_cast<InlineQueryResultCachedDocument>(object));
}
else if (object->type == InlineQueryResultCachedGif::TYPE) {
- result += parseInlineQueryResultCachedGif(static_pointer_cast<InlineQueryResultCachedGif>(object));
+ result += parseInlineQueryResultCachedGif(std::static_pointer_cast<InlineQueryResultCachedGif>(object));
}
else if (object->type == InlineQueryResultCachedMpeg4Gif::TYPE) {
- result += parseInlineQueryResultCachedMpeg4Gif(static_pointer_cast<InlineQueryResultCachedMpeg4Gif>(object));
+ result += parseInlineQueryResultCachedMpeg4Gif(std::static_pointer_cast<InlineQueryResultCachedMpeg4Gif>(object));
}
else if (object->type == InlineQueryResultCachedPhoto::TYPE) {
- result += parseInlineQueryResultCachedPhoto(static_pointer_cast<InlineQueryResultCachedPhoto>(object));
+ result += parseInlineQueryResultCachedPhoto(std::static_pointer_cast<InlineQueryResultCachedPhoto>(object));
}
else if (object->type == InlineQueryResultCachedSticker::TYPE) {
- result += parseInlineQueryResultCachedSticker(static_pointer_cast<InlineQueryResultCachedSticker>(object));
+ result += parseInlineQueryResultCachedSticker(std::static_pointer_cast<InlineQueryResultCachedSticker>(object));
}
else if (object->type == InlineQueryResultCachedVideo::TYPE) {
- result += parseInlineQueryResultCachedVideo(static_pointer_cast<InlineQueryResultCachedVideo>(object));
+ result += parseInlineQueryResultCachedVideo(std::static_pointer_cast<InlineQueryResultCachedVideo>(object));
}
else if (object->type == InlineQueryResultCachedVoice::TYPE) {
- result += parseInlineQueryResultCachedVoice(static_pointer_cast<InlineQueryResultCachedVoice>(object));
+ result += parseInlineQueryResultCachedVoice(std::static_pointer_cast<InlineQueryResultCachedVoice>(object));
}
else if (object->type == InlineQueryResultArticle::TYPE) {
- result += parseInlineQueryResultArticle(static_pointer_cast<InlineQueryResultArticle>(object));
+ result += parseInlineQueryResultArticle(std::static_pointer_cast<InlineQueryResultArticle>(object));
}
else if (object->type == InlineQueryResultAudio::TYPE) {
- result += parseInlineQueryResultAudio(static_pointer_cast<InlineQueryResultAudio>(object));
+ result += parseInlineQueryResultAudio(std::static_pointer_cast<InlineQueryResultAudio>(object));
}
else if (object->type == InlineQueryResultContact::TYPE) {
- result += parseInlineQueryResultContact(static_pointer_cast<InlineQueryResultContact>(object));
+ result += parseInlineQueryResultContact(std::static_pointer_cast<InlineQueryResultContact>(object));
}
else if (object->type == InlineQueryResultGame::TYPE) {
- result += parseInlineQueryResultGame(static_pointer_cast<InlineQueryResultGame>(object));
+ result += parseInlineQueryResultGame(std::static_pointer_cast<InlineQueryResultGame>(object));
}
else if (object->type == InlineQueryResultDocument::TYPE) {
- result += parseInlineQueryResultDocument(static_pointer_cast<InlineQueryResultDocument>(object));
+ result += parseInlineQueryResultDocument(std::static_pointer_cast<InlineQueryResultDocument>(object));
}
else if (object->type == InlineQueryResultLocation::TYPE) {
- result += parseInlineQueryResultLocation(static_pointer_cast<InlineQueryResultLocation>(object));
+ result += parseInlineQueryResultLocation(std::static_pointer_cast<InlineQueryResultLocation>(object));
}
else if (object->type == InlineQueryResultVenue::TYPE) {
- result += parseInlineQueryResultVenue(static_pointer_cast<InlineQueryResultVenue>(object));
+ result += parseInlineQueryResultVenue(std::static_pointer_cast<InlineQueryResultVenue>(object));
}
else if (object->type == InlineQueryResultVoice::TYPE) {
- result += parseInlineQueryResultVoice(static_pointer_cast<InlineQueryResultVoice>(object));
+ result += parseInlineQueryResultVoice(std::static_pointer_cast<InlineQueryResultVoice>(object));
}
else if (object->type == InlineQueryResultPhoto::TYPE) {
- result += parseInlineQueryResultPhoto(static_pointer_cast<InlineQueryResultPhoto>(object));
+ result += parseInlineQueryResultPhoto(std::static_pointer_cast<InlineQueryResultPhoto>(object));
}
else if (object->type == InlineQueryResultGif::TYPE) {
- result += parseInlineQueryResultGif(static_pointer_cast<InlineQueryResultGif>(object));
+ result += parseInlineQueryResultGif(std::static_pointer_cast<InlineQueryResultGif>(object));
}
else if (object->type == InlineQueryResultMpeg4Gif::TYPE) {
- result += parseInlineQueryResultMpeg4Gif(static_pointer_cast<InlineQueryResultMpeg4Gif>(object));
+ result += parseInlineQueryResultMpeg4Gif(std::static_pointer_cast<InlineQueryResultMpeg4Gif>(object));
}
else if (object->type == InlineQueryResultVideo::TYPE) {
- result += parseInlineQueryResultVideo(static_pointer_cast<InlineQueryResultVideo>(object));
+ result += parseInlineQueryResultVideo(std::static_pointer_cast<InlineQueryResultVideo>(object));
}
removeLastComma(result);
@@ -1402,8 +1902,12 @@ string TgTypeParser::parseInlineQueryResult(const InlineQueryResult::Ptr& object
InlineQueryResultCachedAudio::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCachedAudio(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultCachedAudio>());
- result->audioFileId = data.get<string>("audio_file_id");
+ auto result(std::make_shared<InlineQueryResultCachedAudio>());
+ result->audioFileId = data.get<std::string>("audio_file_id", "");
+ result->caption = data.get<std::string>("caption", "");
+ result->parseMode = data.get<std::string>("parse_mode", "");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
return result;
}
@@ -1412,18 +1916,27 @@ std::string TgTypeParser::parseInlineQueryResultCachedAudio(const InlineQueryRes
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "audio_file_id", object->audioFileId);
+ appendToJson(result, "caption", object->caption);
+ appendToJson(result, "parse_mode", object->parseMode);
+ appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
// The last comma will be erased by parseInlineQueryResult().
return result;
}
InlineQueryResultCachedDocument::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCachedDocument(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultCachedDocument>());
- result->documentFileId = data.get<string>("document_file_id");
- result->description = data.get<string>("description", "");
+ auto result(std::make_shared<InlineQueryResultCachedDocument>());
+ result->title = data.get<std::string>("title", "");
+ result->documentFileId = data.get<std::string>("document_file_id", "");
+ result->description = data.get<std::string>("description", "");
+ result->caption = data.get<std::string>("caption", "");
+ result->parseMode = data.get<std::string>("parse_mode", "");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
return result;
}
@@ -1432,19 +1945,28 @@ std::string TgTypeParser::parseInlineQueryResultCachedDocument(const InlineQuery
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
+ appendToJson(result, "title", object->title);
appendToJson(result, "document_file_id", object->documentFileId);
appendToJson(result, "description", object->description);
+ appendToJson(result, "caption", object->caption);
+ appendToJson(result, "parse_mode", object->parseMode);
+ appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
// The last comma will be erased by parseInlineQueryResult().
return result;
}
-
InlineQueryResultCachedGif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCachedGif(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultCachedGif>());
- result->gifFileId = data.get<string>("gif_file_id");
+ auto result(std::make_shared<InlineQueryResultCachedGif>());
+ result->gifFileId = data.get<std::string>("gif_file_id", "");
+ result->title = data.get<std::string>("title", "");
+ result->caption = data.get<std::string>("caption", "");
+ result->parseMode = data.get<std::string>("parse_mode", "");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
return result;
}
@@ -1453,18 +1975,27 @@ std::string TgTypeParser::parseInlineQueryResultCachedGif(const InlineQueryResul
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "gif_file_id", object->gifFileId);
+ appendToJson(result, "title", object->title);
+ appendToJson(result, "caption", object->caption);
+ appendToJson(result, "parse_mode", object->parseMode);
+ appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
// The last comma will be erased by parseInlineQueryResult().
return result;
}
-
InlineQueryResultCachedMpeg4Gif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCachedMpeg4Gif(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultCachedMpeg4Gif>());
- result->mpeg4FileId = data.get<string>("mpeg4_file_id");
+ auto result(std::make_shared<InlineQueryResultCachedMpeg4Gif>());
+ result->mpeg4FileId = data.get<std::string>("mpeg4_file_id", "");
+ result->title = data.get<std::string>("title", "");
+ result->caption = data.get<std::string>("caption", "");
+ result->parseMode = data.get<std::string>("parse_mode", "");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
return result;
}
@@ -1473,19 +2004,28 @@ std::string TgTypeParser::parseInlineQueryResultCachedMpeg4Gif(const InlineQuery
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "mpeg4_file_id", object->mpeg4FileId);
+ appendToJson(result, "title", object->title);
+ appendToJson(result, "caption", object->caption);
+ appendToJson(result, "parse_mode", object->parseMode);
+ appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
// The last comma will be erased by parseInlineQueryResult().
return result;
}
-
InlineQueryResultCachedPhoto::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCachedPhoto(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultCachedPhoto>());
- result->photoFileId = data.get<string>("photo_file_id");
- result->description = data.get<string>("description", "");
+ auto result(std::make_shared<InlineQueryResultCachedPhoto>());
+ result->photoFileId = data.get<std::string>("photo_file_id", "");
+ result->title = data.get<std::string>("title", "");
+ result->description = data.get<std::string>("description", "");
+ result->caption = data.get<std::string>("caption", "");
+ result->parseMode = data.get<std::string>("parse_mode", "");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
return result;
}
@@ -1494,19 +2034,24 @@ std::string TgTypeParser::parseInlineQueryResultCachedPhoto(const InlineQueryRes
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "photo_file_id", object->photoFileId);
+ appendToJson(result, "title", object->title);
appendToJson(result, "description", object->description);
+ appendToJson(result, "caption", object->caption);
+ appendToJson(result, "parse_mode", object->parseMode);
+ appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
// The last comma will be erased by parseInlineQueryResult().
return result;
}
-
InlineQueryResultCachedSticker::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCachedSticker(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultCachedSticker>());
- result->stickerFileId = data.get<string>("sticker_file_id");
+ auto result(std::make_shared<InlineQueryResultCachedSticker>());
+ result->stickerFileId = data.get<std::string>("sticker_file_id", "");
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
return result;
}
@@ -1515,18 +2060,24 @@ std::string TgTypeParser::parseInlineQueryResultCachedSticker(const InlineQueryR
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "sticker_file_id", object->stickerFileId);
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
// The last comma will be erased by parseInlineQueryResult().
return result;
}
InlineQueryResultCachedVideo::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCachedVideo(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultCachedVideo>());
- result->videoFileId = data.get<string>("video_file_id");
- result->description = data.get<string>("description", "");
+ auto result(std::make_shared<InlineQueryResultCachedVideo>());
+ result->videoFileId = data.get<std::string>("video_file_id", "");
+ result->title = data.get<std::string>("title", "");
+ result->description = data.get<std::string>("description", "");
+ result->caption = data.get<std::string>("caption", "");
+ result->parseMode = data.get<std::string>("parse_mode", "");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
return result;
}
@@ -1535,19 +2086,28 @@ std::string TgTypeParser::parseInlineQueryResultCachedVideo(const InlineQueryRes
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "video_file_id", object->videoFileId);
+ appendToJson(result, "title", object->title);
appendToJson(result, "description", object->description);
+ appendToJson(result, "caption", object->caption);
+ appendToJson(result, "parse_mode", object->parseMode);
+ appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
// The last comma will be erased by parseInlineQueryResult().
return result;
}
-
InlineQueryResultCachedVoice::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCachedVoice(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultCachedVoice>());
- result->voiceFileId = data.get<string>("voice_file_id");
+ auto result(std::make_shared<InlineQueryResultCachedVoice>());
+ result->voiceFileId = data.get<std::string>("voice_file_id", "");
+ result->title = data.get<std::string>("title", "");
+ result->caption = data.get<std::string>("caption", "");
+ result->parseMode = data.get<std::string>("parse_mode", "");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
return result;
}
@@ -1556,22 +2116,29 @@ std::string TgTypeParser::parseInlineQueryResultCachedVoice(const InlineQueryRes
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "voice_file_id", object->voiceFileId);
+ appendToJson(result, "title", object->title);
+ appendToJson(result, "caption", object->caption);
+ appendToJson(result, "parse_mode", object->parseMode);
+ appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
// The last comma will be erased by parseInlineQueryResult().
return result;
}
InlineQueryResultArticle::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultArticle(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultArticle>());
- result->url = data.get<string>("url", "");
- result->hideUrl = data.get("hide_url", false);
- result->description = data.get<string>("description", "");
- result->thumbUrl = data.get<string>("thumb_url", "");
- result->thumbWidth = data.get("thumb_width", 0);
- result->thumbHeight = data.get("thumb_height", 0);
+ auto result(std::make_shared<InlineQueryResultArticle>());
+ result->title = data.get<std::string>("title", "");
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
+ result->url = data.get<std::string>("url", "");
+ result->hideUrl = data.get<bool>("hide_url", false);
+ result->description = data.get<std::string>("description", "");
+ result->thumbUrl = data.get<std::string>("thumb_url", "");
+ result->thumbWidth = data.get<std::int32_t>("thumb_width", 0);
+ result->thumbHeight = data.get<std::int32_t>("thumb_height", 0);
return result;
}
@@ -1580,8 +2147,10 @@ std::string TgTypeParser::parseInlineQueryResultArticle(const InlineQueryResultA
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
+ appendToJson(result, "title", object->title);
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
appendToJson(result, "url", object->url);
appendToJson(result, "hide_url", object->hideUrl);
appendToJson(result, "description", object->description);
@@ -1594,10 +2163,15 @@ std::string TgTypeParser::parseInlineQueryResultArticle(const InlineQueryResultA
InlineQueryResultAudio::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultAudio(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultAudio>());
- result->audioUrl = data.get<string>("audio_url");
- result->performer = data.get<string>("performer", "");
- result->audioDuration = data.get<int32_t>("audio_duration", 0);
+ auto result(std::make_shared<InlineQueryResultAudio>());
+ result->audioUrl = data.get<std::string>("audio_url", "");
+ result->title = data.get<std::string>("title", "");
+ result->caption = data.get<std::string>("caption", "");
+ result->parseMode = data.get<std::string>("parse_mode", "");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
+ result->performer = data.get<std::string>("performer", "");
+ result->audioDuration = data.get<std::int32_t>("audio_duration", 0);
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
return result;
}
@@ -1606,26 +2180,31 @@ std::string TgTypeParser::parseInlineQueryResultAudio(const InlineQueryResultAud
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "audio_url", object->audioUrl);
+ appendToJson(result, "title", object->title);
+ appendToJson(result, "caption", object->caption);
+ appendToJson(result, "parse_mode", object->parseMode);
+ appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
appendToJson(result, "performer", object->performer);
appendToJson(result, "audio_duration", object->audioDuration);
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
// The last comma will be erased by parseInlineQueryResult().
return result;
}
-
InlineQueryResultContact::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultContact(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultContact>());
- 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);
+ auto result(std::make_shared<InlineQueryResultContact>());
+ result->phoneNumber = data.get<std::string>("phone_number", "");
+ result->firstName = data.get<std::string>("first_name", "");
+ result->lastName = data.get<std::string>("last_name", "");
+ result->vcard = data.get<std::string>("vcard", "");
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
+ result->thumbUrl = data.get<std::string>("thumb_url", "");
+ result->thumbWidth = data.get<std::int32_t>("thumb_width", 0);
+ result->thumbHeight = data.get<std::int32_t>("thumb_height", 0);
return result;
}
@@ -1634,12 +2213,13 @@ std::string TgTypeParser::parseInlineQueryResultContact(const InlineQueryResultC
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::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);
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
appendToJson(result, "thumb_url", object->thumbUrl);
appendToJson(result, "thumb_width", object->thumbWidth);
appendToJson(result, "thumb_height", object->thumbHeight);
@@ -1650,8 +2230,8 @@ std::string TgTypeParser::parseInlineQueryResultContact(const InlineQueryResultC
InlineQueryResultGame::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultGame(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultGame>());
- result->gameShortName = data.get<string>("game_short_name");
+ auto result(std::make_shared<InlineQueryResultGame>());
+ result->gameShortName = data.get<std::string>("game_short_name", "");
return result;
}
@@ -1660,8 +2240,8 @@ std::string TgTypeParser::parseInlineQueryResultGame(const InlineQueryResultGame
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "game_short_name", object->gameShortName);
// The last comma will be erased by parseInlineQueryResult().
return result;
@@ -1669,13 +2249,18 @@ std::string TgTypeParser::parseInlineQueryResultGame(const InlineQueryResultGame
InlineQueryResultDocument::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultDocument(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultDocument>());
- result->documentUrl = data.get<string>("document_url");
- result->mimeType = data.get<string>("mime_type");
- result->description = data.get<string>("description", "");
- 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);
+ auto result(std::make_shared<InlineQueryResultDocument>());
+ result->title = data.get<std::string>("title", "");
+ result->caption = data.get<std::string>("caption", "");
+ result->parseMode = data.get<std::string>("parse_mode", "");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
+ result->documentUrl = data.get<std::string>("document_url", "");
+ result->mimeType = data.get<std::string>("mime_type", "");
+ result->description = data.get<std::string>("description", "");
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
+ result->thumbUrl = data.get<std::string>("thumb_url", "");
+ result->thumbWidth = data.get<std::int32_t>("thumb_width", 0);
+ result->thumbHeight = data.get<std::int32_t>("thumb_height", 0);
return result;
}
@@ -1684,11 +2269,16 @@ std::string TgTypeParser::parseInlineQueryResultDocument(const InlineQueryResult
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
+ appendToJson(result, "title", object->title);
+ appendToJson(result, "caption", object->caption);
+ appendToJson(result, "parse_mode", object->parseMode);
+ appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
appendToJson(result, "document_url", object->documentUrl);
appendToJson(result, "mime_type", object->mimeType);
appendToJson(result, "description", object->description);
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
appendToJson(result, "thumb_url", object->thumbUrl);
appendToJson(result, "thumb_width", object->thumbWidth);
appendToJson(result, "thumb_height", object->thumbHeight);
@@ -1698,12 +2288,18 @@ std::string TgTypeParser::parseInlineQueryResultDocument(const InlineQueryResult
InlineQueryResultLocation::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultLocation(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultLocation>());
- result->latitude = data.get<float>("latitude");
- result->longitude = data.get<float>("longitude");
- 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);
+ auto result(std::make_shared<InlineQueryResultLocation>());
+ result->latitude = data.get<float>("latitude", 0);
+ result->longitude = data.get<float>("longitude", 0);
+ result->title = data.get<std::string>("title", "");
+ result->horizontalAccuracy = data.get<float>("horizontal_accuracy", 0);
+ result->livePeriod = data.get<std::int32_t>("live_period", 0);
+ result->heading = data.get<std::int32_t>("heading", 0);
+ result->proximityAlertRadius = data.get<std::int32_t>("proximity_alert_radius", 0);
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
+ result->thumbUrl = data.get<std::string>("thumb_url", "");
+ result->thumbWidth = data.get<std::int32_t>("thumb_width", 0);
+ result->thumbHeight = data.get<std::int32_t>("thumb_height", 0);
return result;
}
@@ -1712,10 +2308,16 @@ std::string TgTypeParser::parseInlineQueryResultLocation(const InlineQueryResult
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "latitude", object->latitude);
appendToJson(result, "longitude", object->longitude);
+ appendToJson(result, "title", object->title);
+ appendToJson(result, "horizontal_accuracy", object->horizontalAccuracy);
+ appendToJson(result, "live_period", object->livePeriod);
+ appendToJson(result, "heading", object->heading);
+ appendToJson(result, "proximity_alert_radius", object->proximityAlertRadius);
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
appendToJson(result, "thumb_url", object->thumbUrl);
appendToJson(result, "thumb_width", object->thumbWidth);
appendToJson(result, "thumb_height", object->thumbHeight);
@@ -1726,15 +2328,19 @@ std::string TgTypeParser::parseInlineQueryResultLocation(const InlineQueryResult
InlineQueryResultVenue::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultVenue(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultVenue>());
- result->latitude = data.get<float>("latitude");
- 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);
+ auto result(std::make_shared<InlineQueryResultVenue>());
+ result->latitude = data.get<float>("latitude", 0);
+ result->longitude = data.get<float>("longitude", 0);
+ result->title = data.get<std::string>("title", "");
+ result->address = data.get<std::string>("address", "");
+ result->foursquareId = data.get<std::string>("foursquare_id", "");
+ result->foursquareType = data.get<std::string>("foursquare_type", "");
+ result->googlePlaceId = data.get<std::string>("google_place_id", "");
+ result->googlePlaceType = data.get<std::string>("google_place_type", "");
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
+ result->thumbUrl = data.get<std::string>("thumb_url", "");
+ result->thumbWidth = data.get<std::int32_t>("thumb_width", 0);
+ result->thumbHeight = data.get<std::int32_t>("thumb_height", 0);
return result;
}
@@ -1743,13 +2349,17 @@ std::string TgTypeParser::parseInlineQueryResultVenue(const InlineQueryResultVen
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "latitude", object->latitude);
appendToJson(result, "longitude", object->longitude);
+ appendToJson(result, "title", object->title);
appendToJson(result, "address", object->address);
appendToJson(result, "foursquare_id", object->foursquareId);
appendToJson(result, "foursquare_type", object->foursquareType);
+ appendToJson(result, "google_place_id", object->googlePlaceId);
+ appendToJson(result, "google_place_type", object->googlePlaceType);
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
appendToJson(result, "thumb_url", object->thumbUrl);
appendToJson(result, "thumb_width", object->thumbWidth);
appendToJson(result, "thumb_height", object->thumbHeight);
@@ -1759,9 +2369,14 @@ std::string TgTypeParser::parseInlineQueryResultVenue(const InlineQueryResultVen
InlineQueryResultVoice::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultVoice(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultVoice>());
- result->voiceUrl = data.get<string>("voice_url");
- result->voiceDuration = data.get<int32_t>("voice_duration", 0);
+ auto result(std::make_shared<InlineQueryResultVoice>());
+ result->voiceUrl = data.get<std::string>("voice_url", "");
+ result->title = data.get<std::string>("title", "");
+ result->caption = data.get<std::string>("caption", "");
+ result->parseMode = data.get<std::string>("parse_mode", "");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
+ result->voiceDuration = data.get<std::int32_t>("voice_duration", 0);
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
return result;
}
@@ -1770,22 +2385,32 @@ std::string TgTypeParser::parseInlineQueryResultVoice(const InlineQueryResultVoi
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "voice_url", object->voiceUrl);
+ appendToJson(result, "title", object->title);
+ appendToJson(result, "caption", object->caption);
+ appendToJson(result, "parse_mode", object->parseMode);
+ appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
appendToJson(result, "voice_duration", object->voiceDuration);
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
// The last comma will be erased by parseInlineQueryResult().
return result;
}
InlineQueryResultPhoto::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultPhoto(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultPhoto>());
- result->photoUrl = data.get<string>("photo_url", "");
- result->thumbUrl = data.get<string>("thumb_url");
- result->photoWidth = data.get("photo_width", 0);
- result->photoHeight = data.get("photo_height", 0);
- result->description = data.get<string>("description", "");
+ auto result(std::make_shared<InlineQueryResultPhoto>());
+ result->photoUrl = data.get<std::string>("photo_url", "");
+ result->thumbUrl = data.get<std::string>("thumb_url", "");
+ result->photoWidth = data.get<std::int32_t>("photo_width", 0);
+ result->photoHeight = data.get<std::int32_t>("photo_height", 0);
+ result->title = data.get<std::string>("title", "");
+ result->description = data.get<std::string>("description", "");
+ result->caption = data.get<std::string>("caption", "");
+ result->parseMode = data.get<std::string>("parse_mode", "");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
return result;
}
@@ -1794,55 +2419,75 @@ std::string TgTypeParser::parseInlineQueryResultPhoto(const InlineQueryResultPho
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "photo_url", object->photoUrl);
appendToJson(result, "thumb_url", object->thumbUrl);
appendToJson(result, "photo_width", object->photoWidth);
appendToJson(result, "photo_height", object->photoHeight);
+ appendToJson(result, "title", object->title);
appendToJson(result, "description", object->description);
+ appendToJson(result, "caption", object->caption);
+ appendToJson(result, "parse_mode", object->parseMode);
+ appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
// The last comma will be erased by parseInlineQueryResult().
return result;
}
-InlineQueryResultGif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultGif(const ptree& data) const {
+InlineQueryResultGif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultGif(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultGif>());
- result->gifUrl = data.get<string>("gif_url", "");
- result->gifWidth = data.get<int32_t>("gif_width", 0);
- result->gifHeight = data.get<int32_t>("gif_height", 0);
- result->gifDuration = data.get<int32_t>("gif_duration", 0);
- result->thumbUrl = data.get<string>("thumb_url", "");
- result->thumbMimeType = data.get<string>("thumb_mime_type", "");
+ auto result(std::make_shared<InlineQueryResultGif>());
+ result->gifUrl = data.get<std::string>("gif_url", "");
+ result->gifWidth = data.get<std::int32_t>("gif_width", 0);
+ result->gifHeight = data.get<std::int32_t>("gif_height", 0);
+ result->gifDuration = data.get<std::int32_t>("gif_duration", 0);
+ result->thumbUrl = data.get<std::string>("thumb_url", "");
+ result->thumbMimeType = data.get<std::string>("thumb_mime_type", "");
+ result->title = data.get<std::string>("title", "");
+ result->caption = data.get<std::string>("caption", "");
+ result->parseMode = data.get<std::string>("parse_mode", "");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
return result;
}
-string TgTypeParser::parseInlineQueryResultGif(const InlineQueryResultGif::Ptr& object) const {
+std::string TgTypeParser::parseInlineQueryResultGif(const InlineQueryResultGif::Ptr& object) const {
if (!object){
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "gif_url", object->gifUrl);
appendToJson(result, "gif_width", object->gifWidth);
appendToJson(result, "gif_height", object->gifHeight);
appendToJson(result, "gif_duration", object->gifDuration);
appendToJson(result, "thumb_url", object->thumbUrl);
appendToJson(result, "thumb_mime_type", object->thumbMimeType);
+ appendToJson(result, "title", object->title);
+ appendToJson(result, "caption", object->caption);
+ appendToJson(result, "parse_mode", object->parseMode);
+ appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
// The last comma will be erased by parseInlineQueryResult().
return result;
}
-InlineQueryResultMpeg4Gif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultMpeg4Gif(const ptree& data) const {
+InlineQueryResultMpeg4Gif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultMpeg4Gif(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultMpeg4Gif>());
- result->mpeg4Url = data.get<string>("mpeg4_url", "");
- result->mpeg4Width = data.get<int32_t>("mpeg4_width", 0);
- result->mpeg4Height = data.get<int32_t>("mpeg4_height", 0);
- result->mpeg4Duration = data.get<int32_t>("mpeg4_duration", 0);
- result->thumbUrl = data.get<string>("thumb_url", "");
- result->thumbMimeType = data.get<string>("thumb_mime_type", "");
+ auto result(std::make_shared<InlineQueryResultMpeg4Gif>());
+ result->mpeg4Url = data.get<std::string>("mpeg4_url", "");
+ result->mpeg4Width = data.get<std::int32_t>("mpeg4_width", 0);
+ result->mpeg4Height = data.get<std::int32_t>("mpeg4_height", 0);
+ result->mpeg4Duration = data.get<std::int32_t>("mpeg4_duration", 0);
+ result->thumbUrl = data.get<std::string>("thumb_url", "");
+ result->thumbMimeType = data.get<std::string>("thumb_mime_type", "");
+ result->title = data.get<std::string>("title", "");
+ result->caption = data.get<std::string>("caption", "");
+ result->parseMode = data.get<std::string>("parse_mode", "");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
return result;
}
@@ -1851,28 +2496,38 @@ std::string TgTypeParser::parseInlineQueryResultMpeg4Gif(const InlineQueryResult
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "mpeg4_url", object->mpeg4Url);
appendToJson(result, "mpeg4_width", object->mpeg4Width);
appendToJson(result, "mpeg4_height", object->mpeg4Height);
appendToJson(result, "mpeg4_duration", object->mpeg4Duration);
appendToJson(result, "thumb_url", object->thumbUrl);
appendToJson(result, "thumb_mime_type", object->thumbMimeType);
+ appendToJson(result, "title", object->title);
+ appendToJson(result, "caption", object->caption);
+ appendToJson(result, "parse_mode", object->parseMode);
+ appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
// The last comma will be erased by parseInlineQueryResult().
return result;
}
InlineQueryResultVideo::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultVideo(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInlineQueryResult().
- auto result(make_shared<InlineQueryResultVideo>());
- result->videoUrl = data.get<string>("video_url");
- result->mimeType = data.get<string>("mime_type");
- result->thumbUrl = data.get<string>("thumb_url");
- result->videoWidth = data.get("video_width", 0);
- result->videoHeight = data.get("video_height", 0);
- result->videoDuration = data.get("video_duration", 0);
- result->description = data.get<string>("description", "");
+ auto result(std::make_shared<InlineQueryResultVideo>());
+ result->videoUrl = data.get<std::string>("video_url", "");
+ result->mimeType = data.get<std::string>("mime_type", "");
+ result->thumbUrl = data.get<std::string>("thumb_url", "");
+ result->title = data.get<std::string>("title", "");
+ result->caption = data.get<std::string>("caption", "");
+ result->parseMode = data.get<std::string>("parse_mode", "");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "caption_entities");
+ result->videoWidth = data.get<std::int32_t>("video_width", 0);
+ result->videoHeight = data.get<std::int32_t>("video_height", 0);
+ result->videoDuration = data.get<std::int32_t>("video_duration", 0);
+ result->description = data.get<std::string>("description", "");
+ result->inputMessageContent = tryParseJson<InputMessageContent>(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content");
return result;
}
@@ -1881,26 +2536,31 @@ std::string TgTypeParser::parseInlineQueryResultVideo(const InlineQueryResultVid
return "";
}
// This function will be called by parseInlineQueryResult(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "video_url", object->videoUrl);
appendToJson(result, "mime_type", object->mimeType);
appendToJson(result, "thumb_url", object->thumbUrl);
+ appendToJson(result, "title", object->title);
+ appendToJson(result, "caption", object->caption);
+ appendToJson(result, "parse_mode", object->parseMode);
+ appendToJson(result, "caption_entities", parseArray(&TgTypeParser::parseMessageEntity, object->captionEntities));
appendToJson(result, "video_width", object->videoWidth);
appendToJson(result, "video_height", object->videoHeight);
appendToJson(result, "video_duration", object->videoDuration);
appendToJson(result, "description", object->description);
+ appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent));
// The last comma will be erased by parseInlineQueryResult().
return result;
}
ChosenInlineResult::Ptr TgTypeParser::parseJsonAndGetChosenInlineResult(const boost::property_tree::ptree& data) const {
- auto result(make_shared<ChosenInlineResult>());
- result->resultId = data.get<string>("result_id");
+ auto result(std::make_shared<ChosenInlineResult>());
+ result->resultId = data.get<std::string>("result_id", "");
result->from = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "from");
result->location = tryParseJson<Location>(&TgTypeParser::parseJsonAndGetLocation, data, "location");
- result->inlineMessageId = data.get<string>("inline_message_id", "");
- result->query = data.get<string>("query");
+ result->inlineMessageId = data.get<std::string>("inline_message_id", "");
+ result->query = data.get<std::string>("query", "");
return result;
}
@@ -1908,8 +2568,7 @@ std::string TgTypeParser::parseChosenInlineResult(const ChosenInlineResult::Ptr&
if (!object){
return "";
}
-
- string result;
+ std::string result;
result += '{';
appendToJson(result, "result_id", object->resultId);
appendToJson(result, "from", parseUser(object->from));
@@ -1920,14 +2579,14 @@ std::string TgTypeParser::parseChosenInlineResult(const ChosenInlineResult::Ptr&
}
CallbackQuery::Ptr TgTypeParser::parseJsonAndGetCallbackQuery(const boost::property_tree::ptree& data) const {
- auto result(make_shared<CallbackQuery>());
- result->id = data.get<string>("id");
+ auto result(std::make_shared<CallbackQuery>());
+ result->id = data.get<std::string>("id");
result->from = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "from");
result->message = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "message");
- result->inlineMessageId = data.get<string>("inline_message_id", "");
- result->chatInstance = data.get<string>("chat_instance");
- result->gameShortName = data.get<string>("game_short_name", "");
- result->data = data.get<string>("data", "");
+ result->inlineMessageId = data.get<std::string>("inline_message_id", "");
+ result->chatInstance = data.get<std::string>("chat_instance");
+ result->gameShortName = data.get<std::string>("game_short_name", "");
+ result->data = data.get<std::string>("data", "");
return result;
}
@@ -1936,7 +2595,7 @@ std::string TgTypeParser::parseCallbackQuery(const CallbackQuery::Ptr& object) c
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "id", object->id);
appendToJson(result, "from", parseUser(object->from));
@@ -1951,7 +2610,7 @@ std::string TgTypeParser::parseCallbackQuery(const CallbackQuery::Ptr& object) c
}
InlineKeyboardMarkup::Ptr TgTypeParser::parseJsonAndGetInlineKeyboardMarkup(const boost::property_tree::ptree& data) const {
- auto result(make_shared<InlineKeyboardMarkup>());
+ auto result(std::make_shared<InlineKeyboardMarkup>());
for (const auto& item : data.find("inline_keyboard")->second){
result->inlineKeyboard.push_back(parseJsonAndGetArray<InlineKeyboardButton>(&TgTypeParser::parseJsonAndGetInlineKeyboardButton, item.second));
}
@@ -1962,7 +2621,7 @@ std::string TgTypeParser::parseInlineKeyboardMarkup(const InlineKeyboardMarkup::
if (!object){
return "";
}
- string result;
+ std::string result;
result += '{';
result += R"("inline_keyboard":[)";
for (const auto& item : object->inlineKeyboard){
@@ -1981,14 +2640,14 @@ std::string TgTypeParser::parseInlineKeyboardMarkup(const InlineKeyboardMarkup::
}
InlineKeyboardButton::Ptr TgTypeParser::parseJsonAndGetInlineKeyboardButton(const boost::property_tree::ptree& data) const {
- auto result(make_shared<InlineKeyboardButton>());
- result->text = data.get<string>("text");
- result->url = data.get<string>("url", "");
- result->loginUrl = make_shared<LoginUrl>();
- result->callbackData = data.get<string>("callback_data", "");
- result->switchInlineQuery = data.get<string>("switch_inline_query", "");
- result->switchInlineQueryCurrentChat = data.get<string>("switch_inline_query_current_chat", "");
- result->callbackGame = make_shared<CallbackGame>();
+ auto result(std::make_shared<InlineKeyboardButton>());
+ result->text = data.get<std::string>("text");
+ result->url = data.get<std::string>("url", "");
+ result->loginUrl = std::make_shared<LoginUrl>();
+ result->callbackData = data.get<std::string>("callback_data", "");
+ result->switchInlineQuery = data.get<std::string>("switch_inline_query", "");
+ result->switchInlineQueryCurrentChat = data.get<std::string>("switch_inline_query_current_chat", "");
+ result->callbackGame = std::make_shared<CallbackGame>();
result->pay = data.get<bool>("pay", false);
return result;
}
@@ -1996,7 +2655,7 @@ std::string TgTypeParser::parseInlineKeyboardButton(const InlineKeyboardButton::
if (!object){
return "";
}
- string result;
+ std::string result;
result += '{';
if(object->pay)
appendToJson(result, "pay", object->pay);
@@ -2011,13 +2670,14 @@ std::string TgTypeParser::parseInlineKeyboardButton(const InlineKeyboardButton::
}
WebhookInfo::Ptr TgTypeParser::parseJsonAndGetWebhookInfo(const boost::property_tree::ptree& data) const {
- auto result(make_shared<WebhookInfo>());
- result->url = data.get<string>("url");
- result->hasCustomCertificate = data.get<bool>("has_custom_certificate");
- result->pendingUpdateCount = data.get<int32_t>("pending_update_count");
- result->lastErrorDate = data.get<int32_t>("last_error_date", 0);
- result->lastErrorMessage = data.get<string>("last_error_message", "");
- result->maxConnections = data.get<int32_t>("max_connections", 0);
+ auto result(std::make_shared<WebhookInfo>());
+ result->url = data.get<std::string>("url", "");
+ result->hasCustomCertificate = data.get<bool>("has_custom_certificate", false);
+ result->pendingUpdateCount = data.get<std::int32_t>("pending_update_count", 0);
+ result->ipAddress = data.get<std::string>("ip_address", "");
+ result->lastErrorDate = data.get<std::int32_t>("last_error_date", 0);
+ result->lastErrorMessage = data.get<std::string>("last_error_message", "");
+ result->maxConnections = data.get<std::int32_t>("max_connections", 0);
result->allowedUpdates = parseJsonAndGetArray<std::string>(
[](const boost::property_tree::ptree& innerData)->std::string {
return innerData.get<std::string>("");
@@ -2030,11 +2690,12 @@ std::string TgTypeParser::parseWebhookInfo(const WebhookInfo::Ptr& object) const
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "url", object->url);
appendToJson(result, "has_custom_certificate", object->hasCustomCertificate);
appendToJson(result, "pending_update_count", object->pendingUpdateCount);
+ appendToJson(result, "ip_address", object->ipAddress);
appendToJson(result, "last_error_date", object->lastErrorDate);
appendToJson(result, "last_error_message", object->lastErrorMessage);
appendToJson(result, "max_connections", object->maxConnections);
@@ -2050,21 +2711,25 @@ std::string TgTypeParser::parseWebhookInfo(const WebhookInfo::Ptr& object) const
InputMessageContent::Ptr TgTypeParser::parseJsonAndGetInputMessageContent(const boost::property_tree::ptree& data) const {
InputMessageContent::Ptr result;
- // define InputMessageContent type
-
- string tMessageText = data.get<string>("message_text", "");
- float tLatitude = data.get<float>("latitude", 1000); // latitude belong (-90,90)
- string tTitle = data.get<string>("title", "");
- string tPnoneNumber = data.get<string>("phone_number", "");
- if (!tMessageText.empty()) {
- result = static_pointer_cast<InputMessageContent>(parseJsonAndGetInputTextMessageContent(data));
- } else if (!tTitle.empty()) {
- result = static_pointer_cast<InputMessageContent>(parseJsonAndGetInputVenueMessageContent(data));
- } else if (tLatitude != 1000) {
- result = static_pointer_cast<InputMessageContent>(parseJsonAndGetInputLocationMessageContent(data));
- } else if (!tPnoneNumber.empty()) {
- result = static_pointer_cast<InputMessageContent>(parseJsonAndGetInputContactMessageContent(data));
+ std::string messageText = data.get<std::string>("message_text", "");
+ float latitude = data.get<float>("latitude", 1000); // latitude belong (-90,90)
+ std::string address = data.get<std::string>("address", "");
+ std::string phoneNumber = data.get<std::string>("phone_number", "");
+ std::string description = data.get<std::string>("description", "");
+
+ if (!messageText.empty()) {
+ result = std::static_pointer_cast<InputMessageContent>(parseJsonAndGetInputTextMessageContent(data));
+ } else if (!address.empty()) {
+ result = std::static_pointer_cast<InputMessageContent>(parseJsonAndGetInputVenueMessageContent(data));
+ } else if (latitude != 1000) {
+ result = std::static_pointer_cast<InputMessageContent>(parseJsonAndGetInputLocationMessageContent(data));
+ } else if (!phoneNumber.empty()) {
+ result = std::static_pointer_cast<InputMessageContent>(parseJsonAndGetInputContactMessageContent(data));
+ } else if (!description.empty()) {
+ result = std::static_pointer_cast<InputMessageContent>(parseJsonAndGetInputInvoiceMessageContent(data));
+ } else {
+ result = std::make_shared<InputMessageContent>();
}
return result;
@@ -2074,21 +2739,19 @@ std::string TgTypeParser::parseInputMessageContent(const InputMessageContent::Pt
if (!object){
return "";
}
-
- string result;
+ std::string result;
result += '{';
- if (object->type == std::string("InputTextMessageContent")) {
- result += parseInputTextMessageContent(static_pointer_cast<InputTextMessageContent>(object));
- }
- else if (object->type == std::string("InputLocationMessageContent")) {
- result += parseInputLocationMessageContent(static_pointer_cast<InputLocationMessageContent>(object));
- }
- else if (object->type == std::string("InputVenueMessageContent")) {
- result += parseInputVenueMessageContent(static_pointer_cast<InputVenueMessageContent>(object));
- }
- else if (object->type == std::string("InputContactMessageContent")) {
- result += parseInputContactMessageContent(static_pointer_cast<InputContactMessageContent>(object));
+ if (object->type == InputTextMessageContent::TYPE) {
+ result += parseInputTextMessageContent(std::static_pointer_cast<InputTextMessageContent>(object));
+ } else if (object->type == InputLocationMessageContent::TYPE) {
+ result += parseInputLocationMessageContent(std::static_pointer_cast<InputLocationMessageContent>(object));
+ } else if (object->type == InputVenueMessageContent::TYPE) {
+ result += parseInputVenueMessageContent(std::static_pointer_cast<InputVenueMessageContent>(object));
+ } else if (object->type == InputContactMessageContent::TYPE) {
+ result += parseInputContactMessageContent(std::static_pointer_cast<InputContactMessageContent>(object));
+ } else if (object->type == InputInvoiceMessageContent::TYPE) {
+ result += parseInputInvoiceMessageContent(std::static_pointer_cast<InputInvoiceMessageContent>(object));
}
removeLastComma(result);
@@ -2098,9 +2761,10 @@ std::string TgTypeParser::parseInputMessageContent(const InputMessageContent::Pt
InputTextMessageContent::Ptr TgTypeParser::parseJsonAndGetInputTextMessageContent(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInputMessageContent().
- auto result(make_shared<InputTextMessageContent>());
- result->messageText = data.get<string>("message_text");
- result->parseMode = data.get<string>("parse_mode", "");
+ auto result(std::make_shared<InputTextMessageContent>());
+ result->messageText = data.get<std::string>("message_text", "");
+ result->parseMode = data.get<std::string>("parse_mode", "");
+ result->entities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, data, "entities");
result->disableWebPagePreview = data.get<bool>("disable_web_page_preview", false);
return result;
}
@@ -2110,9 +2774,10 @@ std::string TgTypeParser::parseInputTextMessageContent(const InputTextMessageCon
return "";
}
// This function will be called by parseInputMessageContent()
- string result;
+ std::string result;
appendToJson(result, "message_text", object->messageText);
appendToJson(result, "parse_mode", object->parseMode);
+ appendToJson(result, "entities", parseArray(&TgTypeParser::parseMessageEntity, object->entities));
appendToJson(result, "disable_web_page_preview", object->disableWebPagePreview);
// The last comma will be erased by parseInputMessageContent().
return result;
@@ -2120,9 +2785,13 @@ std::string TgTypeParser::parseInputTextMessageContent(const InputTextMessageCon
InputLocationMessageContent::Ptr TgTypeParser::parseJsonAndGetInputLocationMessageContent(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInputMessageContent().
- auto result(make_shared<InputLocationMessageContent>());
- result->latitude = data.get<float>("latitude");
- result->longitude = data.get<float>("longitude");
+ auto result(std::make_shared<InputLocationMessageContent>());
+ result->latitude = data.get<float>("latitude", 0);
+ result->longitude = data.get<float>("longitude", 0);
+ result->horizontalAccuracy = data.get<float>("horizontal_accuracy", 0);
+ result->livePeriod = data.get<std::int32_t>("live_period", 0);
+ result->heading = data.get<std::int32_t>("heading", 0);
+ result->proximityAlertRadius = data.get<std::int32_t>("proximity_alert_radius", 0);
return result;
}
@@ -2131,22 +2800,28 @@ std::string TgTypeParser::parseInputLocationMessageContent(const InputLocationMe
return "";
}
// This function will be called by parseInputMessageContent()
- string result;
+ std::string result;
appendToJson(result, "latitude", object->latitude);
appendToJson(result, "longitude", object->longitude);
+ appendToJson(result, "horizontal_accuracy", object->horizontalAccuracy);
+ appendToJson(result, "live_period", object->livePeriod);
+ appendToJson(result, "heading", object->heading);
+ appendToJson(result, "proximity_alert_radius", object->proximityAlertRadius);
// The last comma will be erased by parseInputMessageContent().
return result;
}
InputVenueMessageContent::Ptr TgTypeParser::parseJsonAndGetInputVenueMessageContent(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInputMessageContent().
- auto result(make_shared<InputVenueMessageContent>());
- result->latitude = data.get<float>("latitude");
- result->longitude = data.get<float>("longitude");
- 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", "");
+ auto result(std::make_shared<InputVenueMessageContent>());
+ result->latitude = data.get<float>("latitude", 0);
+ result->longitude = data.get<float>("longitude", 0);
+ result->title = data.get<std::string>("title", "");
+ result->address = data.get<std::string>("address", "");
+ result->foursquareId = data.get<std::string>("foursquare_id", "");
+ result->foursquareType = data.get<std::string>("foursquare_type", "");
+ result->googlePlaceId = data.get<std::string>("google_place_id", "");
+ result->googlePlaceType = data.get<std::string>("google_place_type", "");
return result;
}
@@ -2155,23 +2830,26 @@ std::string TgTypeParser::parseInputVenueMessageContent(const InputVenueMessageC
return "";
}
// This function will be called by parseInputMessageContent()
- string result;
+ std::string result;
appendToJson(result, "latitude", object->latitude);
appendToJson(result, "longitude", object->longitude);
appendToJson(result, "title", object->title);
appendToJson(result, "address", object->address);
appendToJson(result, "foursquare_id", object->foursquareId);
+ appendToJson(result, "foursquare_type", object->foursquareType);
+ appendToJson(result, "google_place_id", object->googlePlaceId);
+ appendToJson(result, "google_place_type", object->googlePlaceType);
// The last comma will be erased by parseInputMessageContent().
return result;
}
InputContactMessageContent::Ptr TgTypeParser::parseJsonAndGetInputContactMessageContent(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetInputMessageContent().
- auto result(make_shared<InputContactMessageContent>());
- 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", "");
+ auto result(std::make_shared<InputContactMessageContent>());
+ result->phoneNumber = data.get<std::string>("phone_number", "");
+ result->firstName = data.get<std::string>("first_name", "");
+ result->lastName = data.get<std::string>("last_name", "");
+ result->vcard = data.get<std::string>("vcard", "");
return result;
}
@@ -2180,7 +2858,7 @@ std::string TgTypeParser::parseInputContactMessageContent(const InputContactMess
return "";
}
// This function will be called by parseInputMessageContent()
- string result;
+ std::string result;
appendToJson(result, "phone_number", object->phoneNumber);
appendToJson(result, "first_name", object->firstName);
appendToJson(result, "last_name", object->lastName);
@@ -2189,13 +2867,73 @@ std::string TgTypeParser::parseInputContactMessageContent(const InputContactMess
return result;
}
+InputInvoiceMessageContent::Ptr TgTypeParser::parseJsonAndGetInputInvoiceMessageContent(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetInputMessageContent().
+ auto result(std::make_shared<InputInvoiceMessageContent>());
+ result->title = data.get<std::string>("title", "");
+ result->description = data.get<std::string>("description", "");
+ result->payload = data.get<std::string>("payload", "");
+ result->providerToken = data.get<std::string>("provider_token", "");
+ result->currency = data.get<std::string>("currency", "");
+ result->prices = parseJsonAndGetArray<LabeledPrice>(&TgTypeParser::parseJsonAndGetLabeledPrice, data, "prices");
+ result->maxTipAmount = data.get<std::int32_t>("max_tip_amount", 0);
+ result->suggestedTipAmounts = parseJsonAndGetArray<std::int32_t>([] (const boost::property_tree::ptree& innerData)->std::int32_t {
+ return innerData.get<std::int32_t>(0);
+ }, data, "suggested_tip_amounts");
+ result->providerData = data.get<std::string>("provider_data", "");
+ result->photoUrl = data.get<std::string>("photo_url", "");
+ result->photoSize = data.get<std::int32_t>("photo_size", 0);
+ result->photoWidth = data.get<std::int32_t>("photo_width", 0);
+ result->photoHeight = data.get<std::int32_t>("photo_height", 0);
+ result->needName = data.get<bool>("need_name", false);
+ result->needPhoneNumber = data.get<bool>("need_phone_number", false);
+ result->needEmail = data.get<bool>("need_email", false);
+ result->needShippingAddress = data.get<bool>("need_shipping_address", false);
+ result->sendPhoneNumberToProvider = data.get<bool>("send_phone_number_to_provider", false);
+ result->sendEmailToProvider = data.get<bool>("send_email_to_provider", false);
+ result->isFlexible = data.get<bool>("is_flexible", false);
+ return result;
+}
+
+std::string TgTypeParser::parseInputInvoiceMessageContent(const InputInvoiceMessageContent::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseInputMessageContent()
+ std::string result;
+ appendToJson(result, "title", object->title);
+ appendToJson(result, "description", object->description);
+ appendToJson(result, "payload", object->payload);
+ appendToJson(result, "provider_token", object->providerToken);
+ appendToJson(result, "currency", object->currency);
+ appendToJson(result, "prices", parseArray(&TgTypeParser::parseLabeledPrice, object->prices));
+ appendToJson(result, "max_tip_amount", object->maxTipAmount);
+ appendToJson(result, "suggested_tip_amounts", parseArray<std::int32_t>([] (std::int32_t i)->std::int32_t {
+ return i;
+ }, object->suggestedTipAmounts));
+ appendToJson(result, "provider_data", object->providerData);
+ appendToJson(result, "photo_url", object->photoUrl);
+ appendToJson(result, "photo_size", object->photoSize);
+ appendToJson(result, "photo_width", object->photoWidth);
+ appendToJson(result, "photo_height", object->photoHeight);
+ appendToJson(result, "need_name", object->needName);
+ appendToJson(result, "need_phone_number", object->needPhoneNumber);
+ appendToJson(result, "need_email", object->needEmail);
+ appendToJson(result, "need_shipping_address", object->needShippingAddress);
+ appendToJson(result, "send_phone_number_to_provider", object->sendPhoneNumberToProvider);
+ appendToJson(result, "send_email_to_provider", object->sendEmailToProvider);
+ appendToJson(result, "is_flexible", object->isFlexible);
+ // The last comma will be erased by parseInputMessageContent().
+ return result;
+}
+
Invoice::Ptr TgTypeParser::parseJsonAndGetInvoice(const boost::property_tree::ptree& data) const {
- auto result(make_shared<Invoice>());
- result->title = data.get<string>("title");
- result->description = data.get<string>("description");
- result->startParameter = data.get<string>("start_parameter");
- result->currency = data.get<string>("currency");
- result->totalAmount = data.get<int32_t>("total_amount");
+ auto result(std::make_shared<Invoice>());
+ result->title = data.get<std::string>("title");
+ result->description = data.get<std::string>("description");
+ result->startParameter = data.get<std::string>("start_parameter");
+ result->currency = data.get<std::string>("currency");
+ result->totalAmount = data.get<std::int32_t>("total_amount");
return result;
}
@@ -2203,7 +2941,7 @@ std::string TgTypeParser::parseInvoice(const Invoice::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "title", object->title);
appendToJson(result, "description", object->description);
@@ -2216,13 +2954,13 @@ std::string TgTypeParser::parseInvoice(const Invoice::Ptr& object) const {
}
LabeledPrice::Ptr TgTypeParser::parseJsonAndGetLabeledPrice(const boost::property_tree::ptree& data) const {
- auto result(make_shared<LabeledPrice>());
- result->label = data.get<string>("label");
- result->amount = data.get<int32_t>("amount");
+ auto result(std::make_shared<LabeledPrice>());
+ result->label = data.get<std::string>("label");
+ result->amount = data.get<std::int32_t>("amount");
return result;
}
-string TgTypeParser::parseLabeledPrice(const LabeledPrice::Ptr& object) const {
+std::string TgTypeParser::parseLabeledPrice(const LabeledPrice::Ptr& object) const {
std::string result;
result += '{';
appendToJson(result, "label", object->label);
@@ -2233,13 +2971,13 @@ string TgTypeParser::parseLabeledPrice(const LabeledPrice::Ptr& object) const {
}
BotCommand::Ptr TgTypeParser::parseJsonAndGetBotCommand(const boost::property_tree::ptree& data) const {
- auto result(make_shared<BotCommand>());
+ auto result(std::make_shared<BotCommand>());
result->command = data.get("command", "");
result->description = data.get("description","");
return result;
}
-string TgTypeParser::parseBotCommand(const BotCommand::Ptr& object) const {
+std::string TgTypeParser::parseBotCommand(const BotCommand::Ptr& object) const {
std::string result;
result += '{';
appendToJson(result, "command", object->command);
@@ -2249,16 +2987,199 @@ string TgTypeParser::parseBotCommand(const BotCommand::Ptr& object) const {
return result;
}
+BotCommandScope::Ptr TgTypeParser::parseJsonAndGetBotCommandScope(const boost::property_tree::ptree& data) const {
+ std::string type = data.get<std::string>("type", "");
+ BotCommandScope::Ptr result;
+
+ if (type == BotCommandScopeDefault::TYPE) {
+ result = std::static_pointer_cast<BotCommandScope>(parseJsonAndGetBotCommandScopeDefault(data));
+ } else if (type == BotCommandScopeAllPrivateChats::TYPE) {
+ result = std::static_pointer_cast<BotCommandScope>(parseJsonAndGetBotCommandScopeAllPrivateChats(data));
+ } else if (type == BotCommandScopeAllGroupChats::TYPE) {
+ result = std::static_pointer_cast<BotCommandScope>(parseJsonAndGetBotCommandScopeAllGroupChats(data));
+ } else if (type == BotCommandScopeAllChatAdministrators::TYPE) {
+ result = std::static_pointer_cast<BotCommandScope>(parseJsonAndGetBotCommandScopeAllChatAdministrators(data));
+ } else if (type == BotCommandScopeChat::TYPE) {
+ result = std::static_pointer_cast<BotCommandScope>(parseJsonAndGetBotCommandScopeChat(data));
+ } else if (type == BotCommandScopeChatAdministrators::TYPE) {
+ result = std::static_pointer_cast<BotCommandScope>(parseJsonAndGetBotCommandScopeChatAdministrators(data));
+ } else if (type == BotCommandScopeChatMember::TYPE) {
+ result = std::static_pointer_cast<BotCommandScope>(parseJsonAndGetBotCommandScopeChatMember(data));
+ } else {
+ result = std::make_shared<BotCommandScope>();
+ }
+
+ result->type = type;
+
+ return result;
+}
+
+std::string TgTypeParser::parseBotCommandScope(const BotCommandScope::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "type", object->type);
+
+ if (object->type == BotCommandScopeDefault::TYPE) {
+ result += parseBotCommandScopeDefault(std::static_pointer_cast<BotCommandScopeDefault>(object));
+ } else if (object->type == BotCommandScopeAllPrivateChats::TYPE) {
+ result += parseBotCommandScopeAllPrivateChats(std::static_pointer_cast<BotCommandScopeAllPrivateChats>(object));
+ } else if (object->type == BotCommandScopeAllGroupChats::TYPE) {
+ result += parseBotCommandScopeAllGroupChats(std::static_pointer_cast<BotCommandScopeAllGroupChats>(object));
+ } else if (object->type == BotCommandScopeAllChatAdministrators::TYPE) {
+ result += parseBotCommandScopeAllChatAdministrators(std::static_pointer_cast<BotCommandScopeAllChatAdministrators>(object));
+ } else if (object->type == BotCommandScopeChat::TYPE) {
+ result += parseBotCommandScopeChat(std::static_pointer_cast<BotCommandScopeChat>(object));
+ } else if (object->type == BotCommandScopeChatAdministrators::TYPE) {
+ result += parseBotCommandScopeChatAdministrators(std::static_pointer_cast<BotCommandScopeChatAdministrators>(object));
+ } else if (object->type == BotCommandScopeChatMember::TYPE) {
+ result += parseBotCommandScopeChatMember(std::static_pointer_cast<BotCommandScopeChatMember>(object));
+ }
+
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+BotCommandScopeDefault::Ptr TgTypeParser::parseJsonAndGetBotCommandScopeDefault(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetBotCommandScope().
+ auto result(std::make_shared<BotCommandScopeDefault>());
+ return result;
+}
+
+std::string TgTypeParser::parseBotCommandScopeDefault(const BotCommandScopeDefault::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseBotCommandScope(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ // The last comma will be erased by parseBotCommandScope().
+ return result;
+}
+
+BotCommandScopeAllPrivateChats::Ptr TgTypeParser::parseJsonAndGetBotCommandScopeAllPrivateChats(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetBotCommandScope().
+ auto result(std::make_shared<BotCommandScopeAllPrivateChats>());
+ return result;
+}
+
+std::string TgTypeParser::parseBotCommandScopeAllPrivateChats(const BotCommandScopeAllPrivateChats::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseBotCommandScope(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ // The last comma will be erased by parseBotCommandScope().
+ return result;
+}
+
+BotCommandScopeAllGroupChats::Ptr TgTypeParser::parseJsonAndGetBotCommandScopeAllGroupChats(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetBotCommandScope().
+ auto result(std::make_shared<BotCommandScopeAllGroupChats>());
+ return result;
+}
+
+std::string TgTypeParser::parseBotCommandScopeAllGroupChats(const BotCommandScopeAllGroupChats::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseBotCommandScope(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ // The last comma will be erased by parseBotCommandScope().
+ return result;
+}
+
+BotCommandScopeAllChatAdministrators::Ptr TgTypeParser::parseJsonAndGetBotCommandScopeAllChatAdministrators(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetBotCommandScope().
+ auto result(std::make_shared<BotCommandScopeAllChatAdministrators>());
+ return result;
+}
+
+std::string TgTypeParser::parseBotCommandScopeAllChatAdministrators(const BotCommandScopeAllChatAdministrators::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseBotCommandScope(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ // The last comma will be erased by parseBotCommandScope().
+ return result;
+}
+
+BotCommandScopeChat::Ptr TgTypeParser::parseJsonAndGetBotCommandScopeChat(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetBotCommandScope().
+ auto result(std::make_shared<BotCommandScopeChat>());
+ result->chatId = data.get<std::int64_t>("chat_id", 0);
+ return result;
+}
+
+std::string TgTypeParser::parseBotCommandScopeChat(const BotCommandScopeChat::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseBotCommandScope(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ appendToJson(result, "chat_id", object->chatId);
+ // The last comma will be erased by parseBotCommandScope().
+ return result;
+}
+
+BotCommandScopeChatAdministrators::Ptr TgTypeParser::parseJsonAndGetBotCommandScopeChatAdministrators(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetBotCommandScope().
+ auto result(std::make_shared<BotCommandScopeChatAdministrators>());
+ result->chatId = data.get<std::int64_t>("chat_id", 0);
+ return result;
+}
+
+std::string TgTypeParser::parseBotCommandScopeChatAdministrators(const BotCommandScopeChatAdministrators::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseBotCommandScope(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ appendToJson(result, "chat_id", object->chatId);
+ // The last comma will be erased by parseBotCommandScope().
+ return result;
+}
+
+BotCommandScopeChatMember::Ptr TgTypeParser::parseJsonAndGetBotCommandScopeChatMember(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetBotCommandScope().
+ auto result(std::make_shared<BotCommandScopeChatMember>());
+ result->chatId = data.get<std::int64_t>("chat_id", 0);
+ result->userId = data.get<std::int64_t>("user_id", 0);
+ return result;
+}
+
+std::string TgTypeParser::parseBotCommandScopeChatMember(const BotCommandScopeChatMember::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseBotCommandScope(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ appendToJson(result, "chat_id", object->chatId);
+ appendToJson(result, "user_id", object->userId);
+ // The last comma will be erased by parseBotCommandScope().
+ return result;
+}
+
OrderInfo::Ptr TgTypeParser::parseJsonAndGetOrderInfo(const boost::property_tree::ptree& data) const {
- auto result(make_shared<OrderInfo>());
- result->name = data.get<string>("name", "");
- result->phoneNumber = data.get<string>("phone_number", "");
- result->email = data.get<string>("email", "");
+ auto result(std::make_shared<OrderInfo>());
+ result->name = data.get<std::string>("name", "");
+ result->phoneNumber = data.get<std::string>("phone_number", "");
+ result->email = data.get<std::string>("email", "");
result->shippingAddress = tryParseJson(&TgTypeParser::parseJsonAndGetShippingAddress, data, "shipping_address");
return result;
}
-string TgTypeParser::parseOrderInfo(const OrderInfo::Ptr& object) const {
+std::string TgTypeParser::parseOrderInfo(const OrderInfo::Ptr& object) const {
if (!object) {
return "";
}
@@ -2284,15 +3205,15 @@ string TgTypeParser::parseOrderInfo(const OrderInfo::Ptr& object) const {
}
PreCheckoutQuery::Ptr TgTypeParser::parseJsonAndGetPreCheckoutQuery(const boost::property_tree::ptree& data) const {
- auto result(make_shared<PreCheckoutQuery>());
- result->id = data.get<string>("id");
+ auto result(std::make_shared<PreCheckoutQuery>());
+ result->id = data.get<std::string>("id");
result->from = tryParseJson(&TgTypeParser::parseJsonAndGetUser, data, "user");
- result->currency = data.get<string>("currency");
- result->totalAmount = data.get<int32_t>("total_amount");
+ result->currency = data.get<std::string>("currency");
+ result->totalAmount = data.get<std::int32_t>("total_amount");
return result;
}
-string TgTypeParser::parsePreCheckoutQuery(const PreCheckoutQuery::Ptr& object) const {
+std::string TgTypeParser::parsePreCheckoutQuery(const PreCheckoutQuery::Ptr& object) const {
std::string result;
result += '{';
appendToJson(result, "id", object->id);
@@ -2308,16 +3229,16 @@ string TgTypeParser::parsePreCheckoutQuery(const PreCheckoutQuery::Ptr& object)
ShippingAddress::Ptr TgTypeParser::parseJsonAndGetShippingAddress(const boost::property_tree::ptree& data) const {
ShippingAddress::Ptr result;
- result->countryCode = data.get<string>("country_code");
- result->state = data.get<string>("state", "");
- result->city = data.get<string>("city");
- result->streetLine1 = data.get<string>("street_line1");
- result->streetLine2 = data.get<string>("street_line2");
- result->postCode = data.get<string>("post_code");
+ result->countryCode = data.get<std::string>("country_code");
+ result->state = data.get<std::string>("state", "");
+ result->city = data.get<std::string>("city");
+ result->streetLine1 = data.get<std::string>("street_line1");
+ result->streetLine2 = data.get<std::string>("street_line2");
+ result->postCode = data.get<std::string>("post_code");
return result;
}
-string TgTypeParser::parseShippingAddress(const ShippingAddress::Ptr& object) const {
+std::string TgTypeParser::parseShippingAddress(const ShippingAddress::Ptr& object) const {
std::string result;
result += '{';
appendToJson(result, "country_code", object->countryCode);
@@ -2334,14 +3255,14 @@ string TgTypeParser::parseShippingAddress(const ShippingAddress::Ptr& object) co
}
ShippingOption::Ptr TgTypeParser::parseJsonAndGetShippingOption(const boost::property_tree::ptree& data) const {
- auto result(make_shared<ShippingOption>());
- result->id = data.get<string>("id");
- result->title = data.get<string>("title");
+ auto result(std::make_shared<ShippingOption>());
+ result->id = data.get<std::string>("id");
+ result->title = data.get<std::string>("title");
result->prices = parseJsonAndGetArray<LabeledPrice>(&TgTypeParser::parseJsonAndGetLabeledPrice, data, "prices");
return result;
}
-string TgTypeParser::parseShippingOption(const ShippingOption::Ptr& object) const {
+std::string TgTypeParser::parseShippingOption(const ShippingOption::Ptr& object) const {
std::string result;
result += '{';
appendToJson(result, "id", object->id);
@@ -2354,16 +3275,16 @@ string TgTypeParser::parseShippingOption(const ShippingOption::Ptr& object) cons
}
ShippingQuery::Ptr TgTypeParser::parseJsonAndGetShippingQuery(const boost::property_tree::ptree& data) const {
- auto result(make_shared<ShippingQuery>());
- result->id = data.get<string>("id");
+ auto result(std::make_shared<ShippingQuery>());
+ result->id = data.get<std::string>("id");
result->from = tryParseJson(&TgTypeParser::parseJsonAndGetUser, data, "from");
- result->invoicePayload = data.get<string>("invoice_payload");
+ result->invoicePayload = data.get<std::string>("invoice_payload");
result->shippingAddress = tryParseJson(&TgTypeParser::parseJsonAndGetShippingAddress, data, "shipping_address");
return result;
}
-string TgTypeParser::parseShippingQuery(const ShippingQuery::Ptr& object) const {
- string result;
+std::string TgTypeParser::parseShippingQuery(const ShippingQuery::Ptr& object) const {
+ std::string result;
result += '{';
appendToJson(result, "id", object->id);
result += R"("from":)";
@@ -2379,17 +3300,17 @@ string TgTypeParser::parseShippingQuery(const ShippingQuery::Ptr& object) const
}
SuccessfulPayment::Ptr TgTypeParser::parseJsonAndGetSuccessfulPayment(const boost::property_tree::ptree& data) const {
- auto result(make_shared<SuccessfulPayment>());
- result->currency = data.get<string>("currency");
- result->totalAmount = data.get<int32_t>("total_amount");
- result->invoicePayload = data.get<string>("invoice_payload");
- result->shippingOptionId = data.get<string>("shipping_option_id");
+ auto result(std::make_shared<SuccessfulPayment>());
+ result->currency = data.get<std::string>("currency");
+ result->totalAmount = data.get<std::int32_t>("total_amount");
+ result->invoicePayload = data.get<std::string>("invoice_payload");
+ result->shippingOptionId = data.get<std::string>("shipping_option_id");
result->orderInfo = tryParseJson(&TgTypeParser::parseJsonAndGetOrderInfo, data, "order_info");
return result;
}
std::string TgTypeParser::parseSuccessfulPayment(const SuccessfulPayment::Ptr& object) const {
- string result;
+ std::string result;
result += '{';
appendToJson(result, "currency", object->currency);
appendToJson(result, "total_amount", object->totalAmount);
@@ -2403,18 +3324,18 @@ std::string TgTypeParser::parseSuccessfulPayment(const SuccessfulPayment::Ptr& o
return result;
}
-PassportData::Ptr TgTypeParser::parseJsonAndGetPassportData(const ptree& data) const {
- auto result(make_shared<PassportData>());
+PassportData::Ptr TgTypeParser::parseJsonAndGetPassportData(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<PassportData>());
result->data = parseJsonAndGetArray<EncryptedPassportElement>(&TgTypeParser::parseJsonAndGetEncryptedPassportElement, data, "data");
result->credentials = tryParseJson(&TgTypeParser::parseJsonAndGetEncryptedCredentials, data, "credentials");
return result;
}
-string TgTypeParser::parsePassportData(const PassportData::Ptr& object) const {
+std::string TgTypeParser::parsePassportData(const PassportData::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "data", parseArray(&TgTypeParser::parseEncryptedPassportElement, object->data));
appendToJson(result, "credentials", parseEncryptedCredentials(object->credentials));
@@ -2423,20 +3344,20 @@ string TgTypeParser::parsePassportData(const PassportData::Ptr& object) const {
return result;
}
-PassportFile::Ptr TgTypeParser::parseJsonAndGetPassportFile(const ptree& data) const {
- auto result(make_shared<PassportFile>());
- result->fileId = data.get<string>("file_id", "");
- result->fileUniqueId = data.get<string>("file_unique_id", "");
- result->fileSize = data.get<int32_t>("file_size", 0);
- result->fileDate = data.get<int32_t>("file_date", 0);
+PassportFile::Ptr TgTypeParser::parseJsonAndGetPassportFile(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<PassportFile>());
+ result->fileId = data.get<std::string>("file_id", "");
+ result->fileUniqueId = data.get<std::string>("file_unique_id", "");
+ result->fileSize = data.get<std::int32_t>("file_size", 0);
+ result->fileDate = data.get<std::int32_t>("file_date", 0);
return result;
}
-string TgTypeParser::parsePassportFile(const PassportFile::Ptr& object) const {
+std::string TgTypeParser::parsePassportFile(const PassportFile::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "file_id", object->fileId);
appendToJson(result, "file_unique_id", object->fileUniqueId);
@@ -2447,26 +3368,26 @@ string TgTypeParser::parsePassportFile(const PassportFile::Ptr& object) const {
return result;
}
-EncryptedPassportElement::Ptr TgTypeParser::parseJsonAndGetEncryptedPassportElement(const ptree& data) const {
- auto result(make_shared<EncryptedPassportElement>());
- result->type = data.get<string>("type", "");
- result->data = data.get<string>("data", "");
- result->phoneNumber = data.get<string>("phone_number", "");
- result->email = data.get<string>("email", "");
+EncryptedPassportElement::Ptr TgTypeParser::parseJsonAndGetEncryptedPassportElement(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<EncryptedPassportElement>());
+ result->type = data.get<std::string>("type", "");
+ result->data = data.get<std::string>("data", "");
+ result->phoneNumber = data.get<std::string>("phone_number", "");
+ result->email = data.get<std::string>("email", "");
result->files = parseJsonAndGetArray<PassportFile>(&TgTypeParser::parseJsonAndGetPassportFile, data, "files");
result->frontSide = tryParseJson(&TgTypeParser::parseJsonAndGetPassportFile, data, "front_side");
result->reverseSide = tryParseJson(&TgTypeParser::parseJsonAndGetPassportFile, data, "reverse_side");
result->selfie = tryParseJson(&TgTypeParser::parseJsonAndGetPassportFile, data, "selfie");
result->translation = parseJsonAndGetArray<PassportFile>(&TgTypeParser::parseJsonAndGetPassportFile, data, "translation");
- result->hash = data.get<string>("hash", "");
+ result->hash = data.get<std::string>("hash", "");
return result;
}
-string TgTypeParser::parseEncryptedPassportElement(const EncryptedPassportElement::Ptr& object) const {
+std::string TgTypeParser::parseEncryptedPassportElement(const EncryptedPassportElement::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "type", object->type);
appendToJson(result, "data", object->data);
@@ -2483,19 +3404,19 @@ string TgTypeParser::parseEncryptedPassportElement(const EncryptedPassportElemen
return result;
}
-EncryptedCredentials::Ptr TgTypeParser::parseJsonAndGetEncryptedCredentials(const ptree& data) const {
- auto result(make_shared<EncryptedCredentials>());
- result->data = data.get<string>("data", "");
- result->hash = data.get<string>("hash", "");
- result->secret = data.get<string>("secret", "");
+EncryptedCredentials::Ptr TgTypeParser::parseJsonAndGetEncryptedCredentials(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<EncryptedCredentials>());
+ result->data = data.get<std::string>("data", "");
+ result->hash = data.get<std::string>("hash", "");
+ result->secret = data.get<std::string>("secret", "");
return result;
}
-string TgTypeParser::parseEncryptedCredentials(const EncryptedCredentials::Ptr& object) const {
+std::string TgTypeParser::parseEncryptedCredentials(const EncryptedCredentials::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "data", object->data);
appendToJson(result, "hash", object->hash);
@@ -2505,67 +3426,67 @@ string TgTypeParser::parseEncryptedCredentials(const EncryptedCredentials::Ptr&
return result;
}
-PassportElementError::Ptr TgTypeParser::parseJsonAndGetPassportElementError(const ptree& data) const {
- string source = data.get<string>("source", "");
+PassportElementError::Ptr TgTypeParser::parseJsonAndGetPassportElementError(const boost::property_tree::ptree& data) const {
+ std::string source = data.get<std::string>("source", "");
PassportElementError::Ptr result;
if (source == PassportElementErrorDataField::SOURCE) {
- result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorDataField(data));
+ result = std::static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorDataField(data));
} else if (source == PassportElementErrorFrontSide::SOURCE) {
- result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorFrontSide(data));
+ result = std::static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorFrontSide(data));
} else if (source == PassportElementErrorReverseSide::SOURCE) {
- result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorReverseSide(data));
+ result = std::static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorReverseSide(data));
} else if (source == PassportElementErrorSelfie::SOURCE) {
- result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorSelfie(data));
+ result = std::static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorSelfie(data));
} else if (source == PassportElementErrorFile::SOURCE) {
- result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorFile(data));
+ result = std::static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorFile(data));
} else if (source == PassportElementErrorFiles::SOURCE) {
- result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorFiles(data));
+ result = std::static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorFiles(data));
} else if (source == PassportElementErrorTranslationFile::SOURCE) {
- result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorTranslationFile(data));
+ result = std::static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorTranslationFile(data));
} else if (source == PassportElementErrorTranslationFiles::SOURCE) {
- result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorTranslationFiles(data));
+ result = std::static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorTranslationFiles(data));
} else if (source == PassportElementErrorUnspecified::SOURCE) {
- result = static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorUnspecified(data));
+ result = std::static_pointer_cast<PassportElementError>(parseJsonAndGetPassportElementErrorUnspecified(data));
} else {
- result = make_shared<PassportElementError>();
+ result = std::make_shared<PassportElementError>();
}
- result->source = data.get<string>("source", "");
- result->type = data.get<string>("type", "");
- result->message = data.get<string>("message", "");
+ result->source = data.get<std::string>("source", "");
+ result->type = data.get<std::string>("type", "");
+ result->message = data.get<std::string>("message", "");
return result;
}
-string TgTypeParser::parsePassportElementError(const PassportElementError::Ptr& object) const {
+std::string TgTypeParser::parsePassportElementError(const PassportElementError::Ptr& object) const {
if (!object) {
return "";
}
- string result;
+ std::string result;
result += '{';
appendToJson(result, "source", object->source);
appendToJson(result, "type", object->type);
appendToJson(result, "message", object->message);
if (object->source == PassportElementErrorDataField::SOURCE) {
- result += parsePassportElementErrorDataField(static_pointer_cast<PassportElementErrorDataField>(object));
+ result += parsePassportElementErrorDataField(std::static_pointer_cast<PassportElementErrorDataField>(object));
} else if (object->source == PassportElementErrorFrontSide::SOURCE) {
- result += parsePassportElementErrorFrontSide(static_pointer_cast<PassportElementErrorFrontSide>(object));
+ result += parsePassportElementErrorFrontSide(std::static_pointer_cast<PassportElementErrorFrontSide>(object));
} else if (object->source == PassportElementErrorReverseSide::SOURCE) {
- result += parsePassportElementErrorReverseSide(static_pointer_cast<PassportElementErrorReverseSide>(object));
+ result += parsePassportElementErrorReverseSide(std::static_pointer_cast<PassportElementErrorReverseSide>(object));
} else if (object->source == PassportElementErrorSelfie::SOURCE) {
- result += parsePassportElementErrorSelfie(static_pointer_cast<PassportElementErrorSelfie>(object));
+ result += parsePassportElementErrorSelfie(std::static_pointer_cast<PassportElementErrorSelfie>(object));
} else if (object->source == PassportElementErrorFile::SOURCE) {
- result += parsePassportElementErrorFile(static_pointer_cast<PassportElementErrorFile>(object));
+ result += parsePassportElementErrorFile(std::static_pointer_cast<PassportElementErrorFile>(object));
} else if (object->source == PassportElementErrorFiles::SOURCE) {
- result += parsePassportElementErrorFiles(static_pointer_cast<PassportElementErrorFiles>(object));
+ result += parsePassportElementErrorFiles(std::static_pointer_cast<PassportElementErrorFiles>(object));
} else if (object->source == PassportElementErrorTranslationFile::SOURCE) {
- result += parsePassportElementErrorTranslationFile(static_pointer_cast<PassportElementErrorTranslationFile>(object));
+ result += parsePassportElementErrorTranslationFile(std::static_pointer_cast<PassportElementErrorTranslationFile>(object));
} else if (object->source == PassportElementErrorTranslationFiles::SOURCE) {
- result += parsePassportElementErrorTranslationFiles(static_pointer_cast<PassportElementErrorTranslationFiles>(object));
+ result += parsePassportElementErrorTranslationFiles(std::static_pointer_cast<PassportElementErrorTranslationFiles>(object));
} else if (object->source == PassportElementErrorUnspecified::SOURCE) {
- result += parsePassportElementErrorUnspecified(static_pointer_cast<PassportElementErrorUnspecified>(object));
+ result += parsePassportElementErrorUnspecified(std::static_pointer_cast<PassportElementErrorUnspecified>(object));
}
removeLastComma(result);
@@ -2573,120 +3494,120 @@ string TgTypeParser::parsePassportElementError(const PassportElementError::Ptr&
return result;
}
-PassportElementErrorDataField::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorDataField(const ptree& data) const {
+PassportElementErrorDataField::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorDataField(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetPassportElementError().
- auto result(make_shared<PassportElementErrorDataField>());
- result->fieldName = data.get<string>("field_name", "");
- result->dataHash = data.get<string>("data_hash", "");
+ auto result(std::make_shared<PassportElementErrorDataField>());
+ result->fieldName = data.get<std::string>("field_name", "");
+ result->dataHash = data.get<std::string>("data_hash", "");
return result;
}
-string TgTypeParser::parsePassportElementErrorDataField(const PassportElementErrorDataField::Ptr& object) const {
+std::string TgTypeParser::parsePassportElementErrorDataField(const PassportElementErrorDataField::Ptr& object) const {
if (!object) {
return "";
}
// This function will be called by parsePassportElementError(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "field_name", object->fieldName);
appendToJson(result, "data_hash", object->dataHash);
// The last comma will be erased by parsePassportElementError().
return result;
}
-PassportElementErrorFrontSide::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorFrontSide(const ptree& data) const {
+PassportElementErrorFrontSide::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorFrontSide(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetPassportElementError().
- auto result(make_shared<PassportElementErrorFrontSide>());
- result->fileHash = data.get<string>("file_hash", "");
+ auto result(std::make_shared<PassportElementErrorFrontSide>());
+ result->fileHash = data.get<std::string>("file_hash", "");
return result;
}
-string TgTypeParser::parsePassportElementErrorFrontSide(const PassportElementErrorFrontSide::Ptr& object) const {
+std::string TgTypeParser::parsePassportElementErrorFrontSide(const PassportElementErrorFrontSide::Ptr& object) const {
if (!object) {
return "";
}
// This function will be called by parsePassportElementError(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "file_hash", object->fileHash);
// The last comma will be erased by parsePassportElementError().
return result;
}
-PassportElementErrorReverseSide::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorReverseSide(const ptree& data) const {
+PassportElementErrorReverseSide::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorReverseSide(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetPassportElementError().
- auto result(make_shared<PassportElementErrorReverseSide>());
- result->fileHash = data.get<string>("file_hash", "");
+ auto result(std::make_shared<PassportElementErrorReverseSide>());
+ result->fileHash = data.get<std::string>("file_hash", "");
return result;
}
-string TgTypeParser::parsePassportElementErrorReverseSide(const PassportElementErrorReverseSide::Ptr& object) const {
+std::string TgTypeParser::parsePassportElementErrorReverseSide(const PassportElementErrorReverseSide::Ptr& object) const {
if (!object) {
return "";
}
// This function will be called by parsePassportElementError(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "file_hash", object->fileHash);
// The last comma will be erased by parsePassportElementError().
return result;
}
-PassportElementErrorSelfie::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorSelfie(const ptree& data) const {
+PassportElementErrorSelfie::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorSelfie(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetPassportElementError().
- auto result(make_shared<PassportElementErrorSelfie>());
- result->fileHash = data.get<string>("file_hash", "");
+ auto result(std::make_shared<PassportElementErrorSelfie>());
+ result->fileHash = data.get<std::string>("file_hash", "");
return result;
}
-string TgTypeParser::parsePassportElementErrorSelfie(const PassportElementErrorSelfie::Ptr& object) const {
+std::string TgTypeParser::parsePassportElementErrorSelfie(const PassportElementErrorSelfie::Ptr& object) const {
if (!object) {
return "";
}
// This function will be called by parsePassportElementError(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "file_hash", object->fileHash);
// The last comma will be erased by parsePassportElementError().
return result;
}
-PassportElementErrorFile::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorFile(const ptree& data) const {
+PassportElementErrorFile::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorFile(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetPassportElementError().
- auto result(make_shared<PassportElementErrorFile>());
- result->fileHash = data.get<string>("file_hash", "");
+ auto result(std::make_shared<PassportElementErrorFile>());
+ result->fileHash = data.get<std::string>("file_hash", "");
return result;
}
-string TgTypeParser::parsePassportElementErrorFile(const PassportElementErrorFile::Ptr& object) const {
+std::string TgTypeParser::parsePassportElementErrorFile(const PassportElementErrorFile::Ptr& object) const {
if (!object) {
return "";
}
// This function will be called by parsePassportElementError(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "file_hash", object->fileHash);
// The last comma will be erased by parsePassportElementError().
return result;
}
-PassportElementErrorFiles::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorFiles(const ptree& data) const {
+PassportElementErrorFiles::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorFiles(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetPassportElementError().
- auto result(make_shared<PassportElementErrorFiles>());
+ auto result(std::make_shared<PassportElementErrorFiles>());
result->fileHashes = parseJsonAndGetArray<std::string>(
- [] (const ptree& innerData)->std::string {
+ [] (const boost::property_tree::ptree& innerData)->std::string {
return innerData.get<std::string>("");
}, data, "file_hashes");
return result;
}
-string TgTypeParser::parsePassportElementErrorFiles(const PassportElementErrorFiles::Ptr& object) const {
+std::string TgTypeParser::parsePassportElementErrorFiles(const PassportElementErrorFiles::Ptr& object) const {
if (!object) {
return "";
}
// This function will be called by parsePassportElementError(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "file_hashes",
parseArray<std::string>([] (const std::string& s)->std::string {
return s;
@@ -2695,42 +3616,42 @@ string TgTypeParser::parsePassportElementErrorFiles(const PassportElementErrorFi
return result;
}
-PassportElementErrorTranslationFile::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorTranslationFile(const ptree& data) const {
+PassportElementErrorTranslationFile::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorTranslationFile(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetPassportElementError().
- auto result(make_shared<PassportElementErrorTranslationFile>());
- result->fileHash = data.get<string>("file_hash", "");
+ auto result(std::make_shared<PassportElementErrorTranslationFile>());
+ result->fileHash = data.get<std::string>("file_hash", "");
return result;
}
-string TgTypeParser::parsePassportElementErrorTranslationFile(const PassportElementErrorTranslationFile::Ptr& object) const {
+std::string TgTypeParser::parsePassportElementErrorTranslationFile(const PassportElementErrorTranslationFile::Ptr& object) const {
if (!object) {
return "";
}
// This function will be called by parsePassportElementError(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "file_hash", object->fileHash);
// The last comma will be erased by parsePassportElementError().
return result;
}
-PassportElementErrorTranslationFiles::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorTranslationFiles(const ptree& data) const {
+PassportElementErrorTranslationFiles::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorTranslationFiles(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetPassportElementError().
- auto result(make_shared<PassportElementErrorTranslationFiles>());
+ auto result(std::make_shared<PassportElementErrorTranslationFiles>());
result->fileHashes = parseJsonAndGetArray<std::string>(
- [] (const ptree& innerData)->std::string {
+ [] (const boost::property_tree::ptree& innerData)->std::string {
return innerData.get<std::string>("");
}, data, "file_hashes");
return result;
}
-string TgTypeParser::parsePassportElementErrorTranslationFiles(const PassportElementErrorTranslationFiles::Ptr& object) const {
+std::string TgTypeParser::parsePassportElementErrorTranslationFiles(const PassportElementErrorTranslationFiles::Ptr& object) const {
if (!object) {
return "";
}
// This function will be called by parsePassportElementError(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "file_hashes",
parseArray<std::string>([] (const std::string& s)->std::string {
return s;
@@ -2739,27 +3660,27 @@ string TgTypeParser::parsePassportElementErrorTranslationFiles(const PassportEle
return result;
}
-PassportElementErrorUnspecified::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorUnspecified(const ptree& data) const {
+PassportElementErrorUnspecified::Ptr TgTypeParser::parseJsonAndGetPassportElementErrorUnspecified(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetPassportElementError().
- auto result(make_shared<PassportElementErrorUnspecified>());
- result->elementHash = data.get<string>("element_hash", "");
+ auto result(std::make_shared<PassportElementErrorUnspecified>());
+ result->elementHash = data.get<std::string>("element_hash", "");
return result;
}
-string TgTypeParser::parsePassportElementErrorUnspecified(const PassportElementErrorUnspecified::Ptr& object) const {
+std::string TgTypeParser::parsePassportElementErrorUnspecified(const PassportElementErrorUnspecified::Ptr& object) const {
if (!object) {
return "";
}
// This function will be called by parsePassportElementError(), so I don't add
- // curly brackets to the result string.
- string result;
+ // curly brackets to the result std::string.
+ std::string result;
appendToJson(result, "element_hash", object->elementHash);
// The last comma will be erased by parsePassportElementError().
return result;
}
-void TgTypeParser::appendToJson(string& json, const string& varName, const string& value) const {
+void TgTypeParser::appendToJson(std::string& json, const std::string& varName, const std::string& value) const {
if (value.empty()) {
return;
}
diff --git a/src/types/BotCommandScope.cpp b/src/types/BotCommandScope.cpp
new file mode 100644
index 0000000..0e52dd8
--- /dev/null
+++ b/src/types/BotCommandScope.cpp
@@ -0,0 +1,19 @@
+#include "tgbot/types/BotCommandScopeDefault.h"
+#include "tgbot/types/BotCommandScopeAllPrivateChats.h"
+#include "tgbot/types/BotCommandScopeAllGroupChats.h"
+#include "tgbot/types/BotCommandScopeAllChatAdministrators.h"
+#include "tgbot/types/BotCommandScopeChat.h"
+#include "tgbot/types/BotCommandScopeChatAdministrators.h"
+#include "tgbot/types/BotCommandScopeChatMember.h"
+
+#include <string>
+
+using namespace TgBot;
+
+const std::string BotCommandScopeDefault::TYPE = "default";
+const std::string BotCommandScopeAllPrivateChats::TYPE = "all_private_chats";
+const std::string BotCommandScopeAllGroupChats::TYPE = "all_group_chats";
+const std::string BotCommandScopeAllChatAdministrators::TYPE = "all_chat_administrators";
+const std::string BotCommandScopeChat::TYPE = "chat";
+const std::string BotCommandScopeChatAdministrators::TYPE = "chat_administrators";
+const std::string BotCommandScopeChatMember::TYPE = "chat_member";
diff --git a/src/types/ChatMember.cpp b/src/types/ChatMember.cpp
new file mode 100644
index 0000000..7f5b704
--- /dev/null
+++ b/src/types/ChatMember.cpp
@@ -0,0 +1,17 @@
+#include "tgbot/types/ChatMemberOwner.h"
+#include "tgbot/types/ChatMemberAdministrator.h"
+#include "tgbot/types/ChatMemberMember.h"
+#include "tgbot/types/ChatMemberRestricted.h"
+#include "tgbot/types/ChatMemberLeft.h"
+#include "tgbot/types/ChatMemberBanned.h"
+
+#include <string>
+
+using namespace TgBot;
+
+const std::string ChatMemberOwner::STATUS = "creator";
+const std::string ChatMemberAdministrator::STATUS = "administrator";
+const std::string ChatMemberMember::STATUS = "member";
+const std::string ChatMemberRestricted::STATUS = "restricted";
+const std::string ChatMemberLeft::STATUS = "left";
+const std::string ChatMemberBanned::STATUS = "kicked";
diff --git a/src/types/InputMedia.cpp b/src/types/InputMedia.cpp
new file mode 100644
index 0000000..eff22df
--- /dev/null
+++ b/src/types/InputMedia.cpp
@@ -0,0 +1,15 @@
+#include "tgbot/types/InputMediaPhoto.h"
+#include "tgbot/types/InputMediaVideo.h"
+#include "tgbot/types/InputMediaAnimation.h"
+#include "tgbot/types/InputMediaAudio.h"
+#include "tgbot/types/InputMediaDocument.h"
+
+#include <string>
+
+using namespace TgBot;
+
+const std::string InputMediaPhoto::TYPE = "photo";
+const std::string InputMediaVideo::TYPE = "video";
+const std::string InputMediaAnimation::TYPE = "animation";
+const std::string InputMediaAudio::TYPE = "audio";
+const std::string InputMediaDocument::TYPE = "document";
diff --git a/src/types/InputMessageContent.cpp b/src/types/InputMessageContent.cpp
new file mode 100644
index 0000000..2f54e00
--- /dev/null
+++ b/src/types/InputMessageContent.cpp
@@ -0,0 +1,15 @@
+#include "tgbot/types/InputTextMessageContent.h"
+#include "tgbot/types/InputLocationMessageContent.h"
+#include "tgbot/types/InputVenueMessageContent.h"
+#include "tgbot/types/InputContactMessageContent.h"
+#include "tgbot/types/InputInvoiceMessageContent.h"
+
+#include <string>
+
+using namespace TgBot;
+
+const std::string InputTextMessageContent::TYPE = "text";
+const std::string InputLocationMessageContent::TYPE = "location";
+const std::string InputVenueMessageContent::TYPE = "venue";
+const std::string InputContactMessageContent::TYPE = "contact";
+const std::string InputInvoiceMessageContent::TYPE = "invoice";