summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt5
-rw-r--r--README.md4
-rw-r--r--include/tgbot/Api.h73
-rw-r--r--include/tgbot/TgTypeParser.h71
-rw-r--r--include/tgbot/types/CallbackGame.h3
-rw-r--r--include/tgbot/types/ChatAdministratorRights.h75
-rw-r--r--include/tgbot/types/ChatMemberAdministrator.h36
-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/SentWebAppMessage.h26
-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/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.cpp71
-rw-r--r--src/TgTypeParser.cpp305
-rw-r--r--src/types/MenuButton.cpp11
30 files changed, 1006 insertions, 266 deletions
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 103dcdc..54444e5 100644
--- a/README.md
+++ b/README.md
@@ -11,9 +11,9 @@ 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 3.0 ~ 4.9
- [x] Bot API 5.0 ~ 5.7 (Implemented all APIs except 'Run Your Own Bot API Server')
+- [x] Bot API 6.0
## Sample
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index be81d8e..5292e87 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"
@@ -751,26 +752,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,
@@ -781,7 +783,7 @@ public:
bool canPromoteMembers = false,
bool isAnonymous = false,
bool canManageChat = false,
- bool canManageVoiceChats = false,
+ bool canManageVideoChats = false,
bool canRestrictMembers = false) const;
/**
@@ -1085,6 +1087,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
@@ -1314,6 +1358,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)
@@ -1483,4 +1538,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..db29f3d 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;
@@ -694,4 +733,4 @@ private:
}
-#endif //TGBOT_CPP_TGTYPEPARSER_H
+#endif //TGBOT_TGTYPEPARSER_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/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/InlineKeyboardButton.h b/include/tgbot/types/InlineKeyboardButton.h
index 9ec5120..36f150d 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 HTTP 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.
+ * Can 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.
+ * Can 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/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/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/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 9538485..ee17b51 100644
--- a/src/Api.cpp
+++ b/src/Api.cpp
@@ -1057,7 +1057,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,
@@ -1068,7 +1068,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);
@@ -1090,8 +1090,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);
@@ -1427,6 +1427,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,
@@ -1755,6 +1807,17 @@ bool Api::answerInlineQuery(const string& inlineQueryId, const std::vector<Inlin
return sendRequest("answerInlineQuery", args).get<bool>("", false);
}
+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,
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp
index daf80c8..27e96ae 100644
--- a/src/TgTypeParser.cpp
+++ b/src/TgTypeParser.cpp
@@ -196,10 +196,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 +264,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 += '}';
@@ -747,6 +749,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", "");
@@ -887,6 +904,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");
@@ -927,13 +964,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 "";
}
@@ -945,25 +982,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 "";
}
@@ -975,13 +1015,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 "";
}
@@ -1254,6 +1294,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){
@@ -1300,6 +1358,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;
}
@@ -1313,6 +1372,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;
@@ -1455,18 +1515,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;
}
@@ -1478,18 +1538,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;
}
@@ -1696,6 +1756,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);
@@ -2582,6 +2680,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");
@@ -2645,13 +2761,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;
}
@@ -2661,8 +2778,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);
@@ -2673,6 +2789,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", "");
@@ -2681,6 +2821,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 {
@@ -2702,6 +2843,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 {
@@ -3174,6 +3316,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";