summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Morozenkov <m@oleg.rocks>2022-09-11 17:11:45 +0300
committerGitHub <noreply@github.com>2022-09-11 17:11:45 +0300
commit30136601c6755e5d7c2174ebd4ed49595e10a54b (patch)
treea9e6b8b9d653baea4e86d366e38e09f9038a4eda
parentc82fa054194126e400e7e87dabbdaf20d847703c (diff)
parent270612dc36df84fe25d7fa5e59ca20647b1e5da9 (diff)
Merge pull request #227 from llnulldisk/master
Update to API 5.7
-rw-r--r--.gitignore3
-rw-r--r--CMakeLists.txt5
-rw-r--r--README.md4
-rw-r--r--include/tgbot/Api.h409
-rw-r--r--include/tgbot/TgTypeParser.h73
-rw-r--r--include/tgbot/types/Animation.h7
-rw-r--r--include/tgbot/types/Audio.h15
-rw-r--r--include/tgbot/types/CallbackGame.h3
-rw-r--r--include/tgbot/types/Chat.h40
-rw-r--r--include/tgbot/types/ChatAdministratorRights.h75
-rw-r--r--include/tgbot/types/ChatMemberAdministrator.h36
-rw-r--r--include/tgbot/types/ChatMemberBanned.h2
-rw-r--r--include/tgbot/types/ChatMemberRestricted.h2
-rw-r--r--include/tgbot/types/Document.h15
-rw-r--r--include/tgbot/types/File.h26
-rw-r--r--include/tgbot/types/InlineKeyboardButton.h44
-rw-r--r--include/tgbot/types/KeyboardButton.h24
-rw-r--r--include/tgbot/types/LoginUrl.h73
-rw-r--r--include/tgbot/types/MenuButton.h34
-rw-r--r--include/tgbot/types/MenuButtonCommands.h27
-rw-r--r--include/tgbot/types/MenuButtonDefault.h27
-rw-r--r--include/tgbot/types/MenuButtonWebApp.h40
-rw-r--r--include/tgbot/types/Message.h54
-rw-r--r--include/tgbot/types/MessageEntity.h22
-rw-r--r--include/tgbot/types/SentWebAppMessage.h26
-rw-r--r--include/tgbot/types/Sticker.h41
-rw-r--r--include/tgbot/types/StickerSet.h18
-rw-r--r--include/tgbot/types/User.h33
-rw-r--r--include/tgbot/types/Video.h15
-rw-r--r--include/tgbot/types/VideoChatEnded.h26
-rw-r--r--include/tgbot/types/VideoChatParticipantsInvited.h28
-rw-r--r--include/tgbot/types/VideoChatScheduled.h26
-rw-r--r--include/tgbot/types/VideoChatStarted.h21
-rw-r--r--include/tgbot/types/Voice.h7
-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/WebAppData.h32
-rw-r--r--include/tgbot/types/WebAppInfo.h26
-rw-r--r--include/tgbot/types/WebhookInfo.h9
-rw-r--r--src/Api.cpp570
-rw-r--r--src/TgTypeParser.cpp452
-rw-r--r--src/types/MenuButton.cpp11
44 files changed, 1889 insertions, 613 deletions
diff --git a/.gitignore b/.gitignore
index 6a1f7ed..9f1d7bb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,12 +12,13 @@ doc/
Thumbs.db
TgBot_test
.idea/
-.vscode/
docs/
cmake-build-*
# Visual Studio
/.vs/
+.vscode/
+/build/
/out/
# MacOS dependecies
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f11f6d8..664bf67 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,6 +36,7 @@ set(SRC_LIST
src/types/InputFile.cpp
src/types/InputMedia.cpp
src/types/InputMessageContent.cpp
+ src/types/MenuButton.cpp
src/types/PassportElementError.cpp)
# libs
@@ -66,7 +67,7 @@ endif()
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR_RELEASE})
if(NOT Boost_USE_STATIC_LIBS)
- add_definitions(-DBOOST_ALL_DYN_LINK)
+ add_definitions(-DBOOST_ALL_DYN_LINK)
endif()
set(LIB_LIST
@@ -107,7 +108,7 @@ if(BUILD_DOCUMENTATION)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
- install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc/html/ TYPE DOC)
+ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc/html/ TYPE DOC)
endif()
if(BUILD_SHARED_LIBS)
diff --git a/README.md b/README.md
index 74a0130..d3aeb69 100644
--- a/README.md
+++ b/README.md
@@ -11,9 +11,7 @@ Documentation is located [here](http://reo7sp.github.io/tgbot-cpp).
## State
-- [x] Bot API 3.0 ~ 3.6
-- [x] Bot API 4.0 ~ 4.9
-- [x] Bot API 5.0 ~ 5.5 (Implemented all APIs except 'Run Your Own Bot API Server')
+- [x] Bot API 3.0 ~ 6.2
## Sample
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index 87c6c11..78fb4fa 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -1,5 +1,5 @@
-#ifndef TGBOT_CPP_API_H
-#define TGBOT_CPP_API_H
+#ifndef TGBOT_API_H
+#define TGBOT_API_H
#include "tgbot/TgTypeParser.h"
#include "tgbot/net/HttpClient.h"
@@ -19,6 +19,7 @@
#include "tgbot/types/File.h"
#include "tgbot/types/InputMedia.h"
#include "tgbot/types/GameHighScore.h"
+#include "tgbot/types/SentWebAppMessage.h"
#include "tgbot/types/LabeledPrice.h"
#include "tgbot/types/ShippingOption.h"
#include "tgbot/types/BotCommand.h"
@@ -68,37 +69,40 @@ public:
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 @ref Update.
+ * @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.
*
- * 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.
+ * If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secretToken.
+ * If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content.
*
- * You will not be able to receive updates using @ref Api::getUpdates for as long as an outgoing webhook is set up.
+ * You will not be able to receive updates using 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.
+ * 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 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 maxConnection Optional. The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. 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 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 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
+ * @param secretToken Optional. A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters. Only characters A-Z, a-z, 0-9, _ and - are allowed. The header is useful to ensure that the request comes from a webhook set by you.
*
- * @return True on success.
+ * @return Returns True on success.
*/
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;
+ bool dropPendingUpdates = false,
+ const std::string& secretToken = "") const;
/**
* @brief Use this method to remove webhook integration if you decide to switch back to @ref Api::getUpdates.
@@ -135,11 +139,13 @@ public:
* @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
* @param parseMode Optional. Mode for parsing entities in the message text. See https://core.telegram.org/bots/api#formatting-options for more details.
* @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound.
- * @param entities Optional. List of special entities that appear in message text, which can be specified instead of parseMode
+ * @param entities Optional. A JSON-serialized list of special entities that appear in message text, which can be specified instead of parseMode
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
*
* @return On success, the sent Message is returned.
*/
+
Message::Ptr sendMessage(boost::variant<std::int64_t, const std::string&> chatId,
const std::string& text,
bool disableWebPagePreview = false,
@@ -148,67 +154,90 @@ public:
const std::string& parseMode = "",
bool disableNotification = false,
const std::vector<MessageEntity::Ptr>& entities = std::vector<MessageEntity::Ptr>(),
- bool allowSendingWithoutReply = false) const;
+ bool allowSendingWithoutReply = false,
+ bool protectContent = false) const;
/**
* @brief Use this method to forward messages of any kind.
- * @param chatId Unique identifier for the target chat.
- * @param fromChatId Unique identifier for the chat where the original message was sent — User or GroupChat id.
- * @param messageId Unique message identifier.
- * @param disableNotification Optional. Sends the message silenty.
- * @return On success, the sent message is returned.
+ *
+ * Service messages can't be forwarded.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
+ * @param messageId Message identifier in the chat specified in fromChatId
+ * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound.
+ * @param protectContent Optional. Protects the contents of the forwarded message from forwarding and saving
+ *
+ * @return On success, the sent Message is returned.
*/
- Message::Ptr forwardMessage(std::int64_t chatId, std::int64_t fromChatId, std::int32_t messageId, bool disableNotification = false) const;
+ Message::Ptr forwardMessage(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<std::int64_t, const std::string&> fromChatId,
+ std::int32_t messageId,
+ bool disableNotification = false,
+ bool protectContent = false) const;
/**
* @brief Use this method to copy messages of any kind.
- * The method is analogous to the method Api::forwardMessages, but the copied message doesn't have a link to the original message.
+ *
+ * Service messages and invoice messages can't be copied.
+ * The method is analogous to the method Api::forwardMessage, but the copied message doesn't have a link to the original message.
*
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
* @param messageId Message identifier in the chat specified in fromChatId
* @param caption Optional. New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept
* @param parseMode Optional. Mode for parsing entities in the new caption. See https://core.telegram.org/bots/api#formatting-options for more details.
- * @param captionEntities Optional. List of special entities that appear in the new caption, which can be specified instead of parseMode
+ * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the new caption, which can be specified instead of parseMode
* @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound.
* @param replyToMessageId Optional. If the message is a reply, ID of the original message
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
* @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
*
- * @return the MessageId of the sent message on success.
+ * @return Returns the MessageId of the sent message on success.
*/
- MessageId::Ptr copyMessage(std::int64_t chatId, std::int64_t fromChatId, std::int32_t messageId,
- const std::string& caption = "", const std::string& parseMode = "", const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(),
- bool disableNotification = false, std::int32_t replyToMessageId = 0, bool allowSendingWithoutReply = false,
- GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
+ MessageId::Ptr copyMessage(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<std::int64_t, const std::string&> fromChatId,
+ std::int32_t messageId,
+ const std::string& caption = "",
+ const std::string& parseMode = "",
+ const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(),
+ bool disableNotification = false,
+ std::int32_t replyToMessageId = 0,
+ bool allowSendingWithoutReply = false,
+ GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
+ bool protectContent = false) const;
/**
* @brief Use this method to send photos.
*
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- * @param photo Photo to send. Pass a fileId as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. https://core.telegram.org/bots/api#sending-files
+ * @param photo Photo to send. Pass a fileId as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. https://core.telegram.org/bots/api#sending-files
* @param caption Optional. Photo caption (may also be used when resending photos by fileId), 0-1024 characters after entities parsing
* @param replyToMessageId Optional. If the message is a reply, ID of the original message
* @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
* @param parseMode Optional. Mode for parsing entities in the photo caption. See https://core.telegram.org/bots/api#formatting-options for more details.
- * @param disableNotification Optional.Sends the message silently. Users will receive a notification with no sound.
- * @param captionEntities Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound.
+ * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
*
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendPhoto(std::int64_t chatId,
- boost::variant<InputFile::Ptr, std::string> photo,
+ Message::Ptr sendPhoto(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<InputFile::Ptr, const std::string&> photo,
const std::string& caption = "",
std::int32_t replyToMessageId = 0,
GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode = "",
bool disableNotification = false,
const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(),
- bool allowSendingWithoutReply = false) const;
+ bool allowSendingWithoutReply = false,
+ bool protectContent = false) const;
/**
- * @brief Use this method to send audio files, if you want Telegram clients to display them in the music player.
+ * @brief Use this method to send audio files, if you want Telegram clients to display them in the music player.
+ *
* Your audio must be in the .MP3 or .M4A format.
* Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
*
@@ -225,27 +254,30 @@ public:
* @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
* @param parseMode Optional. Mode for parsing entities in the audio caption. See https://core.telegram.org/bots/api#formatting-options for more details.
* @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound.
- * @param captionEntities Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
*
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendAudio(std::int64_t chatId,
- boost::variant<InputFile::Ptr, std::string> audio,
+ Message::Ptr sendAudio(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<InputFile::Ptr, const std::string&> audio,
const std::string& caption = "",
std::int32_t duration = 0,
const std::string& performer = "",
const std::string& title = "",
- boost::variant<InputFile::Ptr, std::string> thumb = "",
+ boost::variant<InputFile::Ptr, const std::string&> thumb = "",
std::int32_t replyToMessageId = 0,
GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode = "",
bool disableNotification = false,
const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(),
- bool allowSendingWithoutReply = false) const;
+ bool allowSendingWithoutReply = false,
+ bool protectContent = false) const;
/**
* @brief Use this method to send general files.
+ *
* Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
*
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@@ -256,15 +288,16 @@ public:
* @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
* @param parseMode Optional. Mode for parsing entities in the document caption. See https://core.telegram.org/bots/api#formatting-options for more details.
* @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound.
- * @param captionEntities Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode
* @param disableContentTypeDetection Optional. Disables automatic server-side content type detection for files uploaded using multipart/form-data
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
*
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendDocument(std::int64_t chatId,
- boost::variant<InputFile::Ptr, std::string> document,
- boost::variant<InputFile::Ptr, std::string> thumb = "",
+ Message::Ptr sendDocument(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<InputFile::Ptr, const std::string&> document,
+ boost::variant<InputFile::Ptr, const std::string&> thumb = "",
const std::string& caption = "",
std::int32_t replyToMessageId = 0,
GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
@@ -272,10 +305,12 @@ public:
bool disableNotification = false,
const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(),
bool disableContentTypeDetection = false,
- bool allowSendingWithoutReply = false) const;
+ bool allowSendingWithoutReply = false,
+ bool protectContent = false) const;
/**
* @brief Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
+ *
* Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
*
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@@ -284,34 +319,37 @@ public:
* @param duration Optional. Duration of sent video in seconds
* @param width Optional. Video width
* @param height Optional. Video height
- * @param thumb Optional Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. https://core.telegram.org/bots/api#sending-files
+ * @param thumb Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. https://core.telegram.org/bots/api#sending-files
* @param caption Optional. Video caption (may also be used when resending videos by fileId), 0-1024 characters after entities parsing
* @param replyToMessageId Optional. If the message is a reply, ID of the original message
* @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
* @param parseMode Optional. Mode for parsing entities in the video caption. See https://core.telegram.org/bots/api#formatting-options for more details.
* @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound.
- * @param captionEntities Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
*
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendVideo(std::int64_t chatId,
- boost::variant<InputFile::Ptr, std::string> video,
+ Message::Ptr sendVideo(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<InputFile::Ptr, const std::string&> video,
bool supportsStreaming = false,
std::int32_t duration = 0,
std::int32_t width = 0,
std::int32_t height = 0,
- boost::variant<InputFile::Ptr, std::string> thumb = "",
+ boost::variant<InputFile::Ptr, const std::string&> thumb = "",
const std::string& caption = "",
std::int32_t replyToMessageId = 0,
GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode = "",
bool disableNotification = false,
const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(),
- bool allowSendingWithoutReply = false) const;
+ bool allowSendingWithoutReply = false,
+ bool protectContent = false) const;
/**
* @brief Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).
+ *
* Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.
*
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@@ -325,27 +363,30 @@ public:
* @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
* @param parseMode Optional. Mode for parsing entities in the animation caption. See https://core.telegram.org/bots/api#formatting-options for more details.
* @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound.
- * @param captionEntities Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
*
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendAnimation(std::int64_t chatId,
- boost::variant<InputFile::Ptr, std::string> animation,
+ Message::Ptr sendAnimation(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<InputFile::Ptr, const std::string&> animation,
std::int32_t duration = 0,
std::int32_t width = 0,
std::int32_t height = 0,
- boost::variant<InputFile::Ptr, std::string> thumb = "",
+ boost::variant<InputFile::Ptr, const std::string&> thumb = "",
const std::string& caption = "",
std::int32_t replyToMessageId = 0,
GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode = "",
bool disableNotification = false,
const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(),
- bool allowSendingWithoutReply = false) const;
+ bool allowSendingWithoutReply = false,
+ bool protectContent = false) const;
/**
* @brief Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message.
+ *
* For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document).
* Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
*
@@ -357,13 +398,14 @@ public:
* @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
* @param parseMode Optional. Mode for parsing entities in the voice message caption. See https://core.telegram.org/bots/api#formatting-options for more details.
* @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound.
- * @param captionEntities Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
+ * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
*
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendVoice(std::int64_t chatId,
- boost::variant<InputFile::Ptr, std::string> voice,
+ Message::Ptr sendVoice(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<InputFile::Ptr, const std::string&> voice,
const std::string& caption = "",
std::int32_t duration = 0,
std::int32_t replyToMessageId = 0,
@@ -371,11 +413,13 @@ public:
const std::string& parseMode = "",
bool disableNotification = false,
const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(),
- bool allowSendingWithoutReply = false) const;
+ bool allowSendingWithoutReply = false,
+ bool protectContent = false) const;
/**
- * @brief As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long.
- * Use this method to send video messages.
+ * @brief Use this method to send video messages.
+ *
+ * As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long.
*
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param videoNote Video note to send. Pass a fileId as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. Sending video notes by a URL is currently unsupported. https://core.telegram.org/bots/api#sending-files
@@ -386,21 +430,24 @@ public:
* @param thumb Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. https://core.telegram.org/bots/api#sending-files
* @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
*
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendVideoNote(std::int64_t chatId,
- boost::variant<InputFile::Ptr, std::string> videoNote,
+ Message::Ptr sendVideoNote(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<InputFile::Ptr, const std::string&> videoNote,
std::int64_t replyToMessageId = 0,
bool disableNotification = false,
std::int32_t duration = 0,
std::int32_t length = 0,
- boost::variant<InputFile::Ptr, std::string> thumb = "",
+ boost::variant<InputFile::Ptr, const std::string&> thumb = "",
GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
- bool allowSendingWithoutReply = false) const;
+ bool allowSendingWithoutReply = false,
+ bool protectContent = false) const;
/**
* @brief Use this method to send a group of photos, videos, documents or audios as an album.
+ *
* Documents and audio files can be only group in an album with messages of the same type.
*
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@@ -408,14 +455,16 @@ public:
* @param disableNotification Optional. Sends messages silently. Users will receive a notification with no sound.
* @param replyToMessageId Optional. If the messages are a reply, ID of the original message
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ * @param protectContent Optional. Protects the contents of the sent messages from forwarding and saving
*
* @return On success, an array of Messages that were sent is returned.
*/
- std::vector<Message::Ptr> sendMediaGroup(std::int64_t chatId,
+ std::vector<Message::Ptr> sendMediaGroup(boost::variant<std::int64_t, const std::string&> chatId,
const std::vector<InputMedia::Ptr>& media,
bool disableNotification = false,
std::int32_t replyToMessageId = 0,
- bool allowSendingWithoutReply = false) const;
+ bool allowSendingWithoutReply = false,
+ bool protectContent = false) const;
/**
* @brief Use this method to send point on the map.
@@ -423,7 +472,7 @@ public:
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param latitude Latitude of the location
* @param longitude Longitude of the location
- * @param livePeriod Optional. Period in seconds for which the location will be updated (see Live Locations, should be between 60 and 86400.
+ * @param livePeriod Optional. Period in seconds for which the location will be updated (see https://telegram.org/blog/live-locations, should be between 60 and 86400.
* @param replyToMessageId Optional. If the message is a reply, ID of the original message
* @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
* @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound.
@@ -431,20 +480,22 @@ public:
* @param heading Optional. For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.
* @param proximityAlertRadius Optional. For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
*
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendLocation(std::int64_t chatId,
+ Message::Ptr sendLocation(boost::variant<std::int64_t, const std::string&> chatId,
float latitude,
float longitude,
- std::uint32_t livePeriod = 0,
+ std::int32_t livePeriod = 0,
std::int32_t replyToMessageId = 0,
GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
bool disableNotification = false,
float horizontalAccuracy = 0,
- std::uint32_t heading = 0,
- std::uint32_t proximityAlertRadius = 0,
- bool allowSendingWithoutReply = false) const;
+ std::int32_t heading = 0,
+ std::int32_t proximityAlertRadius = 0,
+ bool allowSendingWithoutReply = false,
+ bool protectContent = false) const;
/**
* @brief Use this method to edit live location messages.
@@ -499,10 +550,11 @@ public:
* @param googlePlaceId Optional. Google Places identifier of the venue
* @param googlePlaceType Optional. Google Places type of the venue. (See https://developers.google.com/places/web-service/supported_types)
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
*
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendVenue(std::int64_t chatId,
+ Message::Ptr sendVenue(boost::variant<std::int64_t, const std::string&> chatId,
float latitude,
float longitude,
const std::string& title,
@@ -514,7 +566,8 @@ public:
GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& googlePlaceId = "",
const std::string& googlePlaceType = "",
- bool allowSendingWithoutReply = false) const;
+ bool allowSendingWithoutReply = false,
+ bool protectContent = false) const;
/**
* @brief Use this method to send phone contacts.
@@ -528,10 +581,11 @@ public:
* @param replyToMessageId Optional. If the message is a reply, ID of the original message
* @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove keyboard or to force a reply from the user.
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
*
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendContact(std::int64_t chatId,
+ Message::Ptr sendContact(boost::variant<std::int64_t, const std::string&> chatId,
const std::string& phoneNumber,
const std::string& firstName,
const std::string& lastName = "",
@@ -539,7 +593,8 @@ public:
bool disableNotification = false,
std::int32_t replyToMessageId = 0,
GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
- bool allowSendingWithoutReply = false) const;
+ bool allowSendingWithoutReply = false,
+ bool protectContent = false) const;
/**
* @brief Use this method to send a native poll.
@@ -561,10 +616,11 @@ public:
* @param closeDate Optional. Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can't be used together with openPeriod.
* @param isClosed Optional. Pass True, if the poll needs to be immediately closed. This can be useful for poll preview.
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
*
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendPoll(std::int64_t chatId,
+ Message::Ptr sendPoll(boost::variant<std::int64_t, const std::string&> chatId,
const std::string& question,
const std::vector<std::string>& options,
bool disableNotification = false,
@@ -580,7 +636,8 @@ public:
std::int32_t openPeriod = 0,
std::int32_t closeDate = 0,
bool isClosed = false,
- bool allowSendingWithoutReply = false) const;
+ bool allowSendingWithoutReply = false,
+ bool protectContent = false) const;
/**
* @brief Use this method to send an animated emoji that will display a random value.
@@ -591,15 +648,17 @@ public:
* @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
* @param emoji Optional. Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲”
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding
*
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendDice(std::int64_t chatId,
+ Message::Ptr sendDice(boost::variant<std::int64_t, const std::string&> chatId,
bool disableNotification = false,
std::int32_t replyToMessageId = 0,
GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& emoji = "",
- bool allowSendingWithoutReply = false) const;
+ bool allowSendingWithoutReply = false,
+ bool protectContent = false) const;
/**
* @brief Use this method when you need to tell the user that something is happening on the bot's side.
@@ -696,26 +755,27 @@ public:
/**
* @brief Use this method to promote or demote a user in a supergroup or a channel.
- * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
+ *
+ * The bot must be an administrator in the chat for this to work and must have the appropriate administrator 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 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 canManageVideoChats Optional. Pass True, if the administrator can manage video chats
* @param canRestrictMembers Optional. Pass True, if the administrator can restrict, ban or unban chat members
*
- * @return True on success.
+ * @return Returns True on success.
*/
- bool promoteChatMember(std::int64_t chatId,
+ bool promoteChatMember(boost::variant<std::int64_t, const std::string&> chatId,
std::int64_t userId,
bool canChangeInfo = false,
bool canPostMessages = false,
@@ -726,7 +786,7 @@ public:
bool canPromoteMembers = false,
bool isAnonymous = false,
bool canManageChat = false,
- bool canManageVoiceChats = false,
+ bool canManageVideoChats = false,
bool canRestrictMembers = false) const;
/**
@@ -813,7 +873,7 @@ public:
* @return the edited invite link as a ChatInviteLink object.
*/
ChatInviteLink::Ptr editChatInviteLink(std::int64_t chatId,
- std::string inviteLink,
+ const std::string& inviteLink,
std::int32_t expireDate = 0,
std::int32_t memberLimit = 0,
const std::string& name = "",
@@ -830,7 +890,7 @@ public:
* @return the revoked invite link as ChatInviteLink object.
*/
ChatInviteLink::Ptr revokeChatInviteLink(std::int64_t chatId,
- std::string inviteLink) const;
+ const std::string& inviteLink) const;
/**
* @brief Use this method to approve a chat join request.
@@ -1030,6 +1090,48 @@ public:
const std::string& languageCode = "") const;
/**
+ * @brief Use this method to change the bot's menu button in a private chat, or the default menu button.
+ *
+ * @param chatId Optional. Unique identifier for the target private chat. If not specified, default bot's menu button will be changed
+ * @param menuButton Optional. A JSON-serialized object for the new bot's menu button. Defaults to MenuButtonDefault
+ *
+ * @return Returns True on success.
+ */
+ bool setChatMenuButton(std::int64_t chatId = 0,
+ MenuButton::Ptr menuButton = nullptr) const;
+
+ /**
+ * @brief Use this method to get the current value of the bot's menu button in a private chat, or the default menu button.
+ *
+ * @param chatId Optional. Unique identifier for the target private chat. If not specified, default bot's menu button will be returned
+ *
+ * @return Returns MenuButton on success.
+ */
+ MenuButton::Ptr getChatMenuButton(std::int64_t chatId = 0) const;
+
+ /**
+ * @brief Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels.
+ *
+ * These rights will be suggested to users, but they are are free to modify the list before adding the bot.
+ *
+ * @param rights Optional. A JSON-serialized object describing new default administrator rights. If not specified, the default administrator rights will be cleared.
+ * @param forChannels Optional. Pass True to change the default administrator rights of the bot in channels. Otherwise, the default administrator rights of the bot for groups and supergroups will be changed.
+ *
+ * @return Returns True on success.
+ */
+ bool setMyDefaultAdministratorRights(ChatAdministratorRights::Ptr rights = nullptr,
+ bool forChannels = false) const;
+
+ /**
+ * @brief Use this method to get the current default administrator rights of the bot.
+ *
+ * @param forChannels Optional. Pass True to get default administrator rights of the bot in channels. Otherwise, default administrator rights of the bot for groups and supergroups will be returned.
+ *
+ * @return Returns ChatAdministratorRights on success.
+ */
+ ChatAdministratorRights::Ptr getMyDefaultAdministratorRights(bool forChannels = false) const;
+
+ /**
* @brief Use this method to edit text and game messages.
*
* @param text New text of the message, 1-4096 characters after entities parsing
@@ -1129,15 +1231,17 @@ public:
* @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
* @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound.
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
*
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendSticker(std::int64_t chatId,
- boost::variant<InputFile::Ptr, std::string> sticker,
+ Message::Ptr sendSticker(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<InputFile::Ptr, const std::string&> sticker,
std::int32_t replyToMessageId = 0,
GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
bool disableNotification = false,
- bool allowSendingWithoutReply = false) const;
+ bool allowSendingWithoutReply = false,
+ bool protectContent = false) const;
/**
* @brief Use this method to get a sticker set.
@@ -1149,6 +1253,15 @@ public:
StickerSet::Ptr getStickerSet(const std::string& name) const;
/**
+ * @brief Use this method to get information about custom emoji stickers by their identifiers.
+ *
+ * @param customEmojiIds List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.
+ *
+ * @return Returns an Array of Sticker objects.
+ */
+ std::vector<Sticker::Ptr> getCustomEmojiStickers(const std::vector<std::string>& customEmojiIds) const;
+
+ /**
* @brief Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times).
* @param userId User identifier of sticker file owner.
* @param pngSticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px.
@@ -1157,16 +1270,20 @@ public:
File::Ptr uploadStickerFile(std::int64_t userId, InputFile::Ptr pngSticker) const;
/**
- * @brief Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. You must use exactly one of the fields pngSticker or tgsSticker.
+ * @brief Use this method to create a new sticker set owned by a user.
+ *
+ * The bot will be able to edit the sticker set thus created.
+ * You must use exactly one of the fields pngSticker, tgsSticker, or webmSticker.
*
* @param userId User identifier of created sticker set owner
- * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters.
+ * @param 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 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
+ * @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. https://core.telegram.org/bots/api#sending-files
+ * @param tgsSticker Optional. TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/stickers#animated-sticker-requirements for technical requirements
+ * @param webmSticker Optional. WEBM video with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/stickers#video-sticker-requirements for technical requirements
+ * @param stickerType Optional. Type of stickers in the set, pass “regular” or “mask”. Custom emoji sticker sets can't be created via the Bot API at the moment. By default, a regular sticker set is created.
*
* @return Returns True on success.
*/
@@ -1174,20 +1291,27 @@ public:
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;
+ boost::variant<InputFile::Ptr, const std::string&> pngSticker = "",
+ InputFile::Ptr tgsSticker = nullptr,
+ InputFile::Ptr webmSticker = nullptr,
+ const std::string& stickerType = "") 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.
+ * @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, tgs_sticker, or webm_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.
*
* @param userId User identifier of sticker set owner
* @param name Sticker set name
* @param emojis One or more emoji corresponding to the sticker
* @param maskPosition Optional. A JSON-serialized object for position where the mask should be placed on faces
- * @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
+ * @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. https://core.telegram.org/bots/api#sending-files
+ * @param tgsSticker Optional. TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/stickers#animated-sticker-requirements for technical requirements
+ * @param webmSticker Optional. WEBM video with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/stickers#video-sticker-requirements for technical requirements
*
* @return Returns True on success.
*/
@@ -1195,8 +1319,9 @@ public:
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;
+ boost::variant<InputFile::Ptr, const std::string&> pngSticker = "",
+ InputFile::Ptr tgsSticker = nullptr,
+ InputFile::Ptr webmSticker = nullptr) const;
/**
* @brief Use this method to move a sticker in a set created by the bot to a specific position.
@@ -1245,6 +1370,17 @@ public:
std::int32_t cacheTime = 300, bool isPersonal = false, const std::string& nextOffset = "", const std::string& switchPmText = "", const std::string& switchPmParameter = "") const;
/**
+ * @brief Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated.
+ *
+ * @param webAppQueryId Unique identifier for the query to be answered
+ * @param result A JSON-serialized object describing the message to be sent
+ *
+ * @return On success, a SentWebAppMessage object is returned.
+ */
+ SentWebAppMessage::Ptr answerWebAppQuery(const std::string& webAppQueryId,
+ InlineQueryResult::Ptr result) const;
+
+ /**
* @brief Use this method to send invoices.
*
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@@ -1273,10 +1409,11 @@ public:
* @param maxTipAmount Optional. The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in https://core.telegram.org/bots/payments/currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0
* @param suggestedTipAmounts Optional. A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed maxTipAmount.
* @param startParameter Optional. Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
*
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendInvoice(std::int64_t chatId,
+ Message::Ptr sendInvoice(boost::variant<std::int64_t, const std::string&> chatId,
const std::string& title,
const std::string& description,
const std::string& payload,
@@ -1301,7 +1438,55 @@ public:
bool allowSendingWithoutReply = false,
std::int32_t maxTipAmount = 0,
const std::vector<std::int32_t>& suggestedTipAmounts = std::vector<std::int32_t>(),
- const std::string& startParameter = "") const;
+ const std::string& startParameter = "",
+ bool protectContent = false) const;
+
+ /**
+ * @brief Use this method to create a link for an invoice.
+ *
+ * @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 Payment 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 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 maxTipAmount = 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 providerData Optional. 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.
+ * @param photoSize Optional. Photo size in bytes
+ * @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 the user's phone number should be sent to the provider
+ * @param sendEmailToProvider Optional. Pass True, if the user's email address should be sent to the provider
+ * @param isFlexible Optional. Pass True, if the final price depends on the shipping method
+ *
+ * @return Returns the created invoice link as String on success.
+ */
+ std::string createInvoiceLink(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,
+ std::int32_t maxTipAmount = 0,
+ const std::vector<std::int32_t>& suggestedTipAmounts = std::vector<std::int32_t>(),
+ 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) const;
/**
* @brief Use this method to reply to shipping queries.
@@ -1350,9 +1535,10 @@ public:
* @param chatId Unique identifier for the target chat
* @param gameShortName Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
* @param replyToMessageId Optional. If the message is a reply, ID of the original message
- * @param replyMarkup Optional. A JSON-serialized object for an inline keyboard. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game.
+ * @param replyMarkup Optional. A JSON-serialized object for an inline keyboard. If empty, one 'Play gameTitle' button will be shown. If not empty, the first button must launch the game.
* @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound.
* @param allowSendingWithoutReply Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
*
* @return On success, the sent Message is returned.
*/
@@ -1361,7 +1547,8 @@ public:
std::int32_t replyToMessageId = 0,
InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>(),
bool disableNotification = false,
- bool allowSendingWithoutReply = false) const;
+ bool allowSendingWithoutReply = false,
+ bool protectContent = false) const;
/**
* @brief Use this method to set the score of the specified user in a game.
@@ -1410,4 +1597,4 @@ private:
};
}
-#endif //TGBOT_CPP_API_H
+#endif //TGBOT_API_H
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index db96a0b..cef1b60 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -1,5 +1,5 @@
-#ifndef TGBOT_CPP_TGTYPEPARSER_H
-#define TGBOT_CPP_TGTYPEPARSER_H
+#ifndef TGBOT_TGTYPEPARSER_H
+#define TGBOT_TGTYPEPARSER_H
#include "tgbot/export.h"
#include "tgbot/types/User.h"
@@ -23,15 +23,17 @@
#include "tgbot/types/VideoNote.h"
#include "tgbot/types/Contact.h"
#include "tgbot/types/Location.h"
+#include "tgbot/types/WebAppData.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/VideoChatScheduled.h"
+#include "tgbot/types/VideoChatStarted.h"
+#include "tgbot/types/VideoChatEnded.h"
+#include "tgbot/types/VideoChatParticipantsInvited.h"
#include "tgbot/types/Update.h"
#include "tgbot/types/UserProfilePhotos.h"
#include "tgbot/types/File.h"
+#include "tgbot/types/WebAppInfo.h"
#include "tgbot/types/ReplyKeyboardMarkup.h"
#include "tgbot/types/KeyboardButton.h"
#include "tgbot/types/KeyboardButtonPollType.h"
@@ -47,6 +49,7 @@
#include "tgbot/types/ChatMemberUpdated.h"
#include "tgbot/types/ChatJoinRequest.h"
#include "tgbot/types/ChatPhoto.h"
+#include "tgbot/types/ChatAdministratorRights.h"
#include "tgbot/types/ResponseParameters.h"
#include "tgbot/types/GenericReply.h"
#include "tgbot/types/InlineQuery.h"
@@ -72,13 +75,15 @@
#include "tgbot/types/InlineQueryResultVideo.h"
#include "tgbot/types/InlineQueryResultVoice.h"
#include "tgbot/types/ChosenInlineResult.h"
-#include "tgbot/types/CallbackGame.h"
+#include "tgbot/types/SentWebAppMessage.h"
#include "tgbot/types/Animation.h"
#include "tgbot/types/Game.h"
+#include "tgbot/types/CallbackGame.h"
#include "tgbot/types/GameHighScore.h"
#include "tgbot/types/CallbackQuery.h"
#include "tgbot/types/InlineKeyboardMarkup.h"
#include "tgbot/types/InlineKeyboardButton.h"
+#include "tgbot/types/LoginUrl.h"
#include "tgbot/types/WebhookInfo.h"
#include "tgbot/types/InputMessageContent.h"
#include "tgbot/types/InputTextMessageContent.h"
@@ -103,6 +108,10 @@
#include "tgbot/types/BotCommandScopeChat.h"
#include "tgbot/types/BotCommandScopeChatAdministrators.h"
#include "tgbot/types/BotCommandScopeChatMember.h"
+#include "tgbot/types/MenuButton.h"
+#include "tgbot/types/MenuButtonCommands.h"
+#include "tgbot/types/MenuButtonWebApp.h"
+#include "tgbot/types/MenuButtonDefault.h"
#include "tgbot/types/InputMedia.h"
#include "tgbot/types/InputMediaPhoto.h"
#include "tgbot/types/InputMediaVideo.h"
@@ -205,6 +214,9 @@ public:
Game::Ptr parseJsonAndGetGame(const boost::property_tree::ptree& data) const;
std::string parseGame(const Game::Ptr& object) const;
+ CallbackGame::Ptr parseJsonAndGetCallbackGame(const boost::property_tree::ptree& data) const;
+ std::string parseCallbackGame(const CallbackGame::Ptr& object) const;
+
GameHighScore::Ptr parseJsonAndGetGameHighScore(const boost::property_tree::ptree& data) const;
std::string parseGameHighScore(const GameHighScore::Ptr& object) const;
@@ -220,23 +232,26 @@ public:
Venue::Ptr parseJsonAndGetVenue(const boost::property_tree::ptree& data) const;
std::string parseVenue(const Venue::Ptr& object) const;
+ WebAppData::Ptr parseJsonAndGetWebAppData(const boost::property_tree::ptree& data) const;
+ std::string parseWebAppData(const WebAppData::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;
+ VideoChatScheduled::Ptr parseJsonAndGetVideoChatScheduled(const boost::property_tree::ptree& data) const;
+ std::string parseVideoChatScheduled(const VideoChatScheduled::Ptr& object) const;
- VoiceChatStarted::Ptr parseJsonAndGetVoiceChatStarted(const boost::property_tree::ptree& data) const;
- std::string parseVoiceChatStarted(const VoiceChatStarted::Ptr& object) const;
+ VideoChatStarted::Ptr parseJsonAndGetVideoChatStarted(const boost::property_tree::ptree& data) const;
+ std::string parseVideoChatStarted(const VideoChatStarted::Ptr& object) const;
- VoiceChatEnded::Ptr parseJsonAndGetVoiceChatEnded(const boost::property_tree::ptree& data) const;
- std::string parseVoiceChatEnded(const VoiceChatEnded::Ptr& object) const;
+ VideoChatEnded::Ptr parseJsonAndGetVideoChatEnded(const boost::property_tree::ptree& data) const;
+ std::string parseVideoChatEnded(const VideoChatEnded::Ptr& object) const;
- VoiceChatParticipantsInvited::Ptr parseJsonAndGetVoiceChatParticipantsInvited(const boost::property_tree::ptree& data) const;
- std::string parseVoiceChatParticipantsInvited(const VoiceChatParticipantsInvited::Ptr& object) const;
+ VideoChatParticipantsInvited::Ptr parseJsonAndGetVideoChatParticipantsInvited(const boost::property_tree::ptree& data) const;
+ std::string parseVideoChatParticipantsInvited(const VideoChatParticipantsInvited::Ptr& object) const;
Update::Ptr parseJsonAndGetUpdate(const boost::property_tree::ptree& data) const;
std::string parseUpdate(const Update::Ptr& object) const;
@@ -265,6 +280,9 @@ public:
File::Ptr parseJsonAndGetFile(const boost::property_tree::ptree& data) const;
std::string parseFile(const File::Ptr& object) const;
+ WebAppInfo::Ptr parseJsonAndGetWebAppInfo(const boost::property_tree::ptree& data) const;
+ std::string parseWebAppInfo(const WebAppInfo::Ptr& object) const;
+
ReplyKeyboardMarkup::Ptr parseJsonAndGetReplyKeyboardMarkup(const boost::property_tree::ptree& data) const;
std::string parseReplyKeyboardMarkup(const ReplyKeyboardMarkup::Ptr& object) const;
@@ -313,6 +331,9 @@ public:
ChatInviteLink::Ptr parseJsonAndGetChatInviteLink(const boost::property_tree::ptree& data) const;
std::string parseChatInviteLink(const ChatInviteLink::Ptr& object) const;
+ ChatAdministratorRights::Ptr parseJsonAndGetChatAdministratorRights(const boost::property_tree::ptree& data) const;
+ std::string parseChatAdministratorRights(const ChatAdministratorRights::Ptr& object) const;
+
ResponseParameters::Ptr parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const;
std::string parseResponseParameters(const ResponseParameters::Ptr& object) const;
@@ -388,6 +409,9 @@ public:
ChosenInlineResult::Ptr parseJsonAndGetChosenInlineResult(const boost::property_tree::ptree& data) const;
std::string parseChosenInlineResult(const ChosenInlineResult::Ptr& object) const;
+ SentWebAppMessage::Ptr parseJsonAndGetSentWebAppMessage(const boost::property_tree::ptree& data) const;
+ std::string parseSentWebAppMessage(const SentWebAppMessage::Ptr& object) const;
+
CallbackQuery::Ptr parseJsonAndGetCallbackQuery(const boost::property_tree::ptree& data) const;
std::string parseCallbackQuery(const CallbackQuery::Ptr& object) const;
@@ -397,6 +421,9 @@ public:
InlineKeyboardButton::Ptr parseJsonAndGetInlineKeyboardButton(const boost::property_tree::ptree& data) const;
std::string parseInlineKeyboardButton(const InlineKeyboardButton::Ptr& object) const;
+ LoginUrl::Ptr parseJsonAndGetLoginUrl(const boost::property_tree::ptree& data) const;
+ std::string parseLoginUrl(const LoginUrl::Ptr& object) const;
+
WebhookInfo::Ptr parseJsonAndGetWebhookInfo(const boost::property_tree::ptree& data) const;
std::string parseWebhookInfo(const WebhookInfo::Ptr& object) const;
@@ -451,6 +478,18 @@ public:
BotCommandScopeChatMember::Ptr parseJsonAndGetBotCommandScopeChatMember(const boost::property_tree::ptree& data) const;
std::string parseBotCommandScopeChatMember(const BotCommandScopeChatMember::Ptr& object) const;
+ MenuButton::Ptr parseJsonAndGetMenuButton(const boost::property_tree::ptree& data) const;
+ std::string parseMenuButton(const MenuButton::Ptr& object) const;
+
+ MenuButtonCommands::Ptr parseJsonAndGetMenuButtonCommands(const boost::property_tree::ptree& data) const;
+ std::string parseMenuButtonCommands(const MenuButtonCommands::Ptr& object) const;
+
+ MenuButtonWebApp::Ptr parseJsonAndGetMenuButtonWebApp(const boost::property_tree::ptree& data) const;
+ std::string parseMenuButtonWebApp(const MenuButtonWebApp::Ptr& object) const;
+
+ MenuButtonDefault::Ptr parseJsonAndGetMenuButtonDefault(const boost::property_tree::ptree& data) const;
+ std::string parseMenuButtonDefault(const MenuButtonDefault::Ptr& object) const;
+
OrderInfo::Ptr parseJsonAndGetOrderInfo(const boost::property_tree::ptree& data) const;
std::string parseOrderInfo(const OrderInfo::Ptr& object) const;
@@ -688,10 +727,8 @@ private:
}
}
-
void appendToJson(std::string& json, const std::string& varName, const std::string& value) const;
};
-
}
-#endif //TGBOT_CPP_TGTYPEPARSER_H
+#endif //TGBOT_TGTYPEPARSER_H
diff --git a/include/tgbot/types/Animation.h b/include/tgbot/types/Animation.h
index ee3cdd4..8d9688f 100644
--- a/include/tgbot/types/Animation.h
+++ b/include/tgbot/types/Animation.h
@@ -60,9 +60,12 @@ public:
std::string mimeType;
/**
- * @brief Optional. File size
+ * @brief Optional. File size in bytes.
+ *
+ * It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it.
+ * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
*/
- std::int32_t fileSize;
+ std::int64_t fileSize;
};
}
diff --git a/include/tgbot/types/Audio.h b/include/tgbot/types/Audio.h
index 50611ca..5095e5c 100644
--- a/include/tgbot/types/Audio.h
+++ b/include/tgbot/types/Audio.h
@@ -1,11 +1,11 @@
-#ifndef TGBOT_CPP_AUDIO_H
-#define TGBOT_CPP_AUDIO_H
+#ifndef TGBOT_AUDIO_H
+#define TGBOT_AUDIO_H
#include "tgbot/types/PhotoSize.h"
#include <cstdint>
-#include <string>
#include <memory>
+#include <string>
namespace TgBot {
@@ -56,9 +56,12 @@ public:
std::string mimeType;
/**
- * @brief Optional. File size
+ * @brief Optional. File size in bytes.
+ *
+ * It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it.
+ * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
*/
- std::int32_t fileSize;
+ std::int64_t fileSize;
/**
* @brief Optional. Thumbnail of the album cover to which the music file belongs
@@ -67,4 +70,4 @@ public:
};
}
-#endif //TGBOT_CPP_AUDIO_H
+#endif //TGBOT_AUDIO_H
diff --git a/include/tgbot/types/CallbackGame.h b/include/tgbot/types/CallbackGame.h
index 07bd28d..99c1b37 100644
--- a/include/tgbot/types/CallbackGame.h
+++ b/include/tgbot/types/CallbackGame.h
@@ -6,7 +6,8 @@
namespace TgBot {
/**
- * @brief A placeholder, currently holds no information. Use BotFather to set up your game.
+ * @brief A placeholder, currently holds no information.
+ * Use BotFather to set up your game.
*
* @ingroup types
*/
diff --git a/include/tgbot/types/Chat.h b/include/tgbot/types/Chat.h
index 24f7955..4a3f761 100644
--- a/include/tgbot/types/Chat.h
+++ b/include/tgbot/types/Chat.h
@@ -1,17 +1,18 @@
-#ifndef TGBOT_CPP_CHAT_H
-#define TGBOT_CPP_CHAT_H
+#ifndef TGBOT_CHAT_H
+#define TGBOT_CHAT_H
#include "tgbot/types/ChatPhoto.h"
#include "tgbot/types/ChatPermissions.h"
#include "tgbot/types/ChatLocation.h"
#include <cstdint>
-#include <string>
#include <memory>
+#include <string>
namespace TgBot {
class Message;
+
/**
* @brief This object represents a chat.
*
@@ -81,20 +82,37 @@ public:
bool hasPrivateForwards;
/**
+ * @brief Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat.
+ * Returned only in Api::getChat.
+ */
+ bool hasRestrictedVoiceAndVideoMessages;
+
+ /**
+ * @brief Optional. True, if users need to join the supergroup before they can send messages.
+ * Returned only in Api::getChat.
+ */
+ bool joinToSendMessages;
+
+ /**
+ * @brief Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators.
+ * Returned only in Api::getChat.
+ */
+ bool joinByRequest;
+
+ /**
* @brief Optional. Description, for groups, supergroups and channel chats.
* 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 Api::exportChatInviteLink.
+ * @brief Optional. Primary invite link, for groups, supergroups and channel chats.
* Returned only in Api::getChat.
*/
std::string inviteLink;
/**
- * @brief Optional. Pinned message, for groups, supergroups and channels.
+ * @brief Optional. The most recent pinned message (by sending date).
* Returned only in Api::getChat.
*/
std::shared_ptr<Message> pinnedMessage;
@@ -106,13 +124,13 @@ public:
ChatPermissions::Ptr permissions;
/**
- * @brief Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user.
+ * @brief Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds.
* 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.
+ * @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;
@@ -137,21 +155,19 @@ public:
/**
* @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.
+ * Returned only in Api::getChat.
*
* 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;
};
}
-#endif //TGBOT_CPP_CHAT_H
+#endif //TGBOT_CHAT_H
diff --git a/include/tgbot/types/ChatAdministratorRights.h b/include/tgbot/types/ChatAdministratorRights.h
new file mode 100644
index 0000000..52c70ca
--- /dev/null
+++ b/include/tgbot/types/ChatAdministratorRights.h
@@ -0,0 +1,75 @@
+#ifndef TGBOT_CHATADMINISTRATORRIGHTS_H
+#define TGBOT_CHATADMINISTRATORRIGHTS_H
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents the rights of an administrator in a chat.
+ *
+ * @ingroup types
+ */
+class ChatAdministratorRights {
+public:
+ typedef std::shared_ptr<ChatAdministratorRights> Ptr;
+
+ /**
+ * @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 delete messages of other users
+ */
+ bool canDeleteMessages;
+
+ /**
+ * @brief True, if the administrator can manage video chats
+ */
+ bool canManageVideoChats;
+
+ /**
+ * @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 Optional. True, if the administrator can post in the channel; channels only
+ */
+ bool canPostMessages;
+
+ /**
+ * @brief Optional. True, if the administrator can edit messages of other users and can pin messages; channels only
+ */
+ bool canEditMessages;
+
+ /**
+ * @brief Optional. True, if the user is allowed to pin messages; groups and supergroups only
+ */
+ bool canPinMessages;
+};
+}
+
+#endif //TGBOT_CHATADMINISTRATORRIGHTS_H
diff --git a/include/tgbot/types/ChatMemberAdministrator.h b/include/tgbot/types/ChatMemberAdministrator.h
index 1d5ad6f..02fc6bd 100644
--- a/include/tgbot/types/ChatMemberAdministrator.h
+++ b/include/tgbot/types/ChatMemberAdministrator.h
@@ -29,11 +29,6 @@ public:
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;
@@ -45,24 +40,14 @@ public:
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
+ * @brief rue, if the administrator can manage video chats
*/
- bool canManageVoiceChats;
+ bool canManageVideoChats;
/**
* @brief True, if the administrator can restrict, ban or unban chat members
@@ -85,9 +70,24 @@ public:
bool canInviteUsers;
/**
- * @brief True, if the user is allowed to pin messages; groups and supergroups only
+ * @brief Optional. True, if the administrator can post in the channel; channels only
+ */
+ bool canPostMessages;
+
+ /**
+ * @brief Optional. True, if the administrator can edit messages of other users and can pin messages; channels only
+ */
+ bool canEditMessages;
+
+ /**
+ * @brief Optional. True, if the user is allowed to pin messages; groups and supergroups only
*/
bool canPinMessages;
+
+ /**
+ * @brief Optional. Custom title for this user
+ */
+ std::string customTitle;
};
}
diff --git a/include/tgbot/types/ChatMemberBanned.h b/include/tgbot/types/ChatMemberBanned.h
index c54385e..90ae93e 100644
--- a/include/tgbot/types/ChatMemberBanned.h
+++ b/include/tgbot/types/ChatMemberBanned.h
@@ -26,7 +26,7 @@ public:
/**
* @brief Date when restrictions will be lifted for this user; unix time
*/
- std::int32_t untilDate;
+ std::uint32_t untilDate;
};
}
diff --git a/include/tgbot/types/ChatMemberRestricted.h b/include/tgbot/types/ChatMemberRestricted.h
index 76a9cd7..d64c849 100644
--- a/include/tgbot/types/ChatMemberRestricted.h
+++ b/include/tgbot/types/ChatMemberRestricted.h
@@ -72,7 +72,7 @@ public:
/**
* @brief Date when restrictions will be lifted for this user; unix time
*/
- std::int32_t untilDate;
+ std::uint32_t untilDate;
};
}
diff --git a/include/tgbot/types/Document.h b/include/tgbot/types/Document.h
index 71f4f3c..0593076 100644
--- a/include/tgbot/types/Document.h
+++ b/include/tgbot/types/Document.h
@@ -1,11 +1,11 @@
-#ifndef TGBOT_CPP_DOCUMENT_H
-#define TGBOT_CPP_DOCUMENT_H
+#ifndef TGBOT_DOCUMENT_H
+#define TGBOT_DOCUMENT_H
#include "tgbot/types/PhotoSize.h"
#include <cstdint>
-#include <string>
#include <memory>
+#include <string>
namespace TgBot {
@@ -46,10 +46,13 @@ public:
std::string mimeType;
/**
- * @brief Optional. File size
+ * @brief Optional. File size in bytes.
+ *
+ * It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it.
+ * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
*/
- std::int32_t fileSize;
+ std::int64_t fileSize;
};
}
-#endif //TGBOT_CPP_DOCUMENT_H
+#endif //TGBOT_DOCUMENT_H
diff --git a/include/tgbot/types/File.h b/include/tgbot/types/File.h
index e684528..e923881 100644
--- a/include/tgbot/types/File.h
+++ b/include/tgbot/types/File.h
@@ -1,18 +1,19 @@
-#ifndef TGBOT_CPP_FILE_H
-#define TGBOT_CPP_FILE_H
+#ifndef TGBOT_FILE_H
+#define TGBOT_FILE_H
#include <cstdint>
-#include <string>
#include <memory>
+#include <string>
namespace TgBot {
/**
* @brief This object represents a file ready to be downloaded.
- * The file can be downloaded via @ref Api::downloadFile.
- * It is guaranteed that the @ref File::filePath will be valid for at least 1 hour.
- * When the @ref File::filePath expires, a new one can be requested by calling @ref Api::getFile.
- * Maximum file size to download is 20 MB
+ * The file can be downloaded via Api::downloadFile.
+ * It is guaranteed that the File::filePath will be valid for at least 1 hour.
+ * When the File::filePath expires, a new one can be requested by calling Api::getFile.
+ *
+ * The maximum file size to download is 20 MB
*
* @ingroup types
*/
@@ -33,16 +34,19 @@ public:
std::string fileUniqueId;
/**
- * @brief Optional. File size, if known
+ * @brief Optional. File size in bytes.
+ *
+ * It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it.
+ * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
*/
- std::int32_t fileSize;
+ std::int64_t fileSize;
/**
* @brief Optional. File path.
- * Use @ref Api::downloadFile to get the file.
+ * Use Api::downloadFile to get the file.
*/
std::string filePath;
};
}
-#endif //TGBOT_CPP_FILE_H
+#endif //TGBOT_FILE_H
diff --git a/include/tgbot/types/InlineKeyboardButton.h b/include/tgbot/types/InlineKeyboardButton.h
index 9ec5120..f216669 100644
--- a/include/tgbot/types/InlineKeyboardButton.h
+++ b/include/tgbot/types/InlineKeyboardButton.h
@@ -1,16 +1,18 @@
#ifndef TGBOT_INLINEKEYBOARDBUTTON_H
#define TGBOT_INLINEKEYBOARDBUTTON_H
-#include "tgbot/types/CallbackGame.h"
+#include "tgbot/types/WebAppInfo.h"
#include "tgbot/types/LoginUrl.h"
+#include "tgbot/types/CallbackGame.h"
-#include <string>
#include <memory>
+#include <string>
namespace TgBot {
/**
- * @brief This object represents one button of an inline keyboard. You must use exactly one of the optional fields.
+ * @brief This object represents one button of an inline keyboard.
+ * You must use exactly one of the optional fields.
*
* @ingroup types
*/
@@ -24,45 +26,59 @@ public:
std::string text;
/**
- * @brief Optional. HTTP url to be opened when button is pressed.
+ * @brief Optional. HTTP or tg:// URL to be opened when the button is pressed.
+ * Links tg://user?id=<user_id> can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings.
*/
std::string url;
/**
- * @brief Optional. An HTTP URL used to automatically authorize the user.
+ * @brief Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes
*/
- LoginUrl::Ptr loginUrl;
+ std::string callbackData;
/**
- * @brief Optional. Data to be sent in a callback query to the bot when button is pressed.
+ * @brief Optional. Description of the Web App that will be launched when the user presses the button.
+ * The Web App will be able to send an arbitrary message on behalf of the user using the method Api::answerWebAppQuery.
+ * Available only in private chats between a user and the bot.
*/
- std::string callbackData;
+ WebAppInfo::Ptr webApp;
+
+ /**
+ * @brief Optional. An HTTPS URL used to automatically authorize the user.
+ * Can be used as a replacement for the Telegram Login Widget.
+ */
+ LoginUrl::Ptr loginUrl;
/**
- * @brief Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot‘s username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted.
+ * @brief Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field.
+ * May be empty, in which case just the bot's username will be inserted.
*
- * Note: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially useful when combined with switch_pm… actions – in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.
+ * Note: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it.
+ * Especially useful when combined with switch_pm… actions - in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.
*/
std::string switchInlineQuery;
/**
- * @brief Optional. If set, pressing the button will insert the bot‘s username and the specified inline query in the current chat's input field. Can be empty, in which case only the bot’s username will be inserted.
+ * @brief Optional. If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field.
+ * May be empty, in which case only the bot's username will be inserted.
+ *
+ * This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting something from multiple options.
*/
std::string switchInlineQueryCurrentChat;
/**
* @brief Optional. Description of the game that will be launched when the user presses the button.
*
- * Note: This type of button must always be the first button in the first row.
+ * NOTE: This type of button must always be the first button in the first row.
*/
CallbackGame::Ptr callbackGame;
/**
* @brief Optional. Specify True, to send a Pay button.
*
- * Note: This type of button must always be the first button in the first row.
+ * NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages.
*/
- bool pay = false;
+ bool pay;
};
}
diff --git a/include/tgbot/types/KeyboardButton.h b/include/tgbot/types/KeyboardButton.h
index 40e6af1..0847765 100644
--- a/include/tgbot/types/KeyboardButton.h
+++ b/include/tgbot/types/KeyboardButton.h
@@ -1,17 +1,18 @@
-#ifndef TGBOT_CPP_KEYBOARDBUTTON_H
-#define TGBOT_CPP_KEYBOARDBUTTON_H
+#ifndef TGBOT_KEYBOARDBUTTON_H
+#define TGBOT_KEYBOARDBUTTON_H
#include "tgbot/types/KeyboardButtonPollType.h"
+#include "tgbot/types/WebAppInfo.h"
-#include <string>
#include <memory>
+#include <string>
namespace TgBot {
/**
* @brief This object represents one button of the reply keyboard.
* For simple text buttons String can be used instead of this object to specify text of the button.
- * Optional fields request_contact, request_location, and request_poll are mutually exclusive.
+ * Optional fields webApp, requestContact, requestLocation, and requestPoll are mutually exclusive.
*
* @ingroup types
*/
@@ -28,22 +29,29 @@ public:
/**
* @brief Optional. If True, the user's phone number will be sent as a contact when the button is pressed.
- * Available in private chats only
+ * Available in private chats only.
*/
bool requestContact = false;
/**
* @brief Optional. If True, the user's current location will be sent when the button is pressed.
- * Available in private chats only
+ * Available in private chats only.
*/
bool requestLocation = false;
/**
* @brief Optional. If specified, the user will be asked to create a poll and send it to the bot when the button is pressed.
- * Available in private chats only
+ * Available in private chats only.
*/
KeyboardButtonPollType::Ptr requestPoll;
+
+ /**
+ * @brief Optional. If specified, the described Web App will be launched when the button is pressed.
+ * The Web App will be able to send a “web_app_data” service message.
+ * Available in private chats only.
+ */
+ WebAppInfo::Ptr webApp;
};
}
-#endif //TGBOT_CPP_KEYBOARDBUTTON_H
+#endif //TGBOT_KEYBOARDBUTTON_H
diff --git a/include/tgbot/types/LoginUrl.h b/include/tgbot/types/LoginUrl.h
index a816384..575a3a0 100644
--- a/include/tgbot/types/LoginUrl.h
+++ b/include/tgbot/types/LoginUrl.h
@@ -1,42 +1,53 @@
-#ifndef TGBOT_CPP_LOGINURL_H
-#define TGBOT_CPP_LOGINURL_H
+#ifndef TGBOT_LOGINURL_H
+#define TGBOT_LOGINURL_H
#include <memory>
#include <string>
-#include <vector>
namespace TgBot {
+/**
+ * @brief This object represents a parameter of the inline keyboard button used to automatically authorize a user.
+ * Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram.
+ * All the user needs to do is tap/click a button and confirm that they want to log in.
+ * Telegram apps support these buttons as of version 5.7.
+ *
+ * Sample bot: @discussbot
+ *
+ * @ingroup types
+ */
+class LoginUrl {
+public:
+ typedef std::shared_ptr<LoginUrl> Ptr;
+
/**
- * @brief This object represents a Poll.
- *
- * @ingroup types
+ * @brief An HTTP URL to be opened with user authorization data added to the query string when the button is pressed.
+ * If the user refuses to provide authorization data, the original URL without information about the user will be opened.
+ * The data added is the same as described in https://core.telegram.org/widgets/login#receiving-authorization-data
+ *
+ * NOTE: You must always check the hash of the received data to verify the authentication and the integrity of the data as described in https://core.telegram.org/widgets/login#checking-authorization
*/
- class LoginUrl{
- public:
- typedef std::shared_ptr<LoginUrl> Ptr;
-
- /**
- * @brief UAn HTTP URL to be opened with user authorization data added to the query string when the button is pressed..
- */
- std::string url;
-
- /**
- * @brief Optional. New text of the button in forwarded messages.
- */
- std::string forward_text;
-
- /**
- * @brief Optional. Username of a bot, which will be used for user authorization.
- */
- std::string bot_username;
-
- /**
- * @brief Optional. Pass True to request the permission for your bot to send messages to the user.
- */
- bool request_write_access;
- };
+ std::string url;
+ /**
+ * @brief Optional. New text of the button in forwarded messages.
+ */
+ std::string forwardText;
+
+ /**
+ * @brief Optional. Username of a bot, which will be used for user authorization.
+ * See https://core.telegram.org/widgets/login#setting-up-a-bot for more details.
+ * If not specified, the current bot's username will be assumed.
+ * The url's domain must be the same as the domain linked with the bot.
+ * See https://core.telegram.org/widgets/login#linking-your-domain-to-the-bot for more details.
+ */
+ std::string botUsername;
+
+ /**
+ * @brief Optional. Pass True to request the permission for your bot to send messages to the user.
+ */
+ bool requestWriteAccess;
+};
}
-#endif //TGBOT_CPP_LOGINURL_H
+#endif //TGBOT_LOGINURL_H
diff --git a/include/tgbot/types/MenuButton.h b/include/tgbot/types/MenuButton.h
new file mode 100644
index 0000000..011efd1
--- /dev/null
+++ b/include/tgbot/types/MenuButton.h
@@ -0,0 +1,34 @@
+#ifndef TGBOT_MENUBUTTON_H
+#define TGBOT_MENUBUTTON_H
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief This abstract class is base of all bot menu buttons.
+ *
+ * This object describes the bot's menu button in a private chat.
+ * If a menu button other than MenuButtonDefault is set for a private chat, then it is applied in the chat.
+ * Otherwise the default menu button is applied.
+ * By default, the menu button opens the list of bot commands.
+ *
+ * @ingroup types
+ */
+class MenuButton {
+public:
+ typedef std::shared_ptr<MenuButton> Ptr;
+
+ MenuButton() {}
+
+ virtual ~MenuButton() {}
+
+ /**
+ * @brief Type of the button
+ */
+ std::string type;
+};
+}
+
+#endif //TGBOT_MENUBUTTON_H
diff --git a/include/tgbot/types/MenuButtonCommands.h b/include/tgbot/types/MenuButtonCommands.h
new file mode 100644
index 0000000..ae51427
--- /dev/null
+++ b/include/tgbot/types/MenuButtonCommands.h
@@ -0,0 +1,27 @@
+#ifndef TGBOT_MENUBUTTONCOMMANDS_H
+#define TGBOT_MENUBUTTONCOMMANDS_H
+
+#include "tgbot/types/MenuButton.h"
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Represents a menu button, which opens the bot's list of commands.
+ *
+ * @ingroup types
+ */
+class MenuButtonCommands : public MenuButton {
+public:
+ static const std::string TYPE;
+
+ typedef std::shared_ptr<MenuButtonCommands> Ptr;
+
+ MenuButtonCommands() {
+ this->type = TYPE;
+ }
+};
+}
+
+#endif //TGBOT_MENUBUTTONCOMMANDS_H
diff --git a/include/tgbot/types/MenuButtonDefault.h b/include/tgbot/types/MenuButtonDefault.h
new file mode 100644
index 0000000..69cde92
--- /dev/null
+++ b/include/tgbot/types/MenuButtonDefault.h
@@ -0,0 +1,27 @@
+#ifndef TGBOT_MENUBUTTONDEFAULT_H
+#define TGBOT_MENUBUTTONDEFAULT_H
+
+#include "tgbot/types/MenuButton.h"
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief Describes that no specific value for the menu button was set.
+ *
+ * @ingroup types
+ */
+class MenuButtonDefault : public MenuButton {
+public:
+ static const std::string TYPE;
+
+ typedef std::shared_ptr<MenuButtonDefault> Ptr;
+
+ MenuButtonDefault() {
+ this->type = TYPE;
+ }
+};
+}
+
+#endif //TGBOT_MENUBUTTONDEFAULT_H
diff --git a/include/tgbot/types/MenuButtonWebApp.h b/include/tgbot/types/MenuButtonWebApp.h
new file mode 100644
index 0000000..ba26c51
--- /dev/null
+++ b/include/tgbot/types/MenuButtonWebApp.h
@@ -0,0 +1,40 @@
+#ifndef TGBOT_MENUBUTTONWEBAPP_H
+#define TGBOT_MENUBUTTONWEBAPP_H
+
+#include "tgbot/types/MenuButton.h"
+#include "tgbot/types/WebAppInfo.h"
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief Represents a menu button, which launches a Web App.
+ *
+ * @ingroup types
+ */
+class MenuButtonWebApp : public MenuButton {
+public:
+ static const std::string TYPE;
+
+ typedef std::shared_ptr<MenuButtonWebApp> Ptr;
+
+ MenuButtonWebApp() {
+ this->type = TYPE;
+ }
+
+ /**
+ * @brief Text on the button
+ */
+ std::string text;
+
+ /**
+ * @brief Description of the Web App that will be launched when the user presses the button.
+ * The Web App will be able to send an arbitrary message on behalf of the user using the method Api::answerWebAppQuery.
+ */
+ WebAppInfo::Ptr webApp;
+};
+}
+
+#endif //TGBOT_MENUBUTTONWEBAPP_H
diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h
index c918257..2c7915a 100644
--- a/include/tgbot/types/Message.h
+++ b/include/tgbot/types/Message.h
@@ -1,33 +1,34 @@
-#ifndef TGBOT_CPP_MESSAGE_H
-#define TGBOT_CPP_MESSAGE_H
+#ifndef TGBOT_MESSAGE_H
+#define TGBOT_MESSAGE_H
-#include "tgbot/types/Chat.h"
#include "tgbot/types/User.h"
+#include "tgbot/types/Chat.h"
#include "tgbot/types/Message.h"
+#include "tgbot/types/MessageEntity.h"
+#include "tgbot/types/Animation.h"
#include "tgbot/types/Audio.h"
#include "tgbot/types/Document.h"
-#include "tgbot/types/Animation.h"
+#include "tgbot/types/PhotoSize.h"
#include "tgbot/types/Sticker.h"
-#include "tgbot/types/Poll.h"
-#include "tgbot/types/Dice.h"
#include "tgbot/types/Video.h"
+#include "tgbot/types/VideoNote.h"
+#include "tgbot/types/Voice.h"
#include "tgbot/types/Contact.h"
-#include "tgbot/types/Location.h"
+#include "tgbot/types/Dice.h"
#include "tgbot/types/Game.h"
-#include "tgbot/types/PhotoSize.h"
-#include "tgbot/types/MessageEntity.h"
+#include "tgbot/types/Poll.h"
#include "tgbot/types/Venue.h"
-#include "tgbot/types/Voice.h"
-#include "tgbot/types/VideoNote.h"
+#include "tgbot/types/Location.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/VideoChatScheduled.h"
+#include "tgbot/types/VideoChatStarted.h"
+#include "tgbot/types/VideoChatEnded.h"
+#include "tgbot/types/VideoChatParticipantsInvited.h"
+#include "tgbot/types/WebAppData.h"
#include "tgbot/types/InlineKeyboardMarkup.h"
#include <cstdint>
@@ -333,24 +334,29 @@ public:
ProximityAlertTriggered::Ptr proximityAlertTriggered;
/**
- * @brief Optional. Service message: voice chat scheduled
+ * @brief Optional. Service message: video chat scheduled
+ */
+ VideoChatScheduled::Ptr videoChatScheduled;
+
+ /**
+ * @brief Optional. Service message: video chat started
*/
- VoiceChatScheduled::Ptr voiceChatScheduled;
+ VideoChatStarted::Ptr videoChatStarted;
/**
- * @brief Optional. Service message: voice chat started
+ * @brief Optional. Service message: video chat ended
*/
- VoiceChatStarted::Ptr voiceChatStarted;
+ VideoChatEnded::Ptr videoChatEnded;
/**
- * @brief Optional. Service message: voice chat ended
+ * @brief Optional. Service message: new participants invited to a video chat
*/
- VoiceChatEnded::Ptr voiceChatEnded;
+ VideoChatParticipantsInvited::Ptr videoChatParticipantsInvited;
/**
- * @brief Optional. Service message: new participants invited to a voice chat
+ * @brief Optional. Service message: data sent by a Web App
*/
- VoiceChatParticipantsInvited::Ptr voiceChatParticipantsInvited;
+ WebAppData::Ptr webAppData;
/**
* @brief Optional. Inline keyboard attached to the message.
@@ -360,4 +366,4 @@ public:
};
}
-#endif //TGBOT_CPP_MESSAGE_H
+#endif //TGBOT_MESSAGE_H
diff --git a/include/tgbot/types/MessageEntity.h b/include/tgbot/types/MessageEntity.h
index 6cf42f5..960e1a7 100644
--- a/include/tgbot/types/MessageEntity.h
+++ b/include/tgbot/types/MessageEntity.h
@@ -10,7 +10,8 @@
namespace TgBot {
/**
- * @brief This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.
+ * @brief This object represents one special entity in a text message.
+ * For example, hashtags, usernames, URLs, etc.
*
* @ingroup types
*/
@@ -19,10 +20,17 @@ public:
typedef std::shared_ptr<MessageEntity> Ptr;
/**
+ * @brief Enum of possible types.
+ */
+ enum class Type {
+ Mention, Hashtag, Cashtag, BotCommand, Url, Email, PhoneNumber, Bold, Italic, Underline, Strikethrough, Spoiler, Code, Pre, TextLink, TextMention, CustomEmoji
+ };
+
+ /**
* @brief Type of the entity.
- * Can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames)
+ * Currently, can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames), “custom_emoji” (for inline custom emoji stickers)
*/
- std::string type;
+ Type type;
/**
* @brief Offset in UTF-16 code units to the start of the entity
@@ -35,7 +43,7 @@ public:
std::int32_t length;
/**
- * @brief Optional. For “text_link” only, url that will be opened after user taps on the text
+ * @brief Optional. For “text_link” only, URL that will be opened after user taps on the text
*/
std::string url;
@@ -48,6 +56,12 @@ public:
* @brief Optional. For “pre” only, the programming language of the entity text
*/
std::string language;
+
+ /**
+ * @brief Optional. For “custom_emoji” only, unique identifier of the custom emoji.
+ * Use Api::getCustomEmojiStickers to get full information about the sticker
+ */
+ std::string customEmojiId;
};
}
diff --git a/include/tgbot/types/SentWebAppMessage.h b/include/tgbot/types/SentWebAppMessage.h
new file mode 100644
index 0000000..567f97b
--- /dev/null
+++ b/include/tgbot/types/SentWebAppMessage.h
@@ -0,0 +1,26 @@
+#ifndef TGBOT_SENTWEBAPPMESSAGE_H
+#define TGBOT_SENTWEBAPPMESSAGE_H
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief Contains information about an inline message sent by a Web App on behalf of a user.
+ *
+ * @ingroup types
+ */
+class SentWebAppMessage {
+public:
+ typedef std::shared_ptr<SentWebAppMessage> Ptr;
+
+ /**
+ * @brief Optional. Identifier of the sent inline message.
+ * Available only if there is an inline keyboard attached to the message.
+ */
+ std::string inlineMessageId;
+};
+}
+
+#endif //TGBOT_SENTWEBAPPMESSAGE_H
diff --git a/include/tgbot/types/Sticker.h b/include/tgbot/types/Sticker.h
index 540e157..7ec0140 100644
--- a/include/tgbot/types/Sticker.h
+++ b/include/tgbot/types/Sticker.h
@@ -1,12 +1,13 @@
-#ifndef TGBOT_CPP_STICKER_H
-#define TGBOT_CPP_STICKER_H
+#ifndef TGBOT_STICKER_H
+#define TGBOT_STICKER_H
#include "tgbot/types/PhotoSize.h"
+#include "tgbot/types/File.h"
#include "tgbot/types/MaskPosition.h"
#include <cstdint>
-#include <string>
#include <memory>
+#include <string>
namespace TgBot {
@@ -21,6 +22,13 @@ public:
typedef std::shared_ptr<Sticker> Ptr;
/**
+ * @brief Enum of possible types of a sticker.
+ */
+ enum class Type {
+ Regular, Mask, CustomEmoji
+ };
+
+ /**
* @brief Identifier for this file, which can be used to download or reuse the file
*/
std::string fileId;
@@ -32,6 +40,12 @@ public:
std::string fileUniqueId;
/**
+ * @brief Type of the sticker, currently one of “regular”, “mask”, “custom_emoji”.
+ * The type of the sticker is independent from its format, which is determined by the fields isAnimated and isVideo.
+ */
+ Type type;
+
+ /**
* @brief Sticker width
*/
std::int32_t width;
@@ -47,7 +61,12 @@ public:
bool isAnimated;
/**
- * @brief Optional. Sticker thumbnail in the .webp or .jpg format
+ * @brief True, if the sticker is a video sticker
+ */
+ bool isVideo;
+
+ /**
+ * @brief Optional. Sticker thumbnail in the .WEBP or .JPG format
*/
PhotoSize::Ptr thumb;
@@ -62,15 +81,25 @@ public:
std::string setName;
/**
+ * @brief Optional. For premium regular stickers, premium animation for the sticker
+ */
+ File::Ptr premiumAnimation;
+
+ /**
* @brief Optional. For mask stickers, the position where the mask should be placed
*/
MaskPosition::Ptr maskPosition;
/**
- * @brief Optional. File size
+ * @brief Optional. For custom emoji stickers, unique identifier of the custom emoji
+ */
+ std::string customEmojiId;
+
+ /**
+ * @brief Optional. File size in bytes
*/
std::int32_t fileSize;
};
}
-#endif //TGBOT_CPP_STICKER_H
+#endif //TGBOT_STICKER_H
diff --git a/include/tgbot/types/StickerSet.h b/include/tgbot/types/StickerSet.h
index 4009096..006b1d1 100644
--- a/include/tgbot/types/StickerSet.h
+++ b/include/tgbot/types/StickerSet.h
@@ -20,6 +20,13 @@ public:
typedef std::shared_ptr<StickerSet> Ptr;
/**
+ * @brief Enum of possible types of a sticker.
+ */
+ enum class Type {
+ Regular, Mask, CustomEmoji
+ };
+
+ /**
* @brief Sticker set name
*/
std::string name;
@@ -30,14 +37,19 @@ public:
std::string title;
/**
+ * @brief Type of stickers in the set, currently one of “regular”, “mask”, “custom_emoji”
+ */
+ Type type;
+
+ /**
* @brief True, if the sticker set contains animated stickers
*/
bool isAnimated;
/**
- * @brief True, if the sticker set contains masks
+ * @brief True, if the sticker set contains video stickers
*/
- bool containsMasks;
+ bool isVideo;
/**
* @brief List of all set stickers
@@ -45,7 +57,7 @@ public:
std::vector<Sticker::Ptr> stickers;
/**
- * @brief Optional. Sticker set thumbnail in the .WEBP or .TGS format
+ * @brief Optional. Sticker set thumbnail in the .WEBP, .TGS, or .WEBM format
*/
PhotoSize::Ptr thumb;
};
diff --git a/include/tgbot/types/User.h b/include/tgbot/types/User.h
index 629ee6c..328c0a2 100644
--- a/include/tgbot/types/User.h
+++ b/include/tgbot/types/User.h
@@ -1,5 +1,5 @@
-#ifndef TGBOT_CPP_USER_H
-#define TGBOT_CPP_USER_H
+#ifndef TGBOT_USER_H
+#define TGBOT_USER_H
#include <cstdint>
#include <string>
@@ -18,7 +18,10 @@ public:
typedef std::shared_ptr<User> Ptr;
/**
- * @brief Unique identifier for this user or bot
+ * @brief Unique identifier for this user or bot.
+ *
+ * This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it.
+ * But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
*/
std::int64_t id;
@@ -28,17 +31,17 @@ public:
bool isBot;
/**
- * @brief User‘s or bot’s first name
+ * @brief User's or bot's first name
*/
std::string firstName;
/**
- * @brief Optional. User‘s or bot’s last name
+ * @brief Optional. User's or bot's last name
*/
std::string lastName;
/**
- * @brief Optional. User‘s or bot’s username
+ * @brief Optional. User's or bot's username
*/
std::string username;
@@ -48,23 +51,33 @@ public:
std::string languageCode;
/**
+ * @brief Optional. True, if this user is a Telegram Premium user
+ */
+ bool isPremium;
+
+ /**
+ * @brief Optional. True, if this user added the bot to the attachment menu
+ */
+ bool addedToAttachmentMenu;
+
+ /**
* @brief Optional. True, if the bot can be invited to groups.
- * Returned only in @ref Api::getMe.
+ * Returned only in Api::getMe.
*/
bool canJoinGroups;
/**
* @brief Optional. True, if privacy mode is disabled for the bot.
- * Returned only in @ref Api::getMe.
+ * Returned only in Api::getMe.
*/
bool canReadAllGroupMessages;
/**
* @brief Optional. True, if the bot supports inline queries.
- * Returned only in @ref Api::getMe.
+ * Returned only in Api::getMe.
*/
bool supportsInlineQueries;
};
}
-#endif //TGBOT_CPP_USER_H
+#endif //TGBOT_USER_H
diff --git a/include/tgbot/types/Video.h b/include/tgbot/types/Video.h
index c1328b5..95590ad 100644
--- a/include/tgbot/types/Video.h
+++ b/include/tgbot/types/Video.h
@@ -1,11 +1,11 @@
-#ifndef TGBOT_CPP_VIDEO_H
-#define TGBOT_CPP_VIDEO_H
+#ifndef TGBOT_VIDEO_H
+#define TGBOT_VIDEO_H
#include "tgbot/types/PhotoSize.h"
#include <cstdint>
-#include <string>
#include <memory>
+#include <string>
namespace TgBot {
@@ -61,10 +61,13 @@ public:
std::string mimeType;
/**
- * @brief Optional. File size
+ * @brief Optional. File size in bytes.
+ *
+ * It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it.
+ * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
*/
- std::int32_t fileSize;
+ std::int64_t fileSize;
};
}
-#endif //TGBOT_CPP_VIDEO_H
+#endif //TGBOT_VIDEO_H
diff --git a/include/tgbot/types/VideoChatEnded.h b/include/tgbot/types/VideoChatEnded.h
new file mode 100644
index 0000000..48c636a
--- /dev/null
+++ b/include/tgbot/types/VideoChatEnded.h
@@ -0,0 +1,26 @@
+#ifndef TGBOT_VIDEOCHATENDED_H
+#define TGBOT_VIDEOCHATENDED_H
+
+#include <cstdint>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents a service message about a video chat ended in the chat.
+ *
+ * @ingroup types
+ */
+class VideoChatEnded {
+
+public:
+ typedef std::shared_ptr<VideoChatEnded> Ptr;
+
+ /**
+ * @brief Video chat duration in seconds
+ */
+ std::int32_t duration;
+};
+}
+
+#endif //TGBOT_VIDEOCHATENDED_H
diff --git a/include/tgbot/types/VideoChatParticipantsInvited.h b/include/tgbot/types/VideoChatParticipantsInvited.h
new file mode 100644
index 0000000..eee9aaf
--- /dev/null
+++ b/include/tgbot/types/VideoChatParticipantsInvited.h
@@ -0,0 +1,28 @@
+#ifndef TGBOT_VIDEOCHATPARTICIPANTSINVITED_H
+#define TGBOT_VIDEOCHATPARTICIPANTSINVITED_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 video chat.
+ *
+ * @ingroup types
+ */
+class VideoChatParticipantsInvited {
+
+public:
+ typedef std::shared_ptr<VideoChatParticipantsInvited> Ptr;
+
+ /**
+ * @brief New members that were invited to the video chat
+ */
+ std::vector<User::Ptr> users;
+};
+}
+
+#endif //TGBOT_VIDEOCHATPARTICIPANTSINVITED_H
diff --git a/include/tgbot/types/VideoChatScheduled.h b/include/tgbot/types/VideoChatScheduled.h
new file mode 100644
index 0000000..51223e3
--- /dev/null
+++ b/include/tgbot/types/VideoChatScheduled.h
@@ -0,0 +1,26 @@
+#ifndef TGBOT_VIDEOCHATSCHEDULED_H
+#define TGBOT_VIDEOCHATSCHEDULED_H
+
+#include <cstdint>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents a service message about a video chat scheduled in the chat.
+ *
+ * @ingroup types
+ */
+class VideoChatScheduled {
+
+public:
+ typedef std::shared_ptr<VideoChatScheduled> Ptr;
+
+ /**
+ * @brief Point in time (Unix timestamp) when the video chat is supposed to be started by a chat administrator
+ */
+ std::int32_t startDate;
+};
+}
+
+#endif //TGBOT_VIDEOCHATSCHEDULED_H
diff --git a/include/tgbot/types/VideoChatStarted.h b/include/tgbot/types/VideoChatStarted.h
new file mode 100644
index 0000000..165c0c5
--- /dev/null
+++ b/include/tgbot/types/VideoChatStarted.h
@@ -0,0 +1,21 @@
+#ifndef TGBOT_VIDEOCHATSTARTED_H
+#define TGBOT_VIDEOCHATSTARTED_H
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents a service message about a video chat started in the chat.
+ * Currently holds no information.
+ *
+ * @ingroup types
+ */
+class VideoChatStarted {
+
+public:
+ typedef std::shared_ptr<VideoChatStarted> Ptr;
+};
+}
+
+#endif //TGBOT_VIDEOCHATSTARTED_H
diff --git a/include/tgbot/types/Voice.h b/include/tgbot/types/Voice.h
index c337b0a..763ffae 100644
--- a/include/tgbot/types/Voice.h
+++ b/include/tgbot/types/Voice.h
@@ -38,9 +38,12 @@ public:
std::string mimeType;
/**
- * @brief Optional. File size
+ * @brief Optional. File size in bytes.
+ *
+ * It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it.
+ * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
*/
- std::int32_t fileSize;
+ std::int64_t fileSize;
};
}
diff --git a/include/tgbot/types/VoiceChatEnded.h b/include/tgbot/types/VoiceChatEnded.h
deleted file mode 100644
index 883f6a2..0000000
--- a/include/tgbot/types/VoiceChatEnded.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#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
deleted file mode 100644
index f96c800..0000000
--- a/include/tgbot/types/VoiceChatParticipantsInvited.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#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
deleted file mode 100644
index 8611d5f..0000000
--- a/include/tgbot/types/VoiceChatScheduled.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#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
deleted file mode 100644
index 3d4b2e6..0000000
--- a/include/tgbot/types/VoiceChatStarted.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#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/WebAppData.h b/include/tgbot/types/WebAppData.h
new file mode 100644
index 0000000..98631d9
--- /dev/null
+++ b/include/tgbot/types/WebAppData.h
@@ -0,0 +1,32 @@
+#ifndef TGBOT_WEBAPPDATA_H
+#define TGBOT_WEBAPPDATA_H
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief Contains data sent from a Web App to the bot.
+ *
+ * @ingroup types
+ */
+class WebAppData {
+public:
+ typedef std::shared_ptr<WebAppData> Ptr;
+
+ /**
+ * @brief The data.
+ * Be aware that a bad client can send arbitrary data in this field.
+ */
+ std::string data;
+
+ /**
+ * @brief Text of the webApp keyboard button, from which the Web App was opened.
+ * Be aware that a bad client can send arbitrary data in this field.
+ */
+ std::string buttonText;
+};
+}
+
+#endif //TGBOT_WEBAPPMESSAGE_H
diff --git a/include/tgbot/types/WebAppInfo.h b/include/tgbot/types/WebAppInfo.h
new file mode 100644
index 0000000..1e9d314
--- /dev/null
+++ b/include/tgbot/types/WebAppInfo.h
@@ -0,0 +1,26 @@
+#ifndef TGBOT_WEBAPPINFO_H
+#define TGBOT_WEBAPPINFO_H
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief Contains information about a Web App.
+ *
+ * @ingroup types
+ */
+class WebAppInfo {
+
+public:
+ typedef std::shared_ptr<WebAppInfo> Ptr;
+
+ /**
+ * @brief An HTTPS URL of a Web App to be opened with additional data as specified in https://core.telegram.org/bots/webapps#initializing-web-apps
+ */
+ std::string url;
+};
+}
+
+#endif //TGBOT_WEBAPPINFO_H
diff --git a/include/tgbot/types/WebhookInfo.h b/include/tgbot/types/WebhookInfo.h
index 8139edc..a375bc2 100644
--- a/include/tgbot/types/WebhookInfo.h
+++ b/include/tgbot/types/WebhookInfo.h
@@ -2,9 +2,9 @@
#define TGBOT_WEBHOOKINFO_H
#include <cstdint>
+#include <memory>
#include <string>
#include <vector>
-#include <memory>
namespace TgBot {
@@ -48,12 +48,17 @@ public:
std::string lastErrorMessage;
/**
+ * @brief Optional. Unix time of the most recent error that happened when trying to synchronize available updates with Telegram datacenters
+ */
+ std::int32_t lastSynchronizationErrorDate;
+
+ /**
* @brief Optional. Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery
*/
std::int32_t maxConnections;
/**
- * @brief Optional. A list of update types the bot is subscribed to. Defaults to all update types
+ * @brief Optional. A list of update types the bot is subscribed to. Defaults to all update types except chatMember
*/
std::vector<std::string> allowedUpdates;
};
diff --git a/src/Api.cpp b/src/Api.cpp
index c1c86d2..4107a4e 100644
--- a/src/Api.cpp
+++ b/src/Api.cpp
@@ -45,9 +45,10 @@ bool Api::setWebhook(const std::string& url,
std::int32_t maxConnection,
const StringArrayPtr& allowedUpdates,
const std::string& ipAddress,
- bool dropPendingUpdates) const {
+ bool dropPendingUpdates,
+ const std::string& secretToken) const {
vector<HttpReqArg> args;
- args.reserve(6);
+ args.reserve(7);
args.emplace_back("url", url);
if (certificate != nullptr) {
@@ -69,6 +70,9 @@ bool Api::setWebhook(const std::string& url,
if (dropPendingUpdates) {
args.emplace_back("drop_pending_updates", dropPendingUpdates);
}
+ if (!secretToken.empty()) {
+ args.emplace_back("secret_token", secretToken);
+ }
return sendRequest("setWebhook").get<bool>("", false);
}
@@ -109,9 +113,10 @@ Message::Ptr Api::sendMessage(boost::variant<std::int64_t, const std::string&> c
const std::string& parseMode,
bool disableNotification,
const std::vector<MessageEntity::Ptr>& entities,
- bool allowSendingWithoutReply) const {
+ bool allowSendingWithoutReply,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(9);
+ args.reserve(10);
args.emplace_back("chat_id", chatId);
args.emplace_back("text", text);
@@ -127,6 +132,9 @@ Message::Ptr Api::sendMessage(boost::variant<std::int64_t, const std::string&> c
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -140,24 +148,40 @@ Message::Ptr Api::sendMessage(boost::variant<std::int64_t, const std::string&> c
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendMessage", args));
}
-Message::Ptr Api::forwardMessage(std::int64_t chatId, std::int64_t fromChatId, std::int32_t messageId, bool disableNotification) const {
+Message::Ptr Api::forwardMessage(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<std::int64_t, const std::string&> fromChatId,
+ std::int32_t messageId,
+ bool disableNotification,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(4);
+ args.reserve(5);
+
args.emplace_back("chat_id", chatId);
args.emplace_back("from_chat_id", fromChatId);
- args.emplace_back("message_id", messageId);
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
+ args.emplace_back("message_id", messageId);
+
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("forwardMessage", args));
}
-MessageId::Ptr Api::copyMessage(std::int64_t chatId, std::int64_t fromChatId, std::int32_t messageId,
- const std::string& caption, const std::string& parseMode, const std::vector<MessageEntity::Ptr>& captionEntities,
- bool disableNotification, std::int32_t replyToMessageId, bool allowSendingWithoutReply,
- GenericReply::Ptr replyMarkup) const {
+MessageId::Ptr Api::copyMessage(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<std::int64_t, const std::string&> fromChatId,
+ std::int32_t messageId,
+ const std::string& caption,
+ const std::string& parseMode,
+ const std::vector<MessageEntity::Ptr>& captionEntities,
+ bool disableNotification,
+ std::int32_t replyToMessageId,
+ bool allowSendingWithoutReply,
+ GenericReply::Ptr replyMarkup,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(10);
+ args.reserve(11);
args.emplace_back("chat_id", chatId);
args.emplace_back("from_chat_id", fromChatId);
@@ -174,6 +198,9 @@ MessageId::Ptr Api::copyMessage(std::int64_t chatId, std::int64_t fromChatId, st
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -187,24 +214,25 @@ MessageId::Ptr Api::copyMessage(std::int64_t chatId, std::int64_t fromChatId, st
return _tgTypeParser.parseJsonAndGetMessageId(sendRequest("copyMessage", args));
}
-Message::Ptr Api::sendPhoto(std::int64_t chatId,
- boost::variant<InputFile::Ptr, std::string> photo,
+Message::Ptr Api::sendPhoto(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<InputFile::Ptr, const std::string&> photo,
const std::string& caption,
std::int32_t replyToMessageId,
GenericReply::Ptr replyMarkup,
const std::string& parseMode,
bool disableNotification,
const std::vector<MessageEntity::Ptr>& captionEntities,
- bool allowSendingWithoutReply) const {
+ bool allowSendingWithoutReply,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(9);
+ args.reserve(10);
args.emplace_back("chat_id", chatId);
- if (photo.which() == 0 /* InputFile::Ptr */) {
+ if (photo.which() == 0) { // InputFile::Ptr
auto file = boost::get<InputFile::Ptr>(photo);
args.emplace_back("photo", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- args.emplace_back("photo", boost::get<std::string>(photo));
+ } else { // const std::string&
+ args.emplace_back("photo", boost::get<const std::string&>(photo));
}
if (!caption.empty()) {
args.emplace_back("caption", caption);
@@ -218,6 +246,9 @@ Message::Ptr Api::sendPhoto(std::int64_t chatId,
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -231,28 +262,29 @@ Message::Ptr Api::sendPhoto(std::int64_t chatId,
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendPhoto", args));
}
-Message::Ptr Api::sendAudio(std::int64_t chatId,
- boost::variant<InputFile::Ptr, std::string> audio,
+Message::Ptr Api::sendAudio(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<InputFile::Ptr, const std::string&> audio,
const std::string& caption,
std::int32_t duration,
const std::string& performer,
const std::string& title,
- boost::variant<InputFile::Ptr, std::string> thumb,
+ boost::variant<InputFile::Ptr, const std::string&> thumb,
std::int32_t replyToMessageId,
GenericReply::Ptr replyMarkup,
const std::string& parseMode,
bool disableNotification,
const std::vector<MessageEntity::Ptr>& captionEntities,
- bool allowSendingWithoutReply) const {
+ bool allowSendingWithoutReply,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(13);
+ args.reserve(14);
args.emplace_back("chat_id", chatId);
- if (audio.which() == 0 /* InputFile::Ptr */) {
+ if (audio.which() == 0) { // InputFile::Ptr
auto file = boost::get<InputFile::Ptr>(audio);
args.emplace_back("audio", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- args.emplace_back("audio", boost::get<std::string>(audio));
+ } else { // const std::string&
+ args.emplace_back("audio", boost::get<const std::string&>(audio));
}
if (!caption.empty()) {
args.emplace_back("caption", caption);
@@ -272,11 +304,11 @@ Message::Ptr Api::sendAudio(std::int64_t chatId,
if (!title.empty()) {
args.emplace_back("title", title);
}
- if (thumb.which() == 0 /* InputFile::Ptr */) {
+ if (thumb.which() == 0) { // InputFile::Ptr
auto file = boost::get<InputFile::Ptr>(thumb);
args.emplace_back("thumb", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- auto thumbStr = boost::get<std::string>(thumb);
+ } else { // const std::string&
+ auto thumbStr = boost::get<const std::string&>(thumb);
if (!thumbStr.empty()) {
args.emplace_back("thumb", thumbStr);
}
@@ -284,6 +316,9 @@ Message::Ptr Api::sendAudio(std::int64_t chatId,
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -297,9 +332,9 @@ Message::Ptr Api::sendAudio(std::int64_t chatId,
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendAudio", args));
}
-Message::Ptr Api::sendDocument(std::int64_t chatId,
- boost::variant<InputFile::Ptr, std::string> document,
- boost::variant<InputFile::Ptr, std::string> thumb,
+Message::Ptr Api::sendDocument(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<InputFile::Ptr, const std::string&> document,
+ boost::variant<InputFile::Ptr, const std::string&> thumb,
const std::string& caption,
std::int32_t replyToMessageId,
GenericReply::Ptr replyMarkup,
@@ -307,22 +342,23 @@ Message::Ptr Api::sendDocument(std::int64_t chatId,
bool disableNotification,
const std::vector<MessageEntity::Ptr>& captionEntities,
bool disableContentTypeDetection,
- bool allowSendingWithoutReply) const {
+ bool allowSendingWithoutReply,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(11);
+ args.reserve(12);
args.emplace_back("chat_id", chatId);
- if (document.which() == 0 /* InputFile::Ptr */) {
+ if (document.which() == 0) { // InputFile::Ptr
auto file = boost::get<InputFile::Ptr>(document);
args.emplace_back("document", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- args.emplace_back("document", boost::get<std::string>(document));
+ } else { // const std::string&
+ args.emplace_back("document", boost::get<const std::string&>(document));
}
- if (thumb.which() == 0 /* InputFile::Ptr */) {
+ if (thumb.which() == 0) { // InputFile::Ptr
auto file = boost::get<InputFile::Ptr>(thumb);
args.emplace_back("thumb", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- auto thumbStr = boost::get<std::string>(thumb);
+ } else { // const std::string&
+ auto thumbStr = boost::get<const std::string&>(thumb);
if (!thumbStr.empty()) {
args.emplace_back("thumb", thumbStr);
}
@@ -342,6 +378,9 @@ Message::Ptr Api::sendDocument(std::int64_t chatId,
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -355,29 +394,30 @@ Message::Ptr Api::sendDocument(std::int64_t chatId,
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendDocument", args));
}
-Message::Ptr Api::sendVideo(std::int64_t chatId,
- boost::variant<InputFile::Ptr, std::string> video,
+Message::Ptr Api::sendVideo(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<InputFile::Ptr, const std::string&> video,
bool supportsStreaming,
std::int32_t duration,
std::int32_t width,
std::int32_t height,
- boost::variant<InputFile::Ptr, std::string> thumb,
- const std::string& caption,
+ boost::variant<InputFile::Ptr, const std::string&> thumb,
+ const std::string& caption ,
std::int32_t replyToMessageId,
GenericReply::Ptr replyMarkup,
const std::string& parseMode,
bool disableNotification,
const std::vector<MessageEntity::Ptr>& captionEntities,
- bool allowSendingWithoutReply) const {
+ bool allowSendingWithoutReply,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(14);
+ args.reserve(15);
args.emplace_back("chat_id", chatId);
- if (video.which() == 0 /* InputFile::Ptr */) {
+ if (video.which() == 0) { // InputFile::Ptr
auto file = boost::get<InputFile::Ptr>(video);
args.emplace_back("video", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- args.emplace_back("video", boost::get<std::string>(video));
+ } else { // const std::string&
+ args.emplace_back("video", boost::get<const std::string&>(video));
}
if (duration) {
args.emplace_back("duration", duration);
@@ -388,11 +428,11 @@ Message::Ptr Api::sendVideo(std::int64_t chatId,
if (height) {
args.emplace_back("height", height);
}
- if (thumb.which() == 0 /* InputFile::Ptr */) {
+ if (thumb.which() == 0) { // InputFile::Ptr
auto file = boost::get<InputFile::Ptr>(thumb);
args.emplace_back("thumb", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- auto thumbStr = boost::get<std::string>(thumb);
+ } else { // const std::string&
+ auto thumbStr = boost::get<const std::string&>(thumb);
if (!thumbStr.empty()) {
args.emplace_back("thumb", thumbStr);
}
@@ -412,6 +452,9 @@ Message::Ptr Api::sendVideo(std::int64_t chatId,
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -425,28 +468,29 @@ Message::Ptr Api::sendVideo(std::int64_t chatId,
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVideo", args));
}
-Message::Ptr Api::sendAnimation(std::int64_t chatId,
- boost::variant<InputFile::Ptr, std::string> animation,
+Message::Ptr Api::sendAnimation(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<InputFile::Ptr, const std::string&> animation,
std::int32_t duration,
std::int32_t width,
std::int32_t height,
- boost::variant<InputFile::Ptr, std::string> thumb,
+ boost::variant<InputFile::Ptr, const std::string&> thumb,
const std::string& caption,
std::int32_t replyToMessageId,
GenericReply::Ptr replyMarkup,
const std::string& parseMode,
bool disableNotification,
const std::vector<MessageEntity::Ptr>& captionEntities,
- bool allowSendingWithoutReply) const {
+ bool allowSendingWithoutReply,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(13);
+ args.reserve(14);
args.emplace_back("chat_id", chatId);
- if (animation.which() == 0 /* InputFile::Ptr */) {
+ if (animation.which() == 0) { // InputFile::Ptr
auto file = boost::get<InputFile::Ptr>(animation);
args.emplace_back("animation", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- args.emplace_back("animation", boost::get<std::string>(animation));
+ } else { // const std::string&
+ args.emplace_back("animation", boost::get<const std::string&>(animation));
}
if (duration) {
args.emplace_back("duration", duration);
@@ -457,11 +501,11 @@ Message::Ptr Api::sendAnimation(std::int64_t chatId,
if (height) {
args.emplace_back("height", height);
}
- if (thumb.which() == 0 /* InputFile::Ptr */) {
+ if (thumb.which() == 0) { // InputFile::Ptr
auto file = boost::get<InputFile::Ptr>(thumb);
args.emplace_back("thumb", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- auto thumbStr = boost::get<std::string>(thumb);
+ } else { // const std::string&
+ auto thumbStr = boost::get<const std::string&>(thumb);
if (!thumbStr.empty()) {
args.emplace_back("thumb", thumbStr);
}
@@ -478,6 +522,9 @@ Message::Ptr Api::sendAnimation(std::int64_t chatId,
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -491,8 +538,8 @@ Message::Ptr Api::sendAnimation(std::int64_t chatId,
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendAnimation", args));
}
-Message::Ptr Api::sendVoice(std::int64_t chatId,
- boost::variant<InputFile::Ptr, std::string> voice,
+Message::Ptr Api::sendVoice(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<InputFile::Ptr, const std::string&> voice,
const std::string& caption,
std::int32_t duration,
std::int32_t replyToMessageId,
@@ -500,16 +547,17 @@ Message::Ptr Api::sendVoice(std::int64_t chatId,
const std::string& parseMode,
bool disableNotification,
const std::vector<MessageEntity::Ptr>& captionEntities,
- bool allowSendingWithoutReply) const {
+ bool allowSendingWithoutReply,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(10);
+ args.reserve(11);
args.emplace_back("chat_id", chatId);
- if (voice.which() == 0 /* InputFile::Ptr */) {
+ if (voice.which() == 0) { // InputFile::Ptr
auto file = boost::get<InputFile::Ptr>(voice);
args.emplace_back("voice", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- args.emplace_back("voice", boost::get<std::string>(voice));
+ } else { // const std::string&
+ args.emplace_back("voice", boost::get<const std::string&>(voice));
}
if (!caption.empty()) {
args.emplace_back("caption", caption);
@@ -526,6 +574,9 @@ Message::Ptr Api::sendVoice(std::int64_t chatId,
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -539,24 +590,25 @@ Message::Ptr Api::sendVoice(std::int64_t chatId,
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVoice", args));
}
-Message::Ptr Api::sendVideoNote(std::int64_t chatId,
- boost::variant<InputFile::Ptr, std::string> videoNote,
+Message::Ptr Api::sendVideoNote(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<InputFile::Ptr, const std::string&> videoNote,
std::int64_t replyToMessageId,
bool disableNotification,
std::int32_t duration,
std::int32_t length,
- boost::variant<InputFile::Ptr, std::string> thumb,
+ boost::variant<InputFile::Ptr, const std::string&> thumb,
GenericReply::Ptr replyMarkup,
- bool allowSendingWithoutReply) const {
+ bool allowSendingWithoutReply,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(9);
+ args.reserve(10);
args.emplace_back("chat_id", chatId);
- if (videoNote.which() == 0 /* InputFile::Ptr */) {
+ if (videoNote.which() == 0) { // InputFile::Ptr
auto file = boost::get<InputFile::Ptr>(videoNote);
args.emplace_back("video_note", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- args.emplace_back("video_note", boost::get<std::string>(videoNote));
+ } else { // const std::string&
+ args.emplace_back("video_note", boost::get<const std::string&>(videoNote));
}
if (duration) {
args.emplace_back("duration", duration);
@@ -564,11 +616,11 @@ Message::Ptr Api::sendVideoNote(std::int64_t chatId,
if (length) {
args.emplace_back("length", length);
}
- if (thumb.which() == 0 /* InputFile::Ptr */) {
+ if (thumb.which() == 0) { // InputFile::Ptr
auto file = boost::get<InputFile::Ptr>(thumb);
args.emplace_back("thumb", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- auto thumbStr = boost::get<std::string>(thumb);
+ } else { // const std::string&
+ auto thumbStr = boost::get<const std::string&>(thumb);
if (!thumbStr.empty()) {
args.emplace_back("thumb", thumbStr);
}
@@ -576,6 +628,9 @@ Message::Ptr Api::sendVideoNote(std::int64_t chatId,
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -589,16 +644,23 @@ Message::Ptr Api::sendVideoNote(std::int64_t chatId,
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVideoNote", args));
}
-vector<Message::Ptr> Api::sendMediaGroup(std::int64_t chatId, const std::vector<InputMedia::Ptr>& media, bool disableNotification,
- std::int32_t replyToMessageId, bool allowSendingWithoutReply) const {
+vector<Message::Ptr> Api::sendMediaGroup(boost::variant<std::int64_t, const std::string&> chatId,
+ const std::vector<InputMedia::Ptr>& media,
+ bool disableNotification,
+ std::int32_t replyToMessageId,
+ bool allowSendingWithoutReply,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(5);
+ args.reserve(6);
args.emplace_back("chat_id", chatId);
args.emplace_back("media", _tgTypeParser.parseArray<InputMedia>(&TgTypeParser::parseInputMedia, media));
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId != 0) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -609,19 +671,20 @@ vector<Message::Ptr> Api::sendMediaGroup(std::int64_t chatId, const std::vector<
return _tgTypeParser.parseJsonAndGetArray<Message>(&TgTypeParser::parseJsonAndGetMessage, sendRequest("sendMediaGroup", args));
}
-Message::Ptr Api::sendLocation(std::int64_t chatId,
+Message::Ptr Api::sendLocation(boost::variant<std::int64_t, const std::string&> chatId,
float latitude,
float longitude,
- std::uint32_t livePeriod,
+ std::int32_t livePeriod,
std::int32_t replyToMessageId,
GenericReply::Ptr replyMarkup,
bool disableNotification,
float horizontalAccuracy,
- std::uint32_t heading,
- std::uint32_t proximityAlertRadius,
- bool allowSendingWithoutReply) const {
+ std::int32_t heading,
+ std::int32_t proximityAlertRadius,
+ bool allowSendingWithoutReply,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(11);
+ args.reserve(12);
args.emplace_back("chat_id", chatId);
args.emplace_back("latitude", latitude);
@@ -641,6 +704,9 @@ Message::Ptr Api::sendLocation(std::int64_t chatId,
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -711,7 +777,7 @@ Message::Ptr Api::stopMessageLiveLocation(std::int64_t chatId, std::int32_t mess
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("editMessageLiveLocation", args));
}
-Message::Ptr Api::sendVenue(std::int64_t chatId,
+Message::Ptr Api::sendVenue(boost::variant<std::int64_t, const std::string&> chatId,
float latitude,
float longitude,
const std::string& title,
@@ -723,9 +789,10 @@ Message::Ptr Api::sendVenue(std::int64_t chatId,
GenericReply::Ptr replyMarkup,
const std::string& googlePlaceId,
const std::string& googlePlaceType,
- bool allowSendingWithoutReply) const {
+ bool allowSendingWithoutReply,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(13);
+ args.reserve(14);
args.emplace_back("chat_id", chatId);
args.emplace_back("latitude", latitude);
@@ -747,6 +814,9 @@ Message::Ptr Api::sendVenue(std::int64_t chatId,
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -760,17 +830,18 @@ Message::Ptr Api::sendVenue(std::int64_t chatId,
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVenue", args));
}
-Message::Ptr Api::sendContact(std::int64_t chatId,
- const std::string& phoneNumber,
- const std::string& firstName,
- const std::string& lastName,
- const std::string& vcard,
- bool disableNotification,
- std::int32_t replyToMessageId,
- GenericReply::Ptr replyMarkup,
- bool allowSendingWithoutReply) const {
+Message::Ptr Api::sendContact(boost::variant<std::int64_t, const std::string&> chatId,
+ const std::string& phoneNumber,
+ const std::string& firstName,
+ const std::string& lastName ,
+ const std::string& vcard,
+ bool disableNotification,
+ std::int32_t replyToMessageId,
+ GenericReply::Ptr replyMarkup,
+ bool allowSendingWithoutReply,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(9);
+ args.reserve(10);
args.emplace_back("chat_id", chatId);
args.emplace_back("phone_number", phoneNumber);
@@ -784,6 +855,9 @@ Message::Ptr Api::sendContact(std::int64_t chatId,
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -797,7 +871,7 @@ Message::Ptr Api::sendContact(std::int64_t chatId,
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendContact", args));
}
-Message::Ptr Api::sendPoll(std::int64_t chatId,
+Message::Ptr Api::sendPoll(boost::variant<std::int64_t, const std::string&> chatId,
const std::string& question,
const std::vector<std::string>& options,
bool disableNotification,
@@ -813,9 +887,10 @@ Message::Ptr Api::sendPoll(std::int64_t chatId,
std::int32_t openPeriod,
std::int32_t closeDate,
bool isClosed,
- bool allowSendingWithoutReply) const {
+ bool allowSendingWithoutReply,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(17);
+ args.reserve(18);
args.emplace_back("chat_id", chatId);
args.emplace_back("question", question);
@@ -855,6 +930,9 @@ Message::Ptr Api::sendPoll(std::int64_t chatId,
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId != 0) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -868,24 +946,32 @@ Message::Ptr Api::sendPoll(std::int64_t chatId,
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendPoll", args));
}
-Message::Ptr Api::sendDice(std::int64_t chatId,
+Message::Ptr Api::sendDice(boost::variant<std::int64_t, const std::string&> chatId,
bool disableNotification,
std::int32_t replyToMessageId,
GenericReply::Ptr replyMarkup,
const std::string& emoji,
- bool allowSendingWithoutReply) const {
+ bool allowSendingWithoutReply,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(6);
+ args.reserve(7);
args.emplace_back("chat_id", chatId);
if (!emoji.empty()) {
args.emplace_back("emoji", emoji);
}
- args.emplace_back("disable_notification", disableNotification);
+ if (disableNotification) {
+ args.emplace_back("disable_notification", disableNotification);
+ }
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId != 0) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
- args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ if (allowSendingWithoutReply) {
+ args.emplace_back("allow_sending_without_reply", allowSendingWithoutReply);
+ }
if (replyMarkup) {
args.emplace_back("reply_markup", _tgTypeParser.parseGenericReply(replyMarkup));
}
@@ -975,7 +1061,7 @@ 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,
+bool Api::promoteChatMember(boost::variant<std::int64_t, const std::string&> chatId,
std::int64_t userId,
bool canChangeInfo,
bool canPostMessages,
@@ -986,7 +1072,7 @@ bool Api::promoteChatMember(std::int64_t chatId,
bool canPromoteMembers,
bool isAnonymous,
bool canManageChat,
- bool canManageVoiceChats,
+ bool canManageVideoChats,
bool canRestrictMembers) const {
vector<HttpReqArg> args;
args.reserve(13);
@@ -1008,8 +1094,8 @@ bool Api::promoteChatMember(std::int64_t chatId,
if (canDeleteMessages) {
args.emplace_back("can_delete_messages", canDeleteMessages);
}
- if (canManageVoiceChats) {
- args.emplace_back("can_manage_voice_chats", canManageVoiceChats);
+ if (canManageVideoChats) {
+ args.emplace_back("can_manage_video_chats", canManageVideoChats);
}
if (canRestrictMembers) {
args.emplace_back("can_restrict_members", canRestrictMembers);
@@ -1104,7 +1190,7 @@ ChatInviteLink::Ptr Api::createChatInviteLink(std::int64_t chatId,
}
ChatInviteLink::Ptr Api::editChatInviteLink(std::int64_t chatId,
- std::string inviteLink,
+ const std::string& inviteLink,
std::int32_t expireDate,
std::int32_t memberLimit,
const std::string& name,
@@ -1131,7 +1217,7 @@ ChatInviteLink::Ptr Api::editChatInviteLink(std::int64_t chatId,
}
ChatInviteLink::Ptr Api::revokeChatInviteLink(std::int64_t chatId,
- std::string inviteLink) const {
+ const std::string& inviteLink) const {
vector<HttpReqArg> args;
args.reserve(2);
@@ -1345,6 +1431,58 @@ std::vector<BotCommand::Ptr> Api::getMyCommands(BotCommandScope::Ptr scope,
return _tgTypeParser.parseJsonAndGetArray<BotCommand>(&TgTypeParser::parseJsonAndGetBotCommand, sendRequest("getMyCommands", args));
}
+bool Api::setChatMenuButton(std::int64_t chatId,
+ MenuButton::Ptr menuButton) const {
+ vector<HttpReqArg> args;
+ args.reserve(2);
+
+ if (chatId != 0) {
+ args.emplace_back("chat_id", chatId);
+ }
+ if (menuButton != nullptr) {
+ args.emplace_back("menu_button", _tgTypeParser.parseMenuButton(menuButton));
+ }
+
+ return sendRequest("setChatMenuButton", args).get<bool>("", false);
+}
+
+MenuButton::Ptr Api::getChatMenuButton(std::int64_t chatId) const {
+ vector<HttpReqArg> args;
+ args.reserve(1);
+
+ if (chatId != 0) {
+ args.emplace_back("chat_id", chatId);
+ }
+
+ return _tgTypeParser.parseJsonAndGetMenuButton(sendRequest("getChatMenuButton", args));
+}
+
+bool Api::setMyDefaultAdministratorRights(ChatAdministratorRights::Ptr rights,
+ bool forChannels) const {
+ vector<HttpReqArg> args;
+ args.reserve(2);
+
+ if (rights != nullptr) {
+ args.emplace_back("rights", _tgTypeParser.parseChatAdministratorRights(rights));
+ }
+ if (forChannels) {
+ args.emplace_back("for_channels", forChannels);
+ }
+
+ return sendRequest("setMyDefaultAdministratorRights", args).get<bool>("", false);
+}
+
+ChatAdministratorRights::Ptr Api::getMyDefaultAdministratorRights(bool forChannels) const {
+ vector<HttpReqArg> args;
+ args.reserve(1);
+
+ if (forChannels) {
+ args.emplace_back("for_channels", forChannels);
+ }
+
+ return _tgTypeParser.parseJsonAndGetChatAdministratorRights(sendRequest("getMyDefaultAdministratorRights", args));
+}
+
Message::Ptr Api::editMessageText(const std::string& text,
std::int64_t chatId,
std::int32_t messageId,
@@ -1493,25 +1631,29 @@ void Api::deleteMessage(std::int64_t chatId, std::int32_t messageId) const {
sendRequest("deleteMessage", { HttpReqArg("chat_id", chatId), HttpReqArg("message_id", messageId) });
}
-Message::Ptr Api::sendSticker(std::int64_t chatId,
- boost::variant<InputFile::Ptr, std::string> sticker,
+Message::Ptr Api::sendSticker(boost::variant<std::int64_t, const std::string&> chatId,
+ boost::variant<InputFile::Ptr, const std::string&> sticker,
std::int32_t replyToMessageId,
GenericReply::Ptr replyMarkup,
bool disableNotification,
- bool allowSendingWithoutReply) const {
+ bool allowSendingWithoutReply,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(6);
+ args.reserve(7);
args.emplace_back("chat_id", chatId);
- if (sticker.which() == 0 /* InputFile::Ptr */) {
+ if (sticker.which() == 0) { // InputFile::Ptr
auto file = boost::get<InputFile::Ptr>(sticker);
args.emplace_back("sticker", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- args.emplace_back("sticker", boost::get<std::string>(sticker));
+ } else { // const std::string&
+ args.emplace_back("sticker", boost::get<const std::string&>(sticker));
}
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -1534,6 +1676,17 @@ StickerSet::Ptr Api::getStickerSet(const string& name) const {
return _tgTypeParser.parseJsonAndGetStickerSet(sendRequest("getStickerSet", args));
}
+std::vector<Sticker::Ptr> Api::getCustomEmojiStickers(const std::vector<std::string>& customEmojiIds) const {
+ vector<HttpReqArg> args;
+ args.reserve(1);
+
+ args.emplace_back("custom_emoji_ids", _tgTypeParser.parseArray<std::string>([] (const std::string& customEmojiId) -> std::string {
+ return "\"" + StringTools::urlEncode(customEmojiId) + "\"";
+ }, customEmojiIds));
+
+ return _tgTypeParser.parseJsonAndGetArray<Sticker>(&TgTypeParser::parseJsonAndGetSticker, sendRequest("getCustomEmojiStickers", args));
+}
+
File::Ptr Api::uploadStickerFile(std::int64_t userId, const InputFile::Ptr pngSticker) const {
vector<HttpReqArg> args;
args.reserve(2);
@@ -1546,32 +1699,33 @@ 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 {
+ boost::variant<InputFile::Ptr, const std::string&> pngSticker,
+ InputFile::Ptr tgsSticker,
+ InputFile::Ptr webmSticker,
+ const std::string& stickerType) const {
vector<HttpReqArg> args;
- args.reserve(8);
+ args.reserve(10);
args.emplace_back("user_id", userId);
args.emplace_back("name", name);
args.emplace_back("title", title);
- args.emplace_back("emojis", emojis);
- if (pngSticker.which() == 0 /* InputFile::Ptr */) {
+ if (pngSticker.which() == 0) { // InputFile::Ptr
auto file = boost::get<InputFile::Ptr>(pngSticker);
args.emplace_back("png_sticker", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- args.emplace_back("png_sticker", boost::get<std::string>(pngSticker));
+ } else { // const std::string&
+ args.emplace_back("png_sticker", boost::get<const std::string&>(pngSticker));
}
- if (tgsSticker.which() == 0 /* InputFile::Ptr */) {
- auto file = boost::get<InputFile::Ptr>(tgsSticker);
- args.emplace_back("tgs_sticker", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- args.emplace_back("tgs_sticker", boost::get<std::string>(tgsSticker));
+ if (tgsSticker != nullptr) {
+ args.emplace_back("tgs_sticker", tgsSticker->data, true, tgsSticker->mimeType, tgsSticker->fileName);
}
- if (containsMasks) {
- args.emplace_back("contains_mask", containsMasks);
+ if (webmSticker != nullptr) {
+ args.emplace_back("webm_sticker", webmSticker->data, true, webmSticker->mimeType, webmSticker->fileName);
}
+ if (!stickerType.empty()) {
+ args.emplace_back("sticker_type", stickerType);
+ }
+ args.emplace_back("emojis", emojis);
if (maskPosition != nullptr) {
args.emplace_back("mask_position", _tgTypeParser.parseMaskPosition(maskPosition));
}
@@ -1580,29 +1734,31 @@ bool Api::createNewStickerSet(std::int64_t userId,
}
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 {
+ const std::string& name,
+ const std::string& emojis,
+ MaskPosition::Ptr maskPosition,
+ boost::variant<InputFile::Ptr, const std::string&> pngSticker,
+ InputFile::Ptr tgsSticker,
+ InputFile::Ptr webmSticker) const {
vector<HttpReqArg> args;
- args.reserve(6);
+ args.reserve(7);
args.emplace_back("user_id", userId);
args.emplace_back("name", name);
- args.emplace_back("emojis", emojis);
- if (pngSticker.which() == 0 /* InputFile::Ptr */) {
+
+ if (pngSticker.which() == 0) { // InputFile::Ptr
auto file = boost::get<InputFile::Ptr>(pngSticker);
args.emplace_back("png_sticker", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- args.emplace_back("png_sticker", boost::get<std::string>(pngSticker));
+ } else { // const std::string&
+ args.emplace_back("png_sticker", boost::get<const std::string&>(pngSticker));
}
- if (tgsSticker.which() == 0 /* InputFile::Ptr */) {
- auto file = boost::get<InputFile::Ptr>(tgsSticker);
- args.emplace_back("tgs_sticker", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- args.emplace_back("tgs_sticker", boost::get<std::string>(tgsSticker));
+ if (tgsSticker != nullptr) {
+ args.emplace_back("tgs_sticker", tgsSticker->data, true, tgsSticker->mimeType, tgsSticker->fileName);
+ }
+ if (webmSticker != nullptr) {
+ args.emplace_back("webm_sticker", webmSticker->data, true, webmSticker->mimeType, webmSticker->fileName);
}
+ args.emplace_back("emojis", emojis);
if (maskPosition != nullptr) {
args.emplace_back("mask_position", _tgTypeParser.parseMaskPosition(maskPosition));
}
@@ -1666,7 +1822,18 @@ 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,
+SentWebAppMessage::Ptr Api::answerWebAppQuery(const std::string& webAppQueryId,
+ InlineQueryResult::Ptr result) const {
+ vector<HttpReqArg> args;
+ args.reserve(2);
+
+ args.emplace_back("web_app_query_id", webAppQueryId);
+ args.emplace_back("result", _tgTypeParser.parseInlineQueryResult(result));
+
+ return _tgTypeParser.parseJsonAndGetSentWebAppMessage(sendRequest("answerWebAppQuery", args));
+}
+
+Message::Ptr Api::sendInvoice(boost::variant<std::int64_t, const std::string&> chatId,
const std::string& title,
const std::string& description,
const std::string& payload,
@@ -1691,9 +1858,10 @@ Message::Ptr Api::sendInvoice(std::int64_t chatId,
bool allowSendingWithoutReply,
std::int32_t maxTipAmount,
const std::vector<std::int32_t>& suggestedTipAmounts,
- const std::string& startParameter) const {
+ const std::string& startParameter,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(26);
+ args.reserve(27);
args.emplace_back("chat_id", chatId);
args.emplace_back("title", title);
@@ -1750,6 +1918,9 @@ Message::Ptr Api::sendInvoice(std::int64_t chatId,
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
@@ -1763,6 +1934,81 @@ Message::Ptr Api::sendInvoice(std::int64_t chatId,
return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendInvoice", args));
}
+std::string Api::createInvoiceLink(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,
+ std::int32_t maxTipAmount,
+ const std::vector<std::int32_t>& suggestedTipAmounts,
+ 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) const {
+ vector<HttpReqArg> args;
+ args.reserve(20);
+
+ args.emplace_back("title", title);
+ args.emplace_back("description", description);
+ args.emplace_back("payload", payload);
+ args.emplace_back("provider_token", providerToken);
+ 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 (!providerData.empty()) {
+ args.emplace_back("provider_data", providerData);
+ }
+ if (!photoUrl.empty()) {
+ args.emplace_back("photo_url", photoUrl);
+ }
+ if (photoSize) {
+ args.emplace_back("photo_size", photoSize);
+ }
+ if (photoWidth) {
+ args.emplace_back("photo_width", photoWidth);
+ }
+ if (photoHeight) {
+ args.emplace_back("photo_height", photoHeight);
+ }
+ if (needName) {
+ args.emplace_back("need_name", needName);
+ }
+ if (needPhoneNumber) {
+ args.emplace_back("need_phone_number", needPhoneNumber);
+ }
+ if (needEmail) {
+ args.emplace_back("need_email", needEmail);
+ }
+ if (needShippingAddress) {
+ args.emplace_back("need_shipping_address", needShippingAddress);
+ }
+ if (sendPhoneNumberToProvider) {
+ args.emplace_back("send_phone_number_to_provider", sendPhoneNumberToProvider);
+ }
+ if (sendEmailToProvider) {
+ args.emplace_back("send_email_to_provider", sendEmailToProvider);
+ }
+ if (isFlexible) {
+ args.emplace_back("is_flexible", isFlexible);
+ }
+
+ return sendRequest("createInvoiceLink", args).get<std::string>("", "");
+}
+
bool Api::answerShippingQuery(const std::string& shippingQueryId, bool ok, const std::vector<ShippingOption::Ptr>& shippingOptions, const std::string& errorMessage) const {
vector<HttpReqArg> args;
args.reserve(4);
@@ -1803,15 +2049,19 @@ Message::Ptr Api::sendGame(std::int64_t chatId,
std::int32_t replyToMessageId,
InlineKeyboardMarkup::Ptr replyMarkup,
bool disableNotification,
- bool allowSendingWithoutReply) const {
+ bool allowSendingWithoutReply,
+ bool protectContent) const {
vector<HttpReqArg> args;
- args.reserve(6);
+ args.reserve(7);
args.emplace_back("chat_id", chatId);
args.emplace_back("game_short_name", gameShortName);
if (disableNotification) {
args.emplace_back("disable_notification", disableNotification);
}
+ if (protectContent) {
+ args.emplace_back("protect_content", protectContent);
+ }
if (replyToMessageId) {
args.emplace_back("reply_to_message_id", replyToMessageId);
}
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp
index e8a81d7..d251da6 100644
--- a/src/TgTypeParser.cpp
+++ b/src/TgTypeParser.cpp
@@ -25,6 +25,9 @@ Chat::Ptr TgTypeParser::parseJsonAndGetChat(const boost::property_tree::ptree& d
result->photo = tryParseJson<ChatPhoto>(&TgTypeParser::parseJsonAndGetChatPhoto, data, "photo");
result->bio = data.get<std::string>("bio", "");
result->hasPrivateForwards = data.get<bool>("has_private_forwards", false);
+ result->hasRestrictedVoiceAndVideoMessages = data.get<bool>("has_restricted_voice_and_video_messages", false);
+ result->joinToSendMessages = data.get<bool>("join_to_send_messages", false);
+ result->joinByRequest = data.get<bool>("join_by_request", 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");
@@ -62,6 +65,9 @@ std::string TgTypeParser::parseChat(const Chat::Ptr& object) const {
appendToJson(result, "photo", parseChatPhoto(object->photo));
appendToJson(result, "bio", object->bio);
appendToJson(result, "has_private_forwards", object->hasPrivateForwards);
+ appendToJson(result, "has_restricted_voice_and_video_messages", object->hasRestrictedVoiceAndVideoMessages);
+ appendToJson(result, "join_to_send_messages", object->joinToSendMessages);
+ appendToJson(result, "join_by_request", object->joinByRequest);
appendToJson(result, "description", object->description);
appendToJson(result, "invite_link", object->inviteLink);
appendToJson(result, "pinned_message", parseMessage(object->pinnedMessage));
@@ -86,6 +92,8 @@ User::Ptr TgTypeParser::parseJsonAndGetUser(const boost::property_tree::ptree& d
result->lastName = data.get<std::string>("last_name", "");
result->username = data.get<std::string>("username", "");
result->languageCode = data.get<std::string>("language_code", "");
+ result->isPremium = data.get<bool>("is_premium", false);
+ result->addedToAttachmentMenu = data.get<bool>("added_to_attachment_menu", false);
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);
@@ -104,6 +112,8 @@ std::string TgTypeParser::parseUser(const User::Ptr& object) const {
appendToJson(result, "last_name", object->lastName);
appendToJson(result, "username", object->username);
appendToJson(result, "language_code", object->languageCode);
+ appendToJson(result, "is_premium", object->isPremium);
+ appendToJson(result, "added_to_attachment_menu", object->addedToAttachmentMenu);
appendToJson(result, "can_join_groups", object->canJoinGroups);
appendToJson(result, "can_read_all_group_messages", object->canReadAllGroupMessages);
appendToJson(result, "supports_inline_queries", object->supportsInlineQueries);
@@ -114,12 +124,48 @@ std::string TgTypeParser::parseUser(const User::Ptr& object) const {
MessageEntity::Ptr TgTypeParser::parseJsonAndGetMessageEntity(const boost::property_tree::ptree& data) const{
auto result(std::make_shared<MessageEntity>());
- result->type = data.get<std::string>("type", "");
+ std::string type = data.get<std::string>("type", "");
+ if (type == "mention") {
+ result->type = MessageEntity::Type::Mention;
+ } else if (type == "hashtag") {
+ result->type = MessageEntity::Type::Hashtag;
+ } else if (type == "cashtag") {
+ result->type = MessageEntity::Type::Cashtag;
+ } else if (type == "bot_command") {
+ result->type = MessageEntity::Type::BotCommand;
+ } else if (type == "url") {
+ result->type = MessageEntity::Type::Url;
+ } else if (type == "email") {
+ result->type = MessageEntity::Type::Email;
+ } else if (type == "phone_number") {
+ result->type = MessageEntity::Type::PhoneNumber;
+ } else if (type == "bold") {
+ result->type = MessageEntity::Type::Bold;
+ } else if (type == "italic") {
+ result->type = MessageEntity::Type::Italic;
+ } else if (type == "underline") {
+ result->type = MessageEntity::Type::Underline;
+ } else if (type == "strikethrough") {
+ result->type = MessageEntity::Type::Strikethrough;
+ } else if (type == "spoiler") {
+ result->type = MessageEntity::Type::Spoiler;
+ } else if (type == "code") {
+ result->type = MessageEntity::Type::Code;
+ } else if (type == "pre") {
+ result->type = MessageEntity::Type::Pre;
+ } else if (type == "text_link") {
+ result->type = MessageEntity::Type::TextLink;
+ } else if (type == "text_mention") {
+ result->type = MessageEntity::Type::TextMention;
+ } else if (type == "custom_emoji") {
+ result->type = MessageEntity::Type::CustomEmoji;
+ }
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<std::string>("language", "");
+ result->customEmojiId = data.get<std::string>("custom_emoji_id", "");
return result;
}
@@ -129,12 +175,47 @@ std::string TgTypeParser::parseMessageEntity(const MessageEntity::Ptr& object) c
}
std::string result;
result += '{';
- appendToJson(result, "type", object->type);
+ if (object->type == MessageEntity::Type::Mention) {
+ appendToJson(result, "type", "mention");
+ } else if (object->type == MessageEntity::Type::Hashtag) {
+ appendToJson(result, "type", "hashtag");
+ } else if (object->type == MessageEntity::Type::Cashtag) {
+ appendToJson(result, "type", "cashtag");
+ } else if (object->type == MessageEntity::Type::BotCommand) {
+ appendToJson(result, "type", "bot_command");
+ } else if (object->type == MessageEntity::Type::Url) {
+ appendToJson(result, "type", "url");
+ } else if (object->type == MessageEntity::Type::Email) {
+ appendToJson(result, "type", "email");
+ } else if (object->type == MessageEntity::Type::PhoneNumber) {
+ appendToJson(result, "type", "phone_number");
+ } else if (object->type == MessageEntity::Type::Bold) {
+ appendToJson(result, "type", "bold");
+ } else if (object->type == MessageEntity::Type::Italic) {
+ appendToJson(result, "type", "italic");
+ } else if (object->type == MessageEntity::Type::Underline) {
+ appendToJson(result, "type", "underline");
+ } else if (object->type == MessageEntity::Type::Strikethrough) {
+ appendToJson(result, "type", "strikethrough");
+ } else if (object->type == MessageEntity::Type::Spoiler) {
+ appendToJson(result, "type", "spoiler");
+ } else if (object->type == MessageEntity::Type::Code) {
+ appendToJson(result, "type", "code");
+ } else if (object->type == MessageEntity::Type::Pre) {
+ appendToJson(result, "type", "pre");
+ } else if (object->type == MessageEntity::Type::TextLink) {
+ appendToJson(result, "type", "text_link");
+ } else if (object->type == MessageEntity::Type::TextMention) {
+ appendToJson(result, "type", "text_mention");
+ } else if (object->type == MessageEntity::Type::CustomEmoji) {
+ appendToJson(result, "type", "custom_emoji");
+ }
appendToJson(result, "offset", object->offset);
appendToJson(result, "length", object->length);
appendToJson(result, "url", object->url);
appendToJson(result, "user", parseUser(object->user));
- appendToJson(result, "language", object->url);
+ appendToJson(result, "language", object->language);
+ appendToJson(result, "custom_emoji_id", object->customEmojiId);
removeLastComma(result);
result += '}';
return result;
@@ -196,10 +277,11 @@ Message::Ptr TgTypeParser::parseJsonAndGetMessage(const boost::property_tree::pt
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->videoChatScheduled = tryParseJson<VideoChatScheduled>(&TgTypeParser::parseJsonAndGetVideoChatScheduled, data, "video_chat_scheduled");
+ result->videoChatStarted = tryParseJson<VideoChatStarted>(&TgTypeParser::parseJsonAndGetVideoChatStarted, data, "video_chat_started");
+ result->videoChatEnded = tryParseJson<VideoChatEnded>(&TgTypeParser::parseJsonAndGetVideoChatEnded, data, "video_chat_ended");
+ result->videoChatParticipantsInvited = tryParseJson<VideoChatParticipantsInvited>(&TgTypeParser::parseJsonAndGetVideoChatParticipantsInvited, data, "video_chat_participants_invited");
+ result->webAppData = tryParseJson<WebAppData>(&TgTypeParser::parseJsonAndGetWebAppData, data, "web_app_data");
result->replyMarkup = tryParseJson<InlineKeyboardMarkup>(&TgTypeParser::parseJsonAndGetInlineKeyboardMarkup, data, "reply_markup");
return result;
}
@@ -263,10 +345,11 @@ std::string TgTypeParser::parseMessage(const Message::Ptr& object) const {
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, "video_chat_scheduled", parseVideoChatScheduled(object->videoChatScheduled));
+ appendToJson(result, "video_chat_started", parseVideoChatStarted(object->videoChatStarted));
+ appendToJson(result, "video_chat_ended", parseVideoChatEnded(object->videoChatEnded));
+ appendToJson(result, "video_chat_participants_invited", parseVideoChatParticipantsInvited(object->videoChatParticipantsInvited));
+ appendToJson(result, "web_app_data", parseWebAppData(object->webAppData));
appendToJson(result, "reply_markup", parseInlineKeyboardMarkup(object->replyMarkup));
removeLastComma(result);
result += '}';
@@ -326,7 +409,7 @@ Audio::Ptr TgTypeParser::parseJsonAndGetAudio(const boost::property_tree::ptree&
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->fileSize = data.get<std::int64_t>("file_size", 0);
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
return result;
}
@@ -358,7 +441,7 @@ Document::Ptr TgTypeParser::parseJsonAndGetDocument(const boost::property_tree::
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
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->fileSize = data.get<std::int64_t>("file_size", 0);
return result;
}
@@ -383,13 +466,24 @@ Sticker::Ptr TgTypeParser::parseJsonAndGetSticker(const boost::property_tree::pt
auto result(std::make_shared<Sticker>());
result->fileId = data.get<std::string>("file_id", "");
result->fileUniqueId = data.get<std::string>("file_unique_id", "");
+ std::string type = data.get<std::string>("type", "");
+ if (type == "regular") {
+ result->type = Sticker::Type::Regular;
+ } else if (type == "mask") {
+ result->type = Sticker::Type::Mask;
+ } else if (type == "custom_emoji") {
+ result->type = Sticker::Type::CustomEmoji;
+ }
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->isVideo = data.get<bool>("is_video", false);
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
result->emoji = data.get<std::string>("emoji", "");
result->setName = data.get<std::string>("set_name", "");
+ result->premiumAnimation = tryParseJson<File>(&TgTypeParser::parseJsonAndGetFile, data, "premium_animation");
result->maskPosition = tryParseJson<MaskPosition>(&TgTypeParser::parseJsonAndGetMaskPosition, data, "mask_position");
+ result->customEmojiId = data.get<std::string>("custom_emoji_id", "");
result->fileSize = data.get<std::int32_t>("file_size", 0);
return result;
}
@@ -402,13 +496,23 @@ std::string TgTypeParser::parseSticker(const Sticker::Ptr& object) const {
result += '{';
appendToJson(result, "file_id", object->fileId);
appendToJson(result, "file_unique_id", object->fileUniqueId);
+ if (object->type == Sticker::Type::Regular) {
+ appendToJson(result, "type", "regular");
+ } else if (object->type == Sticker::Type::Mask) {
+ appendToJson(result, "type", "mask");
+ } else if (object->type == Sticker::Type::CustomEmoji) {
+ appendToJson(result, "type", "custom_emoji");
+ }
appendToJson(result, "width", object->width);
appendToJson(result, "height", object->height);
appendToJson(result, "is_animated", object->isAnimated);
+ appendToJson(result, "is_video", object->isVideo);
appendToJson(result, "thumb", parsePhotoSize(object->thumb));
appendToJson(result, "emoji", object->emoji);
appendToJson(result, "set_name", object->setName);
+ appendToJson(result, "premium_animation", parseFile(object->premiumAnimation));
appendToJson(result, "mask_position", parseMaskPosition(object->maskPosition));
+ appendToJson(result, "custom_emoji_id", object->customEmojiId);
appendToJson(result, "file_size", object->fileSize);
removeLastComma(result);
result += '}';
@@ -419,8 +523,16 @@ StickerSet::Ptr TgTypeParser::parseJsonAndGetStickerSet(const boost::property_tr
auto result(std::make_shared<StickerSet>());
result->name = data.get<std::string>("name", "");
result->title = data.get<std::string>("title", "");
+ std::string type = data.get<std::string>("type", "");
+ if (type == "regular") {
+ result->type = StickerSet::Type::Regular;
+ } else if (type == "mask") {
+ result->type = StickerSet::Type::Mask;
+ } else if (type == "custom_emoji") {
+ result->type = StickerSet::Type::CustomEmoji;
+ }
result->isAnimated = data.get<bool>("is_animated", false);
- result->containsMasks = data.get<bool>("contains_masks", false);
+ result->isVideo = data.get<bool>("is_video", false);
result->stickers = parseJsonAndGetArray<Sticker>(&TgTypeParser::parseJsonAndGetSticker, data, "stickers");
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
return result;
@@ -434,8 +546,15 @@ std::string TgTypeParser::parseStickerSet(const StickerSet::Ptr& object) const {
result += '{';
appendToJson(result, "name", object->name);
appendToJson(result, "title", object->title);
+ if (object->type == StickerSet::Type::Regular) {
+ appendToJson(result, "type", "regular");
+ } else if (object->type == StickerSet::Type::Mask) {
+ appendToJson(result, "type", "mask");
+ } else if (object->type == StickerSet::Type::CustomEmoji) {
+ appendToJson(result, "type", "custom_emoji");
+ }
appendToJson(result, "is_animated", object->isAnimated);
- appendToJson(result, "contains_masks", object->containsMasks);
+ appendToJson(result, "is_video", object->isVideo);
appendToJson(result, "stickers", parseArray(&TgTypeParser::parseSticker, object->stickers));
appendToJson(result, "thumb", parsePhotoSize(object->thumb));
removeLastComma(result);
@@ -637,7 +756,7 @@ Video::Ptr TgTypeParser::parseJsonAndGetVideo(const boost::property_tree::ptree&
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
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->fileSize = data.get<std::int64_t>("file_size", 0);
return result;
}
@@ -667,7 +786,7 @@ Voice::Ptr TgTypeParser::parseJsonAndGetVoice(const boost::property_tree::ptree&
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);
+ result->fileSize = data.get<std::int64_t>("file_size", 0);
return result;
}
@@ -743,6 +862,21 @@ std::string TgTypeParser::parseGame(const Game::Ptr& object) const {
return result;
}
+CallbackGame::Ptr TgTypeParser::parseJsonAndGetCallbackGame(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<CallbackGame>());
+ return result;
+}
+
+std::string TgTypeParser::parseCallbackGame(const CallbackGame::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ result += '}';
+ return result;
+}
+
GameHighScore::Ptr TgTypeParser::parseJsonAndGetGameHighScore(const boost::property_tree::ptree& data) const {
auto result(std::make_shared<GameHighScore>());
result->position = data.get("position", "");
@@ -775,7 +909,7 @@ Animation::Ptr TgTypeParser::parseJsonAndGetAnimation(const boost::property_tree
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
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->fileSize = data.get<std::int64_t>("file_size", 0);
return result;
}
@@ -883,6 +1017,26 @@ std::string TgTypeParser::parseVenue(const Venue::Ptr& object) const {
return result;
}
+WebAppData::Ptr TgTypeParser::parseJsonAndGetWebAppData(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<WebAppData>());
+ result->data = data.get<std::string>("data", "");
+ result->buttonText = data.get<std::string>("button_text", "");
+ return result;
+}
+
+std::string TgTypeParser::parseWebAppData(const WebAppData::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "data", object->data);
+ appendToJson(result, "button_text", object->buttonText);
+ 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");
@@ -923,13 +1077,13 @@ std::string TgTypeParser::parseMessageAutoDeleteTimerChanged(const MessageAutoDe
return result;
}
-VoiceChatScheduled::Ptr TgTypeParser::parseJsonAndGetVoiceChatScheduled(const boost::property_tree::ptree& data) const {
- auto result(std::make_shared<VoiceChatScheduled>());
+VideoChatScheduled::Ptr TgTypeParser::parseJsonAndGetVideoChatScheduled(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<VideoChatScheduled>());
result->startDate = data.get<std::int32_t>("start_date", 0);
return result;
}
-std::string TgTypeParser::parseVoiceChatScheduled(const VoiceChatScheduled::Ptr& object) const {
+std::string TgTypeParser::parseVideoChatScheduled(const VideoChatScheduled::Ptr& object) const {
if (!object) {
return "";
}
@@ -941,25 +1095,28 @@ std::string TgTypeParser::parseVoiceChatScheduled(const VoiceChatScheduled::Ptr&
return result;
}
-VoiceChatStarted::Ptr TgTypeParser::parseJsonAndGetVoiceChatStarted(const boost::property_tree::ptree& data) const {
- auto result(std::make_shared<VoiceChatStarted>());
+VideoChatStarted::Ptr TgTypeParser::parseJsonAndGetVideoChatStarted(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<VideoChatStarted>());
return result;
}
-std::string TgTypeParser::parseVoiceChatStarted(const VoiceChatStarted::Ptr& object) const {
+std::string TgTypeParser::parseVideoChatStarted(const VideoChatStarted::Ptr& object) const {
if (!object) {
return "";
}
- return "{}";
+ std::string result;
+ result += '{';
+ result += '}';
+ return result;
}
-VoiceChatEnded::Ptr TgTypeParser::parseJsonAndGetVoiceChatEnded(const boost::property_tree::ptree& data) const {
- auto result(std::make_shared<VoiceChatEnded>());
+VideoChatEnded::Ptr TgTypeParser::parseJsonAndGetVideoChatEnded(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<VideoChatEnded>());
result->duration = data.get<std::int32_t>("duration", 0);
return result;
}
-std::string TgTypeParser::parseVoiceChatEnded(const VoiceChatEnded::Ptr& object) const {
+std::string TgTypeParser::parseVideoChatEnded(const VideoChatEnded::Ptr& object) const {
if (!object) {
return "";
}
@@ -971,13 +1128,13 @@ std::string TgTypeParser::parseVoiceChatEnded(const VoiceChatEnded::Ptr& object)
return result;
}
-VoiceChatParticipantsInvited::Ptr TgTypeParser::parseJsonAndGetVoiceChatParticipantsInvited(const boost::property_tree::ptree& data) const {
- auto result(std::make_shared<VoiceChatParticipantsInvited>());
+VideoChatParticipantsInvited::Ptr TgTypeParser::parseJsonAndGetVideoChatParticipantsInvited(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<VideoChatParticipantsInvited>());
result->users = parseJsonAndGetArray<User>(&TgTypeParser::parseJsonAndGetUser, data, "users");
return result;
}
-std::string TgTypeParser::parseVoiceChatParticipantsInvited(const VoiceChatParticipantsInvited::Ptr& object) const {
+std::string TgTypeParser::parseVideoChatParticipantsInvited(const VideoChatParticipantsInvited::Ptr& object) const {
if (!object) {
return "";
}
@@ -1230,7 +1387,7 @@ File::Ptr TgTypeParser::parseJsonAndGetFile(const boost::property_tree::ptree& d
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->fileSize = data.get<std::int64_t>("file_size", 0);
result->filePath = data.get<std::string>("file_path", "");
return result;
}
@@ -1250,6 +1407,24 @@ std::string TgTypeParser::parseFile(const File::Ptr& object) const {
return result;
}
+WebAppInfo::Ptr TgTypeParser::parseJsonAndGetWebAppInfo(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<WebAppInfo>());
+ result->url = data.get<std::string>("url", "");
+ return result;
+}
+
+std::string TgTypeParser::parseWebAppInfo(const WebAppInfo::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "url", object->url);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
ReplyKeyboardMarkup::Ptr TgTypeParser::parseJsonAndGetReplyKeyboardMarkup(const boost::property_tree::ptree& data) const {
auto result(std::make_shared<ReplyKeyboardMarkup>());
for (const auto& item : data.find("keyboard")->second){
@@ -1296,6 +1471,7 @@ KeyboardButton::Ptr TgTypeParser::parseJsonAndGetKeyboardButton(const boost::pro
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");
+ result->webApp = tryParseJson<WebAppInfo>(&TgTypeParser::parseJsonAndGetWebAppInfo, data, "web_app");
return result;
}
@@ -1309,6 +1485,7 @@ std::string TgTypeParser::parseKeyboardButton(const KeyboardButton::Ptr& object)
appendToJson(result, "request_contact", object->requestContact);
appendToJson(result, "request_location", object->requestLocation);
appendToJson(result, "request_poll", parseKeyboardButtonPollType(object->requestPoll));
+ appendToJson(result, "web_app", parseWebAppInfo(object->webApp));
removeLastComma(result);
result += '}';
return result;
@@ -1451,18 +1628,18 @@ ChatMemberAdministrator::Ptr TgTypeParser::parseJsonAndGetChatMemberAdministrato
// 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->canManageVideoChats = data.get<bool>("can_manage_video_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->canPostMessages = data.get<bool>("can_post_messages", false);
+ result->canEditMessages = data.get<bool>("can_edit_messages", false);
result->canPinMessages = data.get<bool>("can_pin_messages", false);
+ result->customTitle = data.get<std::string>("custom_title", "");
return result;
}
@@ -1474,18 +1651,18 @@ std::string TgTypeParser::parseChatMemberAdministrator(const ChatMemberAdministr
// 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_manage_video_chats", object->canManageVideoChats);
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_post_messages", object->canPostMessages);
+ appendToJson(result, "can_edit_messages", object->canEditMessages);
appendToJson(result, "can_pin_messages", object->canPinMessages);
+ appendToJson(result, "custom_title", object->customTitle);
// The last comma will be erased by parseChatMember().
return result;
}
@@ -1519,7 +1696,7 @@ ChatMemberRestricted::Ptr TgTypeParser::parseJsonAndGetChatMemberRestricted(cons
result->canSendPolls = data.get<bool>("can_send_polls", false);
result->canSendOtherMessages = data.get<bool>("can_send_other_messages", false);
result->canAddWebPagePreviews = data.get<bool>("can_add_web_page_previews", false);
- result->untilDate = data.get<uint32_t>("until_date", 0);
+ result->untilDate = data.get<std::uint32_t>("until_date", 0);
return result;
}
@@ -1666,9 +1843,9 @@ ChatInviteLink::Ptr TgTypeParser::parseJsonAndGetChatInviteLink(const boost::pro
result->isPrimary = data.get<bool>("is_primary", false);
result->isRevoked = data.get<bool>("is_revoked", false);
result->name = data.get<std::string>("name", "");
- result->expireDate = data.get<std::int32_t>("expire_date", 0);
- result->memberLimit = data.get<std::int32_t>("member_limit", 0);
- result->pendingJoinRequestCount = data.get<std::int32_t>("pending_join_request_count", 0);
+ result->expireDate = data.get<std::uint32_t>("expire_date", 0);
+ result->memberLimit = data.get<std::uint32_t>("member_limit", 0);
+ result->pendingJoinRequestCount = data.get<std::uint32_t>("pending_join_request_count", 0);
return result;
}
@@ -1692,6 +1869,44 @@ std::string TgTypeParser::parseChatInviteLink(const ChatInviteLink::Ptr& object)
return result;
}
+ChatAdministratorRights::Ptr TgTypeParser::parseJsonAndGetChatAdministratorRights(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<ChatAdministratorRights>());
+ result->isAnonymous = data.get<bool>("is_anonymous", false);
+ result->canManageChat = data.get<bool>("can_manage_chat", false);
+ result->canDeleteMessages = data.get<bool>("can_delete_messages", false);
+ result->canManageVideoChats = data.get<bool>("can_manage_video_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->canPostMessages = data.get<bool>("can_post_messages", false);
+ result->canEditMessages = data.get<bool>("can_edit_messages", false);
+ result->canPinMessages = data.get<bool>("can_pin_messages", false);
+ return result;
+}
+
+std::string TgTypeParser::parseChatAdministratorRights(const ChatAdministratorRights::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "is_anonymous", object->isAnonymous);
+ appendToJson(result, "can_manage_chat", object->canManageChat);
+ appendToJson(result, "can_delete_messages", object->canDeleteMessages);
+ appendToJson(result, "can_manage_video_chats", object->canManageVideoChats);
+ 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_post_messages", object->canPostMessages);
+ appendToJson(result, "can_edit_messages", object->canEditMessages);
+ appendToJson(result, "can_pin_messages", object->canPinMessages);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
ResponseParameters::Ptr TgTypeParser::parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const {
auto result(std::make_shared<ResponseParameters>());
result->migrateToChatId = data.get<std::int64_t>("migrate_to_chat_id", 0);
@@ -2578,6 +2793,24 @@ std::string TgTypeParser::parseChosenInlineResult(const ChosenInlineResult::Ptr&
return result;
}
+SentWebAppMessage::Ptr TgTypeParser::parseJsonAndGetSentWebAppMessage(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<SentWebAppMessage>());
+ result->inlineMessageId = data.get<std::string>("inline_message_id", "");
+ return result;
+}
+
+std::string TgTypeParser::parseSentWebAppMessage(const SentWebAppMessage::Ptr& object) const {
+ if (!object){
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "inline_message_id", object->inlineMessageId);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
CallbackQuery::Ptr TgTypeParser::parseJsonAndGetCallbackQuery(const boost::property_tree::ptree& data) const {
auto result(std::make_shared<CallbackQuery>());
result->id = data.get<std::string>("id");
@@ -2641,13 +2874,14 @@ std::string TgTypeParser::parseInlineKeyboardMarkup(const InlineKeyboardMarkup::
InlineKeyboardButton::Ptr TgTypeParser::parseJsonAndGetInlineKeyboardButton(const boost::property_tree::ptree& data) const {
auto result(std::make_shared<InlineKeyboardButton>());
- result->text = data.get<std::string>("text");
+ 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->webApp = tryParseJson<WebAppInfo>(&TgTypeParser::parseJsonAndGetWebAppInfo, data, "web_app");
+ result->loginUrl = tryParseJson<LoginUrl>(&TgTypeParser::parseJsonAndGetLoginUrl, data, "login_url");
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->callbackGame = tryParseJson<CallbackGame>(&TgTypeParser::parseJsonAndGetCallbackGame, data, "callback_game");
result->pay = data.get<bool>("pay", false);
return result;
}
@@ -2657,8 +2891,7 @@ std::string TgTypeParser::parseInlineKeyboardButton(const InlineKeyboardButton::
}
std::string result;
result += '{';
- if(object->pay)
- appendToJson(result, "pay", object->pay);
+ appendToJson(result, "pay", object->pay);
appendToJson(result, "text", object->text);
appendToJson(result, "url", object->url);
appendToJson(result, "callback_data", object->callbackData);
@@ -2669,6 +2902,30 @@ std::string TgTypeParser::parseInlineKeyboardButton(const InlineKeyboardButton::
return result;
}
+LoginUrl::Ptr TgTypeParser::parseJsonAndGetLoginUrl(const boost::property_tree::ptree& data) const {
+ auto result(std::make_shared<LoginUrl>());
+ result->url = data.get<std::string>("url", "");
+ result->forwardText = data.get<std::string>("forward_text", "");
+ result->botUsername = data.get<std::string>("bot_username", "");
+ result->requestWriteAccess = data.get<bool>("request_write_access", false);
+ return result;
+}
+
+std::string TgTypeParser::parseLoginUrl(const LoginUrl::Ptr& object) const {
+ if (!object){
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "url", object->url);
+ appendToJson(result, "forward_text", object->forwardText);
+ appendToJson(result, "bot_username", object->botUsername);
+ appendToJson(result, "request_write_access", object->requestWriteAccess);
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
WebhookInfo::Ptr TgTypeParser::parseJsonAndGetWebhookInfo(const boost::property_tree::ptree& data) const {
auto result(std::make_shared<WebhookInfo>());
result->url = data.get<std::string>("url", "");
@@ -2677,6 +2934,7 @@ WebhookInfo::Ptr TgTypeParser::parseJsonAndGetWebhookInfo(const boost::property_
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->lastSynchronizationErrorDate = data.get<std::int32_t>("last_synchronization_error_date", 0);
result->maxConnections = data.get<std::int32_t>("max_connections", 0);
result->allowedUpdates = parseJsonAndGetArray<std::string>(
[](const boost::property_tree::ptree& innerData)->std::string {
@@ -2698,6 +2956,7 @@ std::string TgTypeParser::parseWebhookInfo(const WebhookInfo::Ptr& object) const
appendToJson(result, "ip_address", object->ipAddress);
appendToJson(result, "last_error_date", object->lastErrorDate);
appendToJson(result, "last_error_message", object->lastErrorMessage);
+ appendToJson(result, "last_synchronization_error_date", object->lastSynchronizationErrorDate);
appendToJson(result, "max_connections", object->maxConnections);
appendToJson(result, "allowed_updates",
parseArray<std::string>([](const std::string &s)->std::string {
@@ -3170,6 +3429,101 @@ std::string TgTypeParser::parseBotCommandScopeChatMember(const BotCommandScopeCh
return result;
}
+MenuButton::Ptr TgTypeParser::parseJsonAndGetMenuButton(const boost::property_tree::ptree& data) const {
+ std::string type = data.get<std::string>("type", "");
+ MenuButton::Ptr result;
+
+ if (type == MenuButtonCommands::TYPE) {
+ result = std::static_pointer_cast<MenuButton>(parseJsonAndGetMenuButtonCommands(data));
+ } else if (type == MenuButtonWebApp::TYPE) {
+ result = std::static_pointer_cast<MenuButton>(parseJsonAndGetMenuButtonWebApp(data));
+ } else if (type == MenuButtonDefault::TYPE) {
+ result = std::static_pointer_cast<MenuButton>(parseJsonAndGetMenuButtonDefault(data));
+ } else {
+ result = std::make_shared<MenuButton>();
+ }
+
+ result->type = type;
+
+ return result;
+}
+
+std::string TgTypeParser::parseMenuButton(const MenuButton::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ std::string result;
+ result += '{';
+ appendToJson(result, "type", object->type);
+
+ if (object->type == MenuButtonCommands::TYPE) {
+ result += parseMenuButtonCommands(std::static_pointer_cast<MenuButtonCommands>(object));
+ } else if (object->type == MenuButtonWebApp::TYPE) {
+ result += parseMenuButtonWebApp(std::static_pointer_cast<MenuButtonWebApp>(object));
+ } else if (object->type == MenuButtonDefault::TYPE) {
+ result += parseMenuButtonDefault(std::static_pointer_cast<MenuButtonDefault>(object));
+ }
+
+ removeLastComma(result);
+ result += '}';
+ return result;
+}
+
+MenuButtonCommands::Ptr TgTypeParser::parseJsonAndGetMenuButtonCommands(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetMenuButton().
+ auto result(std::make_shared<MenuButtonCommands>());
+ return result;
+}
+
+std::string TgTypeParser::parseMenuButtonCommands(const MenuButtonCommands::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseMenuButton(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ // The last comma will be erased by parseMenuButton().
+ return result;
+}
+
+MenuButtonWebApp::Ptr TgTypeParser::parseJsonAndGetMenuButtonWebApp(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetMenuButton().
+ auto result(std::make_shared<MenuButtonWebApp>());
+ result->text = data.get<std::string>("text", "");
+ result->webApp = tryParseJson<WebAppInfo>(&TgTypeParser::parseJsonAndGetWebAppInfo, data, "web_app");
+ return result;
+}
+
+std::string TgTypeParser::parseMenuButtonWebApp(const MenuButtonWebApp::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseMenuButton(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ appendToJson(result, "text", object->text);
+ appendToJson(result, "web_app", parseWebAppInfo(object->webApp));
+ // The last comma will be erased by parseMenuButton().
+ return result;
+}
+
+MenuButtonDefault::Ptr TgTypeParser::parseJsonAndGetMenuButtonDefault(const boost::property_tree::ptree& data) const {
+ // NOTE: This function will be called by parseJsonAndGetMenuButton().
+ auto result(std::make_shared<MenuButtonDefault>());
+ return result;
+}
+
+std::string TgTypeParser::parseMenuButtonDefault(const MenuButtonDefault::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ // This function will be called by parseMenuButton(), so I don't add
+ // curly brackets to the result std::string.
+ std::string result;
+ // The last comma will be erased by parseMenuButton().
+ return result;
+}
+
OrderInfo::Ptr TgTypeParser::parseJsonAndGetOrderInfo(const boost::property_tree::ptree& data) const {
auto result(std::make_shared<OrderInfo>());
result->name = data.get<std::string>("name", "");
diff --git a/src/types/MenuButton.cpp b/src/types/MenuButton.cpp
new file mode 100644
index 0000000..54e3868
--- /dev/null
+++ b/src/types/MenuButton.cpp
@@ -0,0 +1,11 @@
+#include "tgbot/types/MenuButtonCommands.h"
+#include "tgbot/types/MenuButtonWebApp.h"
+#include "tgbot/types/MenuButtonDefault.h"
+
+#include <string>
+
+using namespace TgBot;
+
+const std::string MenuButtonCommands::TYPE = "commands";
+const std::string MenuButtonWebApp::TYPE = "web_app";
+const std::string MenuButtonDefault::TYPE = "default";