diff options
author | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2023-02-11 18:12:59 +0100 |
---|---|---|
committer | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2023-02-11 18:12:59 +0100 |
commit | 0caef51105de2c56d0797d87864db53129d778e6 (patch) | |
tree | ddafa5a9616b8bcec94fe9879f4b2a2abeb82efb /include/tgbot | |
parent | 4356f747596a42dd04766f9c7234fd1aded2eeda (diff) |
Update to Bot API 6.5
Diffstat (limited to 'include/tgbot')
-rw-r--r-- | include/tgbot/Api.h | 18 | ||||
-rw-r--r-- | include/tgbot/TgTypeParser.h | 16 | ||||
-rw-r--r-- | include/tgbot/types/ChatAdministratorRights.h | 2 | ||||
-rw-r--r-- | include/tgbot/types/ChatJoinRequest.h | 16 | ||||
-rw-r--r-- | include/tgbot/types/ChatMemberAdministrator.h | 2 | ||||
-rw-r--r-- | include/tgbot/types/ChatMemberRestricted.h | 49 | ||||
-rw-r--r-- | include/tgbot/types/ChatPermissions.h | 31 | ||||
-rw-r--r-- | include/tgbot/types/ChatShared.h | 36 | ||||
-rw-r--r-- | include/tgbot/types/File.h | 4 | ||||
-rw-r--r-- | include/tgbot/types/KeyboardButton.h | 33 | ||||
-rw-r--r-- | include/tgbot/types/KeyboardButtonRequestChat.h | 80 | ||||
-rw-r--r-- | include/tgbot/types/KeyboardButtonRequestUser.h | 43 | ||||
-rw-r--r-- | include/tgbot/types/Message.h | 12 | ||||
-rw-r--r-- | include/tgbot/types/UserShared.h | 36 |
14 files changed, 344 insertions, 34 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index b34a10d..7db68e7 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -770,7 +770,7 @@ public: * @brief Use this method to get basic information about a file and prepare it for downloading. * * For the moment, bots can download files of up to 20MB in size. - * The file can then be downloaded via Api::downloadFile, where filePath is taken from the response. + * The file can then be downloaded via Api::downloadFile or via the link https://api.telegram.org/file/bot<token>/<filePath>, where filePath is taken from the response. * It is guaranteed that the filePath will be valid for at least 1 hour. * When the link expires, a new one can be requested by calling Api::getFile again. * @@ -823,20 +823,22 @@ public: /** * @brief Use this method to restrict a user in a supergroup. * - * The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. + * The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. * Pass True for all permissions to lift restrictions from a user. * * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) * @param userId Unique identifier of the target user * @param permissions A JSON-serialized object for new user permissions * @param untilDate Optional. Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever + * @param useIndependentChatPermissions Optional. Pass True if chat permissions are set independently. Otherwise, the canSendOtherMessages and canAddWebPagPreviews permissions will imply the canSendMessages, canSendAudios, canSendDocuments, canSendPhotos, canSendVideos, canSendVideoNotes, and canSendVoiceNotes permissions; the canSendPolls permission will imply the canSendMessages permission. * * @return Returns True on success. */ bool restrictChatMember(boost::variant<std::int64_t, std::string> chatId, std::int64_t userId, ChatPermissions::Ptr permissions, - std::int64_t untilDate = 0) const; + std::int64_t untilDate = 0, + bool useIndependentChatPermissions = false) const; /** * @brief Use this method to promote or demote a user in a supergroup or a channel. @@ -852,7 +854,7 @@ public: * @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 canPromoteMembers Optional. Pass True if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have 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 canManageVideoChats Optional. Pass True if the administrator can manage video chats @@ -923,11 +925,13 @@ public: * * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) * @param permissions A JSON-serialized object for new default chat permissions + * @param useIndependentChatPermissions Optional. Pass True if chat permissions are set independently. Otherwise, the canSendOtherMessages and canAddWebPagPreviews permissions will imply the canSendMessages, canSendAudios, canSendDocuments, canSendPhotos, canSendVideos, canSendVideoNotes, and canSendVoiceNotes permissions; the canSendPolls permission will imply the canSendMessages permission. * * @return Returns True on success. */ bool setChatPermissions(boost::variant<std::int64_t, std::string> chatId, - ChatPermissions::Ptr permissions) const; + ChatPermissions::Ptr permissions, + bool useIndependentChatPermissions = false) const; /** * @brief Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. @@ -1157,7 +1161,7 @@ public: /** * @brief Use this method to get information about a member of a chat. * - * The method is guaranteed to work for other users, only if the bot is an administrator in the chat. + * The method is only guaranteed to work for other users if the bot is an administrator in the chat. * * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) * @param userId Unique identifier of the target user @@ -1207,7 +1211,7 @@ public: * * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) * @param name Topic name, 1-128 characters - * @param iconColor Optional. Color of the topic icon in RGB format. Currently, must be one of 0x6FB9F0, 0xFFD67E, 0xCB86DB, 0x8EEE98, 0xFF93B2, or 0xFB6F5F + * @param iconColor Optional. Color of the topic icon in RGB format. Currently, must be one of 7322096 (0x6FB9F0), 16766590 (0xFFD67E), 13338331 (0xCB86DB), 9367192 (0x8EEE98), 16749490 (0xFF93B2), or 16478047 (0xFB6F5F) * @param iconCustomEmojiId Optional. Unique identifier of the custom emoji shown as the topic icon. Use Api::getForumTopicIconStickers to get all allowed custom emoji identifiers. * * @return Returns information about the created topic as a ForumTopic object. diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h index 66c1f8f..191db5a 100644 --- a/include/tgbot/TgTypeParser.h +++ b/include/tgbot/TgTypeParser.h @@ -32,6 +32,8 @@ #include "tgbot/types/ForumTopicReopened.h" #include "tgbot/types/GeneralForumTopicHidden.h" #include "tgbot/types/GeneralForumTopicUnhidden.h" +#include "tgbot/types/UserShared.h" +#include "tgbot/types/ChatShared.h" #include "tgbot/types/WriteAccessAllowed.h" #include "tgbot/types/VideoChatScheduled.h" #include "tgbot/types/VideoChatStarted.h" @@ -42,6 +44,8 @@ #include "tgbot/types/WebAppInfo.h" #include "tgbot/types/ReplyKeyboardMarkup.h" #include "tgbot/types/KeyboardButton.h" +#include "tgbot/types/KeyboardButtonRequestUser.h" +#include "tgbot/types/KeyboardButtonRequestChat.h" #include "tgbot/types/KeyboardButtonPollType.h" #include "tgbot/types/ReplyKeyboardRemove.h" #include "tgbot/types/InlineKeyboardMarkup.h" @@ -252,6 +256,12 @@ public: GeneralForumTopicUnhidden::Ptr parseJsonAndGetGeneralForumTopicUnhidden(const boost::property_tree::ptree& data) const; std::string parseGeneralForumTopicUnhidden(const GeneralForumTopicUnhidden::Ptr& object) const; + UserShared::Ptr parseJsonAndGetUserShared(const boost::property_tree::ptree& data) const; + std::string parseUserShared(const UserShared::Ptr& object) const; + + ChatShared::Ptr parseJsonAndGetChatShared(const boost::property_tree::ptree& data) const; + std::string parseChatShared(const ChatShared::Ptr& object) const; + WriteAccessAllowed::Ptr parseJsonAndGetWriteAccessAllowed(const boost::property_tree::ptree& data) const; std::string parseWriteAccessAllowed(const WriteAccessAllowed::Ptr& object) const; @@ -282,6 +292,12 @@ public: KeyboardButton::Ptr parseJsonAndGetKeyboardButton(const boost::property_tree::ptree& data) const; std::string parseKeyboardButton(const KeyboardButton::Ptr& object) const; + KeyboardButtonRequestUser::Ptr parseJsonAndGetKeyboardButtonRequestUser(const boost::property_tree::ptree& data) const; + std::string parseKeyboardButtonRequestUser(const KeyboardButtonRequestUser::Ptr& object) const; + + KeyboardButtonRequestChat::Ptr parseJsonAndGetKeyboardButtonRequestChat(const boost::property_tree::ptree& data) const; + std::string parseKeyboardButtonRequestChat(const KeyboardButtonRequestChat::Ptr& object) const; + KeyboardButtonPollType::Ptr parseJsonAndGetKeyboardButtonPollType(const boost::property_tree::ptree& data) const; std::string parseKeyboardButtonPollType(const KeyboardButtonPollType::Ptr& object) const; diff --git a/include/tgbot/types/ChatAdministratorRights.h b/include/tgbot/types/ChatAdministratorRights.h index 8e20b18..d2ee3e5 100644 --- a/include/tgbot/types/ChatAdministratorRights.h +++ b/include/tgbot/types/ChatAdministratorRights.h @@ -42,7 +42,7 @@ public: 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) + * @brief True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by the user) */ bool canPromoteMembers; diff --git a/include/tgbot/types/ChatJoinRequest.h b/include/tgbot/types/ChatJoinRequest.h index bcd3e4e..dbcbd8b 100644 --- a/include/tgbot/types/ChatJoinRequest.h +++ b/include/tgbot/types/ChatJoinRequest.h @@ -1,5 +1,5 @@ -#ifndef TGBOT_CPP_CHATJOINREQUEST_H -#define TGBOT_CPP_CHATJOINREQUEST_H +#ifndef TGBOT_CHATJOINREQUEST_H +#define TGBOT_CHATJOINREQUEST_H #include "tgbot/types/Chat.h" #include "tgbot/types/User.h" @@ -32,6 +32,16 @@ public: User::Ptr from; /** + * @brief Identifier of a private chat with the user who sent the join request. + * + * The bot can use this identifier for 24 hours to send messages until the join request is processed, assuming no other administrator contacted the user. + * + * This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. + * But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. + */ + std::int64_t userChatId; + + /** * @brief Date the request was sent in Unix time */ std::int32_t date; @@ -48,4 +58,4 @@ public: }; } -#endif //TGBOT_CPP_CHATJOINREQUEST_H +#endif //TGBOT_CHATJOINREQUEST_H diff --git a/include/tgbot/types/ChatMemberAdministrator.h b/include/tgbot/types/ChatMemberAdministrator.h index 714ed1d..d100f85 100644 --- a/include/tgbot/types/ChatMemberAdministrator.h +++ b/include/tgbot/types/ChatMemberAdministrator.h @@ -56,7 +56,7 @@ public: 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) + * @brief True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by the user) */ bool canPromoteMembers; diff --git a/include/tgbot/types/ChatMemberRestricted.h b/include/tgbot/types/ChatMemberRestricted.h index ab19b03..cbc198b 100644 --- a/include/tgbot/types/ChatMemberRestricted.h +++ b/include/tgbot/types/ChatMemberRestricted.h @@ -31,34 +31,39 @@ public: bool isMember; /** - * @brief True, if the user is allowed to change the chat title, photo and other settings + * @brief True, if the user is allowed to send text messages, contacts, invoices, locations and venues */ - bool canChangeInfo; + bool canSendMessages; /** - * @brief True, if the user is allowed to invite new users to the chat + * @brief True, if the user is allowed to send audios */ - bool canInviteUsers; + bool canSendAudios; /** - * @brief True, if the user is allowed to pin messages + * @brief True, if the user is allowed to send documents */ - bool canPinMessages; + bool canSendDocuments; /** - * @brief True, if the user is allowed to create forum topics + * @brief True, if the user is allowed to send photos */ - bool canManageTopics; + bool canSendPhotos; /** - * @brief True, if the user is allowed to send text messages, contacts, locations and venues + * @brief True, if the user is allowed to send videos */ - bool canSendMessages; + bool canSendVideos; + + /** + * @brief True, if the user is allowed to send video notes + */ + bool canSendVideoNotes; /** - * @brief True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes + * @brief True, if the user is allowed to send voice notes */ - bool canSendMediaMessages; + bool canSendVoiceNotes; /** * @brief True, if the user is allowed to send polls @@ -76,6 +81,26 @@ public: bool canAddWebPagePreviews; /** + * @brief True, if the user is allowed to change the chat title, photo and other settings + */ + bool canChangeInfo; + + /** + * @brief True, if the user is allowed to invite new users to the chat + */ + bool canInviteUsers; + + /** + * @brief True, if the user is allowed to pin messages + */ + bool canPinMessages; + + /** + * @brief True, if the user is allowed to create forum topics + */ + bool canManageTopics; + + /** * @brief Date when restrictions will be lifted for this user; unix time. * * If 0, then the user is restricted forever diff --git a/include/tgbot/types/ChatPermissions.h b/include/tgbot/types/ChatPermissions.h index 0d8e056..20390d6 100644 --- a/include/tgbot/types/ChatPermissions.h +++ b/include/tgbot/types/ChatPermissions.h @@ -16,14 +16,39 @@ public: typedef std::shared_ptr<ChatPermissions> Ptr; /** - * @brief Optional. True, if the user is allowed to send text messages, contacts, locations and venues + * @brief Optional. True, if the user is allowed to send text messages, contacts, invoices, locations and venues */ bool canSendMessages; /** - * @brief Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies canSendMessages + * @brief Optional. True, if the user is allowed to send audios */ - bool canSendMediaMessages; + bool canSendAudios; + + /** + * @brief Optional. True, if the user is allowed to send documents + */ + bool canSendDocuments; + + /** + * @brief Optional. True, if the user is allowed to send photos + */ + bool canSendPhotos; + + /** + * @brief Optional. True, if the user is allowed to send videos + */ + bool canSendVideos; + + /** + * @brief Optional. True, if the user is allowed to send video notes + */ + bool canSendVideoNotes; + + /** + * @brief Optional. True, if the user is allowed to send voice notes + */ + bool canSendVoiceNotes; /** * @brief Optional. True, if the user is allowed to send polls, implies canSendMessages diff --git a/include/tgbot/types/ChatShared.h b/include/tgbot/types/ChatShared.h new file mode 100644 index 0000000..14b1566 --- /dev/null +++ b/include/tgbot/types/ChatShared.h @@ -0,0 +1,36 @@ +#ifndef TGBOT_CHATSHARED_H +#define TGBOT_CHATSHARED_H + +#include <cstdint> +#include <memory> + +namespace TgBot { + +/** + * @brief This object contains information about the chat whose identifier was shared with the bot using a KeyboardButtonRequestChat button. + * + * @ingroup types + */ +class ChatShared { + +public: + typedef std::shared_ptr<ChatShared> Ptr; + + /** + * @brief Identifier of the request + */ + std::int32_t requestId; + + /** + * @brief Identifier of the shared chat. + * + * The bot may not have access to the chat and could be unable to use this identifier, unless the chat is already known to the bot by some other means. + * + * This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. + * But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. + */ + std::int64_t userId; +}; +} + +#endif //TGBOT_CHATSHARED_H diff --git a/include/tgbot/types/File.h b/include/tgbot/types/File.h index e923881..b1f3ee5 100644 --- a/include/tgbot/types/File.h +++ b/include/tgbot/types/File.h @@ -9,7 +9,7 @@ namespace TgBot { /** * @brief This object represents a file ready to be downloaded. - * The file can be downloaded via Api::downloadFile. + * The file can be downloaded via Api::downloadFile or via the link https://api.telegram.org/file/bot<token>/<filePath>. * It is guaranteed that the File::filePath will be valid for at least 1 hour. * When the File::filePath expires, a new one can be requested by calling Api::getFile. * @@ -43,7 +43,7 @@ public: /** * @brief Optional. File path. - * Use Api::downloadFile to get the file. + * Use Api::downloadFile or https://api.telegram.org/file/bot<token>/<filePath> to get the file. */ std::string filePath; }; diff --git a/include/tgbot/types/KeyboardButton.h b/include/tgbot/types/KeyboardButton.h index 0847765..97bdc85 100644 --- a/include/tgbot/types/KeyboardButton.h +++ b/include/tgbot/types/KeyboardButton.h @@ -1,6 +1,8 @@ #ifndef TGBOT_KEYBOARDBUTTON_H #define TGBOT_KEYBOARDBUTTON_H +#include "tgbot/types/KeyboardButtonRequestUser.h" +#include "tgbot/types/KeyboardButtonRequestChat.h" #include "tgbot/types/KeyboardButtonPollType.h" #include "tgbot/types/WebAppInfo.h" @@ -11,8 +13,8 @@ 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 webApp, requestContact, requestLocation, and requestPoll are mutually exclusive. + * For simple text buttons, String can be used instead of this object to specify the button text. + * The optional fields webApp, requestUser, requestChat, requestContact, requestLocation, and requestPoll are mutually exclusive. * * @ingroup types */ @@ -23,31 +25,52 @@ public: /** * @brief Text of the button. + * * If none of the optional fields are used, it will be sent as a message when the button is pressed */ std::string text; /** + * @brief Optional. If specified, pressing the button will open a list of suitable users. + * + * Tapping on any user will send their identifier to the bot in a “user_shared” service message. + * Available in private chats only. + */ + KeyboardButtonRequestUser::Ptr requestUser; + + /** + * @brief Optional. If specified, pressing the button will open a list of suitable chats. + * + * Tapping on a chat will send its identifier to the bot in a “chat_shared” service message. + * Available in private chats only. + */ + KeyboardButtonRequestChat::Ptr requestChat; + + /** * @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. */ - bool requestContact = false; + bool requestContact; /** * @brief Optional. If True, the user's current location will be sent when the button is pressed. + * * Available in private chats only. */ - bool requestLocation = false; + bool requestLocation; /** * @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. */ 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. + * + * The Web App will be able to send a “web_app_data” service message. * Available in private chats only. */ WebAppInfo::Ptr webApp; diff --git a/include/tgbot/types/KeyboardButtonRequestChat.h b/include/tgbot/types/KeyboardButtonRequestChat.h new file mode 100644 index 0000000..9e446d8 --- /dev/null +++ b/include/tgbot/types/KeyboardButtonRequestChat.h @@ -0,0 +1,80 @@ +#ifndef TGBOT_KEYBOARDBUTTONREQUESTCHAT_H +#define TGBOT_KEYBOARDBUTTONREQUESTCHAT_H + +#include "tgbot/types/ChatAdministratorRights.h" + +#include <cstdint> +#include <memory> + +namespace TgBot { + +/** + * @brief This object defines the criteria used to request a suitable chat. + * The identifier of the selected chat will be shared with the bot when the corresponding button is pressed. + * + * @ingroup types + */ +class KeyboardButtonRequestChat { + +public: + typedef std::shared_ptr<KeyboardButtonRequestChat> Ptr; + + /** + * @brief Signed 32-bit identifier of the request, which will be received back in the ChatShared object. + * + * Must be unique within the message + */ + std::int32_t requestId; + + /** + * @brief Pass True to request a channel chat, pass False to request a group or a supergroup chat. + */ + bool chatIsChannel; + + /** + * @brief Optional. Pass True to request a forum supergroup, pass False to request a non-forum chat. + * + * If not specified, no additional restrictions are applied. + */ + bool chatIsForum; + + /** + * @brief Optional. Pass True to request a supergroup or a channel with a username, pass False to request a chat without a username. + * + * If not specified, no additional restrictions are applied. + */ + bool chatHasUsername; + + /** + * @brief Optional. Pass True to request a chat owned by the user. + * + * Otherwise, no additional restrictions are applied. + */ + bool chatIsCreated; + + /** + * @brief Optional. A JSON-serialized object listing the required administrator rights of the user in the chat. + * + * The rights must be a superset of bot_administrator_rights. + * If not specified, no additional restrictions are applied. + */ + ChatAdministratorRights::Ptr userAdministratorRights; + + /** + * @brief Optional. A JSON-serialized object listing the required administrator rights of the bot in the chat. + * + * The rights must be a subset of user_administrator_rights. + * If not specified, no additional restrictions are applied. + */ + ChatAdministratorRights::Ptr botAdministratorRights; + + /** + * @brief Optional. Pass True to request a chat with the bot as a member. + * + * Otherwise, no additional restrictions are applied. + */ + bool botIsMember; +}; +} + +#endif //TGBOT_KEYBOARDBUTTONREQUESTCHAT_H diff --git a/include/tgbot/types/KeyboardButtonRequestUser.h b/include/tgbot/types/KeyboardButtonRequestUser.h new file mode 100644 index 0000000..3463e49 --- /dev/null +++ b/include/tgbot/types/KeyboardButtonRequestUser.h @@ -0,0 +1,43 @@ +#ifndef TGBOT_KEYBOARDBUTTONREQUESTUSER_H +#define TGBOT_KEYBOARDBUTTONREQUESTUSER_H + +#include <cstdint> +#include <memory> + +namespace TgBot { + +/** + * @brief This object defines the criteria used to request a suitable user. + * The identifier of the selected user will be shared with the bot when the corresponding button is pressed. + * + * @ingroup types + */ +class KeyboardButtonRequestUser { + +public: + typedef std::shared_ptr<KeyboardButtonRequestUser> Ptr; + + /** + * @brief Signed 32-bit identifier of the request, which will be received back in the UserShared object. + * + * Must be unique within the message + */ + std::int32_t requestId; + + /** + * @brief Optional. Pass True to request a bot, pass False to request a regular user. + * + * If not specified, no additional restrictions are applied. + */ + bool userIsBot; + + /** + * @brief Optional. Pass True to request a premium user, pass False to request a non-premium user. + * + * If not specified, no additional restrictions are applied. + */ + bool userIsPremium; +}; +} + +#endif //TGBOT_KEYBOARDBUTTONREQUESTUSER_H diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h index 11ba954..8ed8300 100644 --- a/include/tgbot/types/Message.h +++ b/include/tgbot/types/Message.h @@ -22,6 +22,8 @@ #include "tgbot/types/MessageAutoDeleteTimerChanged.h" #include "tgbot/types/Invoice.h" #include "tgbot/types/SuccessfulPayment.h" +#include "tgbot/types/UserShared.h" +#include "tgbot/types/ChatShared.h" #include "tgbot/types/WriteAccessAllowed.h" #include "tgbot/types/PassportData.h" #include "tgbot/types/ProximityAlertTriggered.h" @@ -349,6 +351,16 @@ public: SuccessfulPayment::Ptr successfulPayment; /** + * @brief Optional. Service message: a user was shared with the bot + */ + UserShared::Ptr userShared; + + /** + * @brief Optional. Service message: a chat was shared with the bot + */ + ChatShared::Ptr chatShared; + + /** * @brief Optional. The domain name of the website on which the user has logged in. * * https://core.telegram.org/widgets/login diff --git a/include/tgbot/types/UserShared.h b/include/tgbot/types/UserShared.h new file mode 100644 index 0000000..9d92b4d --- /dev/null +++ b/include/tgbot/types/UserShared.h @@ -0,0 +1,36 @@ +#ifndef TGBOT_USERSHARED_H +#define TGBOT_USERSHARED_H + +#include <cstdint> +#include <memory> + +namespace TgBot { + +/** + * @brief This object contains information about the user whose identifier was shared with the bot using a KeyboardButtonRequestUser button. + * + * @ingroup types + */ +class UserShared { + +public: + typedef std::shared_ptr<UserShared> Ptr; + + /** + * @brief Identifier of the request + */ + std::int32_t requestId; + + /** + * @brief Identifier of the shared user. + * + * The bot may not have access to the user and could be unable to use this identifier, unless the user is already known to the bot by some other means. + * + * This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. + * But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. + */ + std::int64_t userId; +}; +} + +#endif //TGBOT_USERSHARED_H |