diff options
author | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2022-09-11 13:58:09 +0200 |
---|---|---|
committer | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2022-09-11 13:58:09 +0200 |
commit | 0c3b44cead20fb421bdacaba7613348f7573b282 (patch) | |
tree | 74cef323003d7a542cf1f7e3801cb471c0aa4de8 /include | |
parent | 924dd8b38b588fad05f55424f547e521ccfe71f5 (diff) |
Update to API 6.1
Diffstat (limited to 'include')
-rw-r--r-- | include/tgbot/Api.h | 72 | ||||
-rw-r--r-- | include/tgbot/types/Animation.h | 7 | ||||
-rw-r--r-- | include/tgbot/types/Audio.h | 15 | ||||
-rw-r--r-- | include/tgbot/types/Chat.h | 34 | ||||
-rw-r--r-- | include/tgbot/types/Document.h | 15 | ||||
-rw-r--r-- | include/tgbot/types/File.h | 26 | ||||
-rw-r--r-- | include/tgbot/types/InlineKeyboardButton.h | 12 | ||||
-rw-r--r-- | include/tgbot/types/Sticker.h | 14 | ||||
-rw-r--r-- | include/tgbot/types/User.h | 33 | ||||
-rw-r--r-- | include/tgbot/types/Video.h | 15 | ||||
-rw-r--r-- | include/tgbot/types/Voice.h | 7 |
11 files changed, 174 insertions, 76 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index 5292e87..a3f4b37 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -69,37 +69,40 @@ public: const StringArrayPtr& allowedUpdates = nullptr) const; /** - * @brief Use this method to specify a url and receive incoming updates via an outgoing webhook. - * Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized @ref Update. + * @brief Use this method to specify a URL and receive incoming updates via an outgoing webhook. + * + * Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. * In case of an unsuccessful request, we will give up after a reasonable amount of attempts. * - * If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. https://www.example.com/<token>. - * Since nobody else knows your bot's token, you can be pretty sure it's us. + * If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secretToken. + * If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content. * - * You will not be able to receive updates using @ref Api::getUpdates for as long as an outgoing webhook is set up. + * You will not be able to receive updates using Api::getUpdates for as long as an outgoing webhook is set up. * * To use a self-signed certificate, you need to upload your public key certificate using certificate parameter. * Please upload as InputFile, sending a String will not work. * - * Ports currently supported for Webhooks: 443, 80, 88, 8443. + * Ports currently supported for webhooks: 443, 80, 88, 8443. * * If you're having any trouble setting up webhooks, please check out https://core.telegram.org/bots/webhooks. * - * @param url HTTPS url to send updates to. Use an empty string to remove webhook integration + * @param url HTTPS URL to send updates to. Use an empty string to remove webhook integration * @param certificate Optional. Upload your public key certificate so that the root certificate in use can be checked. See https://core.telegram.org/bots/self-signed for details. - * @param maxConnection Optional. Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput. - * @param allowedUpdates Optional. A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all updates regardless of type (default). If not specified, the previous setting will be used. Please note that this parameter doesn't affect updates created before the call to the setWebhook, so unwanted updates may be received for a short period of time. + * @param maxConnection Optional. The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput. + * @param allowedUpdates Optional. A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chatMember (default). If not specified, the previous setting will be used. Please note that this parameter doesn't affect updates created before the call to the setWebhook, so unwanted updates may be received for a short period of time. * @param ipAddress Optional. The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS * @param dropPendingUpdates Optional. Pass True to drop all pending updates + * @param secretToken Optional. A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters. Only characters A-Z, a-z, 0-9, _ and - are allowed. The header is useful to ensure that the request comes from a webhook set by you. * - * @return True on success. + * @return Returns True on success. */ bool setWebhook(const std::string& url, InputFile::Ptr certificate = nullptr, std::int32_t maxConnection = 40, const StringArrayPtr& allowedUpdates = nullptr, const std::string& ipAddress = "", - bool dropPendingUpdates = false) const; + bool dropPendingUpdates = false, + const std::string& secretToken = "") const; /** * @brief Use this method to remove webhook integration if you decide to switch back to @ref Api::getUpdates. @@ -1430,6 +1433,53 @@ public: bool protectContent = false) const; /** + * @brief Use this method to create a link for an invoice. + * + * @param title Product name, 1-32 characters + * @param description Product description, 1-255 characters + * @param payload Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. + * @param providerToken Payment provider token, obtained via BotFather + * @param currency Three-letter ISO 4217 currency code, see https://core.telegram.org/bots/payments#supported-currencies + * @param prices Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) + * @param maxTipAmount Optional. The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass maxTipAmount = 145. See the exp parameter in https://core.telegram.org/bots/payments/currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0 + * @param suggestedTipAmounts Optional. A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed maxTipAmount. + * @param providerData Optional. JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider. + * @param photoUrl Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. + * @param photoSize Optional. Photo size in bytes + * @param photoWidth Optional. Photo width + * @param photoHeight Optional. Photo height + * @param needName Optional. Pass True, if you require the user's full name to complete the order + * @param needPhoneNumber Optional. Pass True, if you require the user's phone number to complete the order + * @param needEmail Optional. Pass True, if you require the user's email address to complete the order + * @param needShippingAddress Optional. Pass True, if you require the user's shipping address to complete the order + * @param sendPhoneNumberToProvider Optional. Pass True, if the user's phone number should be sent to the provider + * @param sendEmailToProvider Optional. Pass True, if the user's email address should be sent to the provider + * @param isFlexible Optional. Pass True, if the final price depends on the shipping method + * + * @return Returns the created invoice link as String on success. + */ + std::string createInvoiceLink(const std::string& title, + const std::string& description, + const std::string& payload, + const std::string& providerToken, + const std::string& currency, + const std::vector<LabeledPrice::Ptr>& prices, + std::int32_t maxTipAmount = 0, + const std::vector<std::int32_t>& suggestedTipAmounts = std::vector<std::int32_t>(), + const std::string& providerData = "", + const std::string& photoUrl = "", + std::int32_t photoSize = 0, + std::int32_t photoWidth = 0, + std::int32_t photoHeight = 0, + bool needName = false, + bool needPhoneNumber = false, + bool needEmail = false, + bool needShippingAddress = false, + bool sendPhoneNumberToProvider = false, + bool sendEmailToProvider = false, + bool isFlexible = false) const; + + /** * @brief Use this method to reply to shipping queries. * * If you sent an invoice requesting a shipping address and the parameter isFlexible was specified, the Bot API will send an Update with a shipping_query field to the bot. diff --git a/include/tgbot/types/Animation.h b/include/tgbot/types/Animation.h index ee3cdd4..8d9688f 100644 --- a/include/tgbot/types/Animation.h +++ b/include/tgbot/types/Animation.h @@ -60,9 +60,12 @@ public: std::string mimeType; /** - * @brief Optional. File size + * @brief Optional. File size in bytes. + * + * It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. + * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value. */ - std::int32_t fileSize; + std::int64_t fileSize; }; } diff --git a/include/tgbot/types/Audio.h b/include/tgbot/types/Audio.h index 50611ca..5095e5c 100644 --- a/include/tgbot/types/Audio.h +++ b/include/tgbot/types/Audio.h @@ -1,11 +1,11 @@ -#ifndef TGBOT_CPP_AUDIO_H -#define TGBOT_CPP_AUDIO_H +#ifndef TGBOT_AUDIO_H +#define TGBOT_AUDIO_H #include "tgbot/types/PhotoSize.h" #include <cstdint> -#include <string> #include <memory> +#include <string> namespace TgBot { @@ -56,9 +56,12 @@ public: std::string mimeType; /** - * @brief Optional. File size + * @brief Optional. File size in bytes. + * + * It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. + * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value. */ - std::int32_t fileSize; + std::int64_t fileSize; /** * @brief Optional. Thumbnail of the album cover to which the music file belongs @@ -67,4 +70,4 @@ public: }; } -#endif //TGBOT_CPP_AUDIO_H +#endif //TGBOT_AUDIO_H diff --git a/include/tgbot/types/Chat.h b/include/tgbot/types/Chat.h index 24f7955..931427e 100644 --- a/include/tgbot/types/Chat.h +++ b/include/tgbot/types/Chat.h @@ -1,17 +1,18 @@ -#ifndef TGBOT_CPP_CHAT_H -#define TGBOT_CPP_CHAT_H +#ifndef TGBOT_CHAT_H +#define TGBOT_CHAT_H #include "tgbot/types/ChatPhoto.h" #include "tgbot/types/ChatPermissions.h" #include "tgbot/types/ChatLocation.h" #include <cstdint> -#include <string> #include <memory> +#include <string> namespace TgBot { class Message; + /** * @brief This object represents a chat. * @@ -81,20 +82,31 @@ public: bool hasPrivateForwards; /** + * @brief Optional. True, if users need to join the supergroup before they can send messages. + * Returned only in Api::getChat. + */ + bool joinToSendMessages; + + /** + * @brief Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators. + * Returned only in Api::getChat. + */ + bool joinByRequest; + + /** * @brief Optional. Description, for groups, supergroups and channel chats. * Returned only in Api::getChat. */ std::string description; /** - * @brief Optional. Chat invite link, for groups, supergroups and channel chats. - * Each administrator in a chat generates their own invite links, so the bot must first generate the link using Api::exportChatInviteLink. + * @brief Optional. Primary invite link, for groups, supergroups and channel chats. * Returned only in Api::getChat. */ std::string inviteLink; /** - * @brief Optional. Pinned message, for groups, supergroups and channels. + * @brief Optional. The most recent pinned message (by sending date). * Returned only in Api::getChat. */ std::shared_ptr<Message> pinnedMessage; @@ -106,13 +118,13 @@ public: ChatPermissions::Ptr permissions; /** - * @brief Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user. + * @brief Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds. * Returned only in Api::getChat. */ std::int32_t slowModeDelay; /** - * @brief Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. + * @brief Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. * Returned only in Api::getChat. */ std::int32_t messageAutoDeleteTime; @@ -137,21 +149,19 @@ public: /** * @brief Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. + * Returned only in Api::getChat. * * This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. * But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. - * - * Returned only in Api::getChat. */ std::int64_t linkedChatId; /** * @brief Optional. For supergroups, the location to which the supergroup is connected. - * * Returned only in Api::getChat. */ ChatLocation::Ptr location; }; } -#endif //TGBOT_CPP_CHAT_H +#endif //TGBOT_CHAT_H diff --git a/include/tgbot/types/Document.h b/include/tgbot/types/Document.h index 71f4f3c..0593076 100644 --- a/include/tgbot/types/Document.h +++ b/include/tgbot/types/Document.h @@ -1,11 +1,11 @@ -#ifndef TGBOT_CPP_DOCUMENT_H -#define TGBOT_CPP_DOCUMENT_H +#ifndef TGBOT_DOCUMENT_H +#define TGBOT_DOCUMENT_H #include "tgbot/types/PhotoSize.h" #include <cstdint> -#include <string> #include <memory> +#include <string> namespace TgBot { @@ -46,10 +46,13 @@ public: std::string mimeType; /** - * @brief Optional. File size + * @brief Optional. File size in bytes. + * + * It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. + * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value. */ - std::int32_t fileSize; + std::int64_t fileSize; }; } -#endif //TGBOT_CPP_DOCUMENT_H +#endif //TGBOT_DOCUMENT_H diff --git a/include/tgbot/types/File.h b/include/tgbot/types/File.h index e684528..e923881 100644 --- a/include/tgbot/types/File.h +++ b/include/tgbot/types/File.h @@ -1,18 +1,19 @@ -#ifndef TGBOT_CPP_FILE_H -#define TGBOT_CPP_FILE_H +#ifndef TGBOT_FILE_H +#define TGBOT_FILE_H #include <cstdint> -#include <string> #include <memory> +#include <string> namespace TgBot { /** * @brief This object represents a file ready to be downloaded. - * The file can be downloaded via @ref Api::downloadFile. - * It is guaranteed that the @ref File::filePath will be valid for at least 1 hour. - * When the @ref File::filePath expires, a new one can be requested by calling @ref Api::getFile. - * Maximum file size to download is 20 MB + * The file can be downloaded via Api::downloadFile. + * It is guaranteed that the File::filePath will be valid for at least 1 hour. + * When the File::filePath expires, a new one can be requested by calling Api::getFile. + * + * The maximum file size to download is 20 MB * * @ingroup types */ @@ -33,16 +34,19 @@ public: std::string fileUniqueId; /** - * @brief Optional. File size, if known + * @brief Optional. File size in bytes. + * + * It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. + * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value. */ - std::int32_t fileSize; + std::int64_t fileSize; /** * @brief Optional. File path. - * Use @ref Api::downloadFile to get the file. + * Use Api::downloadFile to get the file. */ std::string filePath; }; } -#endif //TGBOT_CPP_FILE_H +#endif //TGBOT_FILE_H diff --git a/include/tgbot/types/InlineKeyboardButton.h b/include/tgbot/types/InlineKeyboardButton.h index 36f150d..f216669 100644 --- a/include/tgbot/types/InlineKeyboardButton.h +++ b/include/tgbot/types/InlineKeyboardButton.h @@ -26,7 +26,7 @@ public: std::string text; /** - * @brief Optional. HTTP or tg:// url to be opened when the 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; @@ -44,25 +44,25 @@ public: WebAppInfo::Ptr webApp; /** - * @brief Optional. An HTTP URL used to automatically authorize the user. + * @brief Optional. An HTTPS URL used to automatically authorize the user. * Can be used as a replacement for the Telegram Login Widget. */ LoginUrl::Ptr loginUrl; /** * @brief Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. - * Can be empty, in which case just the bot's username will be inserted. + * May be empty, in which case just the bot's username will be inserted. * * Note: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. - * Especially useful when combined with switch_pm… actions – in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen. + * 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. + * May be empty, in which case only the bot's username will be inserted. * - * This offers a quick way for the user to open your bot in inline mode in the same chat – good for selecting something from multiple options. + * 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; diff --git a/include/tgbot/types/Sticker.h b/include/tgbot/types/Sticker.h index 2dd35fa..0d14ba4 100644 --- a/include/tgbot/types/Sticker.h +++ b/include/tgbot/types/Sticker.h @@ -1,12 +1,13 @@ -#ifndef TGBOT_CPP_STICKER_H -#define TGBOT_CPP_STICKER_H +#ifndef TGBOT_STICKER_H +#define TGBOT_STICKER_H #include "tgbot/types/PhotoSize.h" +#include "tgbot/types/File.h" #include "tgbot/types/MaskPosition.h" #include <cstdint> -#include <string> #include <memory> +#include <string> namespace TgBot { @@ -67,6 +68,11 @@ public: std::string setName; /** + * @brief Optional. Premium animation for the sticker, if the sticker is premium + */ + File::Ptr premiumAnimation; + + /** * @brief Optional. For mask stickers, the position where the mask should be placed */ MaskPosition::Ptr maskPosition; @@ -78,4 +84,4 @@ public: }; } -#endif //TGBOT_CPP_STICKER_H +#endif //TGBOT_STICKER_H diff --git a/include/tgbot/types/User.h b/include/tgbot/types/User.h index 629ee6c..328c0a2 100644 --- a/include/tgbot/types/User.h +++ b/include/tgbot/types/User.h @@ -1,5 +1,5 @@ -#ifndef TGBOT_CPP_USER_H -#define TGBOT_CPP_USER_H +#ifndef TGBOT_USER_H +#define TGBOT_USER_H #include <cstdint> #include <string> @@ -18,7 +18,10 @@ public: typedef std::shared_ptr<User> Ptr; /** - * @brief Unique identifier for this user or bot + * @brief Unique identifier for this user or bot. + * + * This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. + * But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. */ std::int64_t id; @@ -28,17 +31,17 @@ public: bool isBot; /** - * @brief User‘s or bot’s first name + * @brief User's or bot's first name */ std::string firstName; /** - * @brief Optional. User‘s or bot’s last name + * @brief Optional. User's or bot's last name */ std::string lastName; /** - * @brief Optional. User‘s or bot’s username + * @brief Optional. User's or bot's username */ std::string username; @@ -48,23 +51,33 @@ public: std::string languageCode; /** + * @brief Optional. True, if this user is a Telegram Premium user + */ + bool isPremium; + + /** + * @brief Optional. True, if this user added the bot to the attachment menu + */ + bool addedToAttachmentMenu; + + /** * @brief Optional. True, if the bot can be invited to groups. - * Returned only in @ref Api::getMe. + * Returned only in Api::getMe. */ bool canJoinGroups; /** * @brief Optional. True, if privacy mode is disabled for the bot. - * Returned only in @ref Api::getMe. + * Returned only in Api::getMe. */ bool canReadAllGroupMessages; /** * @brief Optional. True, if the bot supports inline queries. - * Returned only in @ref Api::getMe. + * Returned only in Api::getMe. */ bool supportsInlineQueries; }; } -#endif //TGBOT_CPP_USER_H +#endif //TGBOT_USER_H diff --git a/include/tgbot/types/Video.h b/include/tgbot/types/Video.h index c1328b5..95590ad 100644 --- a/include/tgbot/types/Video.h +++ b/include/tgbot/types/Video.h @@ -1,11 +1,11 @@ -#ifndef TGBOT_CPP_VIDEO_H -#define TGBOT_CPP_VIDEO_H +#ifndef TGBOT_VIDEO_H +#define TGBOT_VIDEO_H #include "tgbot/types/PhotoSize.h" #include <cstdint> -#include <string> #include <memory> +#include <string> namespace TgBot { @@ -61,10 +61,13 @@ public: std::string mimeType; /** - * @brief Optional. File size + * @brief Optional. File size in bytes. + * + * It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. + * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value. */ - std::int32_t fileSize; + std::int64_t fileSize; }; } -#endif //TGBOT_CPP_VIDEO_H +#endif //TGBOT_VIDEO_H diff --git a/include/tgbot/types/Voice.h b/include/tgbot/types/Voice.h index c337b0a..763ffae 100644 --- a/include/tgbot/types/Voice.h +++ b/include/tgbot/types/Voice.h @@ -38,9 +38,12 @@ public: std::string mimeType; /** - * @brief Optional. File size + * @brief Optional. File size in bytes. + * + * It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. + * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value. */ - std::int32_t fileSize; + std::int64_t fileSize; }; } |