diff options
author | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2022-09-11 12:32:11 +0200 |
---|---|---|
committer | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2022-09-11 12:32:11 +0200 |
commit | 924dd8b38b588fad05f55424f547e521ccfe71f5 (patch) | |
tree | af01cd42c9d58d538f78a515200745f5e326b0f0 /include/tgbot | |
parent | 707bcac4dd0fffd961dbb325e7d11752ee55392d (diff) |
Update to API 6.0
Diffstat (limited to 'include/tgbot')
25 files changed, 652 insertions, 224 deletions
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; }; |