diff options
author | Oleg Morozenkov <m@oleg.rocks> | 2018-07-23 01:56:42 +0300 |
---|---|---|
committer | Oleg Morozenkov <m@oleg.rocks> | 2018-07-23 01:56:42 +0300 |
commit | d47ee877be5d1175bdc36f2d87881ddaf875a8e9 (patch) | |
tree | 7fd20cdc1236fe6b832ae980de12afd7071ebab9 /include/tgbot | |
parent | cea20d4078f2088dea0dd589f1cc9dd7ee22461b (diff) |
Refactor http clients, fix webhook server, add more samples, change tabs to 4 spaces
Diffstat (limited to 'include/tgbot')
88 files changed, 3481 insertions, 3248 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index 7dd5b92..0a781e6 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -28,6 +28,8 @@ #include <boost/property_tree/ptree.hpp> +#include "tgbot/TgTypeParser.h" +#include "tgbot/net/HttpClient.h" #include "tgbot/net/HttpReqArg.h" #include "tgbot/types/User.h" #include "tgbot/types/Message.h" @@ -49,7 +51,6 @@ namespace TgBot { class Bot; -class HttpClient; /** * @brief This class executes telegram api methods. Telegram docs: <https://core.telegram.org/bots/api#available-methods> @@ -63,336 +64,336 @@ typedef std::shared_ptr<std::vector<std::string>> StringArrayPtr; friend class Bot; public: - Api(const std::string& token, const HttpClient& httpClientDriver); - - /** - * @brief A simple method for testing your bot's auth token. - * @return Basic information about the bot in form of a User object. - */ - User::Ptr getMe() const; - - /** - * @brief Use this method to send text messages. - * @param chatId Unique identifier for the target chat. - * @param text Text of the message to be sent. - * @param disableWebPagePreview Optional. Disables link previews for links in this message. - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. - * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr sendMessage(int64_t chatId, const std::string& text, bool disableWebPagePreview = false, int32_t replyToMessageId = 0, - const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; - - /** - * @brief Use this method to forward messages of any kind. - * @param chatId Unique identifier for the target chat. - * @param fromChatId Unique identifier for the chat where the original message was sent — User or GroupChat id. - * @param messageId Unique message identifier. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr forwardMessage(int64_t chatId, int64_t fromChatId, int32_t messageId, bool disableNotification = false) const; - - /** - * @brief Use this method to send photos. - * @param chatId Unique identifier for the target chat. - * @param photo Photo to send. - * @param caption Optional. Photo caption. - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. - * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr sendPhoto(int64_t chatId, const InputFile::Ptr photo, const std::string& caption = "", int32_t replyToMessageId = 0, - const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; - - /** - * @brief Use this method to send photos. - * @param chatId Unique identifier for the target chat. - * @param photo Photo to send. Id of the photo that is already on the Telegram servers. - * @param caption Optional. Photo caption. - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. - * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr sendPhoto(int64_t chatId, const std::string& photoId, const std::string& caption = "", int32_t replyToMessageId = 0, - const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; - - /** - * @brief Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Document). - * @param chatId Unique identifier for the target chat. - * @param audio Audio to send. - * @param caption Audio caption, 0-200 characters - * @param duration Duration of sent audio in seconds. - * @param performer Performer - * @param title Track name - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. - * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr sendAudio(int64_t chatId, const InputFile::Ptr audio, const std::string &caption = "", int32_t duration = 0, - const std::string& performer = "", const std::string& title = "", int32_t replyToMessageId = 0, - const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; - - /** - * @brief Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Document). - * @param chatId Unique identifier for the target chat. - * @param audio Id of the audio that is already on the Telegram servers. - * @param caption Audio caption, 0-200 characters - * @param duration Duration of sent audio in seconds. - * @param performer Performer - * @param title Track name - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. - * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr sendAudio(int64_t chatId, const std::string& audioId, const std::string &caption = "", int32_t duration = 0, - const std::string& performer = "", const std::string& title = "", int32_t replyToMessageId = 0, - const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; - - /** - * @brief Use this method to send general files. - * @param chatId Unique identifier for the target chat. - * @param document Document to send. - * @param caption Document caption (may also be used when resending documents by file_id), 0-200 characters - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. - * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr sendDocument(int64_t chatId, const InputFile::Ptr document, const std::string &caption = "", int32_t replyToMessageId = 0, - const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; - - /** - * @brief Use this method to send general files. - * @param chatId Unique identifier for the target chat. - * @param document Id of the document that is already on the Telegram servers. - * @param caption Document caption (may also be used when resending documents by file_id), 0-200 characters - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. - * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr sendDocument(int64_t chatId, const std::string& documentId, const std::string &caption = "", int32_t replyToMessageId = 0, - const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; - - /** - * @brief Use this method to send invoices. - * @param chatId Unique identifier for the target private chat. - * @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 Payments provider token, obtained via Botfather. - * @param startParameter Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter. - * @param currency Three-letter ISO 4217 currency code. - * @param prices Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) - * @param providerData Optional. JSON-encoded 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. People like it better when they see what they are paying for. - * @param photoSize Optional. Photo size - * @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 user's phone number should be sent to provider. - * @param sendEmailToProvider Optional. Pass True, if user's email address should be sent to provider - * @param isFlexible Optional. Pass True, if the final price depends on the shipping method. - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button. - * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. - * @return On success, the sent Message is returned. - */ - Message::Ptr sendInvoice(int64_t chatId, const std::string& title, const std::string& description, const std::string& payload, - const std::string& providerToken, const std::string& startParameter, const std::string& currency, const std::vector<LabeledPrice::Ptr>& prices, - const std::string& providerData = "", const std::string& photoUrl = "", int32_t photoSize = 0, - int32_t photoWidth = 0, 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, - int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = 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. - * - * @param shippingQueryId Unique identifier for the query to be answered. - * @param ok Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible) - * @param shippingOptions Optional. Required if ok is True. A JSON-serialized array of available shipping options. - * @param errorMessage Optional. Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user. - * @return On success, True is returned. - */ - bool answerShippingQuery(const std::string& shippingQueryId, bool ok, const std::vector<ShippingOption::Ptr>& shippingOptions = std::vector<ShippingOption::Ptr>(), const std::string& errorMessage = "") const; - - /** - * @brief Use this method to respond to such pre-checkout queries. - * - * Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field preCheckoutQuery. - * Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. - * - * @param preCheckoutQueryId Unique identifier for the query to be answered - * @param ok Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems. - * @param errorMessage Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user. - * @return On success, True is returned. - */ - bool answerPreCheckoutQuery(const std::string& preCheckoutQueryId, bool ok, const std::string& errorMessage = "") const; - - /** - * @brief Use this method to send .webp stickers. - * @param chatId Unique identifier for the target chat. - * @param sticker Sticker to send. - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr sendSticker(int64_t chatId, const InputFile::Ptr sticker, int32_t replyToMessageId = 0, - const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const; - - /** - * @brief Use this method to send .webp stickers. - * @param chatId Unique identifier for the target chat. - * @param stickerId Id of the sticker that is already on the Telegram servers. - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr sendSticker(int64_t chatId, const std::string& stickerId, int32_t replyToMessageId = 0, - const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const; - - /** - * @brief Use this method to get a sticker set. - * @param chatId Name of the sticker set. - * @return On success, a StickerSet object is returned. - */ - StickerSet::Ptr getStickerSet(const std::string& name) const; - - /** - * @brief Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). - * @param userId User identifier of sticker file owner. - * @param pngSticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. - * @return Returns the uploaded File on success. - */ - File::Ptr uploadStickerFile(int32_t userId, const InputFile::Ptr pngSticker) const; - - /** - * @brief Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. - * @param userId User identifier of created sticker set owner. - * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters. - * @param title Sticker set title, 1-64 characters. - * @param pngSticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. - * @param emojis One or more emoji corresponding to the sticker. - * @param containsMasks Optional. Pass True, if a set of mask stickers should be created. - * @param maskPosition Optional. A JSON-serialized object for position where the mask should be placed on faces. - * @return Returns True on success. - */ - bool createNewStickerSet(int32_t userId, const std::string& name, const std::string& title, - InputFile::Ptr pngSticker, const std::string& emojis, bool containsMasks = false, MaskPosition::Ptr maskPosition = nullptr) const; - - /** - * @brief Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. - * @param userId User identifier of created sticker set owner. - * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters. - * @param title Sticker set title, 1-64 characters. - * @param pngSticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet. - * @param emojis One or more emoji corresponding to the sticker. - * @param containsMasks Optional. Pass True, if a set of mask stickers should be created. - * @param maskPosition Optional. A JSON-serialized object for position where the mask should be placed on faces. - * @return Returns True on success. - */ - bool createNewStickerSet(int32_t userId, const std::string& name, const std::string& title, - const std::string& pngSticker, const std::string& emojis, bool containsMasks = false, MaskPosition::Ptr maskPosition = nullptr) const; - - /** - * @brief Use this method to add a new sticker to a set created by the bot. - * @param userId User identifier of created sticker set owner. - * @param name Sticker set name. - * @param title Sticker set title, 1-64 characters. - * @param pngSticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. - * @param emojis One or more emoji corresponding to the sticker. - * @param maskPosition Optional. A JSON-serialized object for position where the mask should be placed on faces. - * @return Returns True on success. - */ - bool addStickerToSet(int32_t userId, const std::string& name, const std::string& title, - InputFile::Ptr pngSticker, const std::string& emojis, MaskPosition::Ptr maskPosition = nullptr) const; - - /** - * @brief Use this method to add a new sticker to a set created by the bot. - * @param userId User identifier of created sticker set owner. - * @param name Sticker set name. - * @param title Sticker set title, 1-64 characters. - * @param pngSticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet. - * @param emojis One or more emoji corresponding to the sticker. - * @param maskPosition Optional. A JSON-serialized object for position where the mask should be placed on faces. - * @return Returns True on success. - */ - bool addStickerToSet(int32_t userId, const std::string& name, const std::string& title, - const std::string& pngSticker, const std::string& emojis, MaskPosition::Ptr maskPosition = nullptr) const; - - /** - * @brief Use this method to move a sticker in a set created by the bot to a specific position. - * @param stickers File identifier of the sticker. - * @param position New sticker position in the set, zero-based. - * @return Returns True on success. - */ - bool setStickerPositionInSet(const std::string& sticker, uint32_t position) const; - - /** - * @brief Use this method to delete a sticker from a set created by the bot. - * @param stickers File identifier of the sticker. - * @return Returns True on success. - */ - bool deleteStickerPositionInSet(const std::string& sticker) const; - - /** - * @brief Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). - * @param chatId Unique identifier for the target chat. - * @param video Video to send. - * @param supportsStreaming Optional. Pass True, if the uploaded video is suitable for streaming. - * @param duration Optional. Duration of sent video in seconds - * @param width Optional. Video width - * @param height Optional. Video height - * @param caption Optional. Video caption (may also be used when resending videos by file_id), 0-200 characters - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. - * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr sendVideo(int64_t chatId, const InputFile::Ptr video, bool supportsStreaming = false, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const std::string& caption = "", - int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; - - /** - * @brief Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). - * @param chatId Unique identifier for the target chat. - * @param videoId Id of the video that is already on the Telegram servers. - * @param supportsStreaming Optional. Pass True, if the uploaded video is suitable for streaming. - * @param duration Optional. Duration of sent video in seconds - * @param width Optional. Video width - * @param height Optional. Video height - * @param caption Optional. Video caption (may also be used when resending videos by file_id), 0-200 characters - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. - * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr sendVideo(int64_t chatId, const std::string& videoId, bool supportsStreaming = false, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const std::string& caption = "", - int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; - - /** + Api(std::string token, const HttpClient& httpClient); + + /** + * @brief A simple method for testing your bot's auth token. + * @return Basic information about the bot in form of a User object. + */ + User::Ptr getMe() const; + + /** + * @brief Use this method to send text messages. + * @param chatId Unique identifier for the target chat. + * @param text Text of the message to be sent. + * @param disableWebPagePreview Optional. Disables link previews for links in this message. + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr sendMessage(int64_t chatId, const std::string& text, bool disableWebPagePreview = false, int32_t replyToMessageId = 0, + GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; + + /** + * @brief Use this method to forward messages of any kind. + * @param chatId Unique identifier for the target chat. + * @param fromChatId Unique identifier for the chat where the original message was sent — User or GroupChat id. + * @param messageId Unique message identifier. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr forwardMessage(int64_t chatId, int64_t fromChatId, int32_t messageId, bool disableNotification = false) const; + + /** + * @brief Use this method to send photos. + * @param chatId Unique identifier for the target chat. + * @param photo Photo to send. + * @param caption Optional. Photo caption. + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr sendPhoto(int64_t chatId, InputFile::Ptr photo, const std::string& caption = "", int32_t replyToMessageId = 0, + GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; + + /** + * @brief Use this method to send photos. + * @param chatId Unique identifier for the target chat. + * @param photo Photo to send. Id of the photo that is already on the Telegram servers. + * @param caption Optional. Photo caption. + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr sendPhoto(int64_t chatId, const std::string& photoId, const std::string& caption = "", int32_t replyToMessageId = 0, + GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; + + /** + * @brief Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Document). + * @param chatId Unique identifier for the target chat. + * @param audio Audio to send. + * @param caption Audio caption, 0-200 characters + * @param duration Duration of sent audio in seconds. + * @param performer Performer + * @param title Track name + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr sendAudio(int64_t chatId, InputFile::Ptr audio, const std::string &caption = "", int32_t duration = 0, + const std::string& performer = "", const std::string& title = "", int32_t replyToMessageId = 0, + GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; + + /** + * @brief Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Document). + * @param chatId Unique identifier for the target chat. + * @param audio Id of the audio that is already on the Telegram servers. + * @param caption Audio caption, 0-200 characters + * @param duration Duration of sent audio in seconds. + * @param performer Performer + * @param title Track name + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr sendAudio(int64_t chatId, const std::string& audioId, const std::string &caption = "", int32_t duration = 0, + const std::string& performer = "", const std::string& title = "", int32_t replyToMessageId = 0, + GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; + + /** + * @brief Use this method to send general files. + * @param chatId Unique identifier for the target chat. + * @param document Document to send. + * @param caption Document caption (may also be used when resending documents by file_id), 0-200 characters + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr sendDocument(int64_t chatId, InputFile::Ptr document, const std::string &caption = "", int32_t replyToMessageId = 0, + GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; + + /** + * @brief Use this method to send general files. + * @param chatId Unique identifier for the target chat. + * @param document Id of the document that is already on the Telegram servers. + * @param caption Document caption (may also be used when resending documents by file_id), 0-200 characters + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr sendDocument(int64_t chatId, const std::string& documentId, const std::string &caption = "", int32_t replyToMessageId = 0, + GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; + + /** + * @brief Use this method to send invoices. + * @param chatId Unique identifier for the target private chat. + * @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 Payments provider token, obtained via Botfather. + * @param startParameter Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter. + * @param currency Three-letter ISO 4217 currency code. + * @param prices Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) + * @param providerData Optional. JSON-encoded 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. People like it better when they see what they are paying for. + * @param photoSize Optional. Photo size + * @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 user's phone number should be sent to provider. + * @param sendEmailToProvider Optional. Pass True, if user's email address should be sent to provider + * @param isFlexible Optional. Pass True, if the final price depends on the shipping method. + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button. + * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. + * @return On success, the sent Message is returned. + */ + Message::Ptr sendInvoice(int64_t chatId, const std::string& title, const std::string& description, const std::string& payload, + const std::string& providerToken, const std::string& startParameter, const std::string& currency, const std::vector<LabeledPrice::Ptr>& prices, + const std::string& providerData = "", const std::string& photoUrl = "", int32_t photoSize = 0, + int32_t photoWidth = 0, 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, + int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = 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. + * + * @param shippingQueryId Unique identifier for the query to be answered. + * @param ok Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible) + * @param shippingOptions Optional. Required if ok is True. A JSON-serialized array of available shipping options. + * @param errorMessage Optional. Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user. + * @return On success, True is returned. + */ + bool answerShippingQuery(const std::string& shippingQueryId, bool ok, const std::vector<ShippingOption::Ptr>& shippingOptions = std::vector<ShippingOption::Ptr>(), const std::string& errorMessage = "") const; + + /** + * @brief Use this method to respond to such pre-checkout queries. + * + * Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field preCheckoutQuery. + * Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. + * + * @param preCheckoutQueryId Unique identifier for the query to be answered + * @param ok Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems. + * @param errorMessage Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user. + * @return On success, True is returned. + */ + bool answerPreCheckoutQuery(const std::string& preCheckoutQueryId, bool ok, const std::string& errorMessage = "") const; + + /** + * @brief Use this method to send .webp stickers. + * @param chatId Unique identifier for the target chat. + * @param sticker Sticker to send. + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr sendSticker(int64_t chatId, InputFile::Ptr sticker, int32_t replyToMessageId = 0, + GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const; + + /** + * @brief Use this method to send .webp stickers. + * @param chatId Unique identifier for the target chat. + * @param stickerId Id of the sticker that is already on the Telegram servers. + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr sendSticker(int64_t chatId, const std::string& stickerId, int32_t replyToMessageId = 0, + GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const; + + /** + * @brief Use this method to get a sticker set. + * @param chatId Name of the sticker set. + * @return On success, a StickerSet object is returned. + */ + StickerSet::Ptr getStickerSet(const std::string& name) const; + + /** + * @brief Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). + * @param userId User identifier of sticker file owner. + * @param pngSticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. + * @return Returns the uploaded File on success. + */ + File::Ptr uploadStickerFile(int32_t userId, InputFile::Ptr pngSticker) const; + + /** + * @brief Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. + * @param userId User identifier of created sticker set owner. + * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters. + * @param title Sticker set title, 1-64 characters. + * @param pngSticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. + * @param emojis One or more emoji corresponding to the sticker. + * @param containsMasks Optional. Pass True, if a set of mask stickers should be created. + * @param maskPosition Optional. A JSON-serialized object for position where the mask should be placed on faces. + * @return Returns True on success. + */ + bool createNewStickerSet(int32_t userId, const std::string& name, const std::string& title, + InputFile::Ptr pngSticker, const std::string& emojis, bool containsMasks = false, MaskPosition::Ptr maskPosition = nullptr) const; + + /** + * @brief Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. + * @param userId User identifier of created sticker set owner. + * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters. + * @param title Sticker set title, 1-64 characters. + * @param pngSticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet. + * @param emojis One or more emoji corresponding to the sticker. + * @param containsMasks Optional. Pass True, if a set of mask stickers should be created. + * @param maskPosition Optional. A JSON-serialized object for position where the mask should be placed on faces. + * @return Returns True on success. + */ + bool createNewStickerSet(int32_t userId, const std::string& name, const std::string& title, + const std::string& pngSticker, const std::string& emojis, bool containsMasks = false, MaskPosition::Ptr maskPosition = nullptr) const; + + /** + * @brief Use this method to add a new sticker to a set created by the bot. + * @param userId User identifier of created sticker set owner. + * @param name Sticker set name. + * @param title Sticker set title, 1-64 characters. + * @param pngSticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. + * @param emojis One or more emoji corresponding to the sticker. + * @param maskPosition Optional. A JSON-serialized object for position where the mask should be placed on faces. + * @return Returns True on success. + */ + bool addStickerToSet(int32_t userId, const std::string& name, const std::string& title, + InputFile::Ptr pngSticker, const std::string& emojis, MaskPosition::Ptr maskPosition = nullptr) const; + + /** + * @brief Use this method to add a new sticker to a set created by the bot. + * @param userId User identifier of created sticker set owner. + * @param name Sticker set name. + * @param title Sticker set title, 1-64 characters. + * @param pngSticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet. + * @param emojis One or more emoji corresponding to the sticker. + * @param maskPosition Optional. A JSON-serialized object for position where the mask should be placed on faces. + * @return Returns True on success. + */ + bool addStickerToSet(int32_t userId, const std::string& name, const std::string& title, + const std::string& pngSticker, const std::string& emojis, MaskPosition::Ptr maskPosition = nullptr) const; + + /** + * @brief Use this method to move a sticker in a set created by the bot to a specific position. + * @param stickers File identifier of the sticker. + * @param position New sticker position in the set, zero-based. + * @return Returns True on success. + */ + bool setStickerPositionInSet(const std::string& sticker, uint32_t position) const; + + /** + * @brief Use this method to delete a sticker from a set created by the bot. + * @param stickers File identifier of the sticker. + * @return Returns True on success. + */ + bool deleteStickerPositionInSet(const std::string& sticker) const; + + /** + * @brief Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). + * @param chatId Unique identifier for the target chat. + * @param video Video to send. + * @param supportsStreaming Optional. Pass True, if the uploaded video is suitable for streaming. + * @param duration Optional. Duration of sent video in seconds + * @param width Optional. Video width + * @param height Optional. Video height + * @param caption Optional. Video caption (may also be used when resending videos by file_id), 0-200 characters + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr sendVideo(int64_t chatId, InputFile::Ptr video, bool supportsStreaming = false, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const std::string& caption = "", + int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; + + /** + * @brief Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). + * @param chatId Unique identifier for the target chat. + * @param videoId Id of the video that is already on the Telegram servers. + * @param supportsStreaming Optional. Pass True, if the uploaded video is suitable for streaming. + * @param duration Optional. Duration of sent video in seconds + * @param width Optional. Video width + * @param height Optional. Video height + * @param caption Optional. Video caption (may also be used when resending videos by file_id), 0-200 characters + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr sendVideo(int64_t chatId, const std::string& videoId, bool supportsStreaming = false, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const std::string& caption = "", + int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; + + /** * @brief Use this method to send video messages. On success, the sent Message is returned. * @param chatId Unique identifier for the target chat. * @param videoNote Video note to send. @@ -403,8 +404,8 @@ public: * @param replyMarkup Additional interface options. A object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. * @return On success, the sent Message is returned. */ - Message::Ptr sendVideoNote(int64_t chatId, const InputFile::Ptr videoNote, int64_t replyToMessageId = 0, bool disableNotification = false, - int32_t duration = 0, int32_t length = 0, const GenericReply::Ptr replyMarkup = GenericReply::Ptr()); + Message::Ptr sendVideoNote(int64_t chatId, InputFile::Ptr videoNote, int64_t replyToMessageId = 0, bool disableNotification = false, + int32_t duration = 0, int32_t length = 0, GenericReply::Ptr replyMarkup = GenericReply::Ptr()); /** * @brief Use this method to send video messages. On success, the sent Message is returned. @@ -418,480 +419,481 @@ public: * @return On success, the sent Message is returned. */ Message::Ptr sendVideoNote(int64_t chatId, const std::string& videoNote, int64_t replyToMessageId = 0, bool disableNotification = false, - int32_t duration = 0, int32_t length = 0, const GenericReply::Ptr replyMarkup = GenericReply::Ptr()); - - /** - * @brief Use this method to send a group of photos or videos as an album. - * @param chatId Unique identifier for the target chat of the target channel. - * @param media A JSON-serialized array describing photos and videos to be sent, must include 2–10 items. - * @param disableNotification Optional. Sends the messages silently. Users will receive a notification with no sound. - * @param replyToMessageId Optional. If the messages are a reply, ID of the original message. - * @return On success, an array of the sent Messages is returned. - */ - std::vector<Message::Ptr> sendMediaGroup(int64_t chatId, const std::vector<InputMedia::Ptr>& media, - bool disableNotification = false, int32_t replyToMessageId = 0) const; - - /** - * @brief Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. - * @param chatId Unique identifier for the target chat. - * @param voice Audio file to send. - * @param caption Voice message caption, 0-200 characters - * @param duration Duration of send audio in seconds. - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. - * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr sendVoice(int64_t chatId, const InputFile::Ptr voice, const std::string& caption = "", int duration = 0, int32_t replyToMessageId = 0, - const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; - - /** - * @brief Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. - * @param chatId Unique identifier for the target chat. - * @param voiceId Id of the voice that is already on the Telegram servers. - * @param caption Voice message caption, 0-200 characters - * @param duration Duration of send audio in seconds. - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. - * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr sendVoice(int64_t chatId, const std::string& voiceId, const std::string& caption = "", int duration = 0, int32_t replyToMessageId = 0, - const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; - - /** - * @brief Use this method to send a game. - * @param chatId Unique identifier for the target chat. - * @param gameShortName Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather. - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. A JSON-serialized object for an inline keyboard. If empty, one ‘Play game_title’ button will be shown. If not empty, the first button must launch the game. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr sendGame(int64_t chatId, const std::string& gameShortName, int32_t replyToMessageId = 0, - const InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>(), bool disableNotification = false) const; - - /** - * @brief Use this method to send point on the map. - * @param chatId Unique identifier for the target chat. - * @param latitude Latitude of location. - * @param longitude Longitude of location. - * @param livePeriod Optional. Period in seconds for which the location will be updated (see Live Locations, should be between 60 and 86400). - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr sendLocation(int64_t chatId, float latitude, float longitude, uint32_t livePeriod = 0, - int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const; - - /** - * @brief Use this method to edit live location messages sent by the bot or via the bot (for inline bots). - * @param latitude Latitude of new location. - * @param longitude Longitude of new location. - * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat of the target channel. - * @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the sent message. - * @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message. - * @param replyMarkup Optional. A JSON-serialized object for a new inline keyboard. - * @return On success, if the edited message was sent by the bot, the edited Message is returned, otherwise nullptr is returned. - */ - Message::Ptr editMessageLiveLocation(float latitude, float longitude, int64_t chatId = 0, int32_t messageId = 0, - int32_t inlineMessageId = 0, const InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>()) const; - - /** - * @brief Use this method to edit live location messages sent by the bot or via the bot (for inline bots). - * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat of the target channel. - * @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the sent message. - * @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message. - * @param replyMarkup Optional. A JSON-serialized object for a new inline keyboard. - * @return On success, if the edited message was sent by the bot, the edited Message is returned, otherwise nullptr is returned. - */ - Message::Ptr stopMessageLiveLocation(int64_t chatId = 0, int32_t messageId = 0, int32_t inlineMessageId = 0, - const InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>()) const; - - - /** - * @brief Use this method to send information about a venue. On success, the sent Message is returned. - * @param chatId Unique identifier for the target chat. - * @param latitude Latitude of location. - * @param longitude Longitude of location. - * @param title Name of the venue. - * @param address Address of the venue. - * @param foursquare_id Foursquare identifier of the venue. - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. - * @param disableNotification Optional. Sends the message silenty. - * @return On success, the sent message is returned. - */ - Message::Ptr sendVenue(int64_t chatId, float latitude, float longitude, const std::string& title, const std::string& address, const std::string& foursquareId = "", - bool disableNotification = false, int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const; - - /** - * @brief Use this method to send phone contacts. On success, the sent Message is returned. - * @param chatId Unique identifier for the target chat. - * @param phoneNumber Contact's phone number. - * @param firstName Contact's first name. - * @param lastName Contact's last name. - * @param disableNotification Optional. Sends the message silenty. - * @param replyToMessageId Optional. If the message is a reply, ID of the original message. - * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. - * @return On success, the sent message is returned. - */ - Message::Ptr sendContact(int64_t chatId, const std::string& phoneNumber, const std::string& firstName, const std::string& lastName = "", bool disableNotification = false, - int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const; - - /** - * @brief Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). - * - * Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot. - * We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive. - * - * @param chatId Unique identifier for the target chat. - * @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_audio or upload_audio for audio files, upload_document for general files, find_location for location data. - */ - void sendChatAction(int64_t chatId, const std::string& action) const; - - /** - * @brief Use this method to get a list of profile pictures for a user. - * @param userId Unique identifier of the target user. - * @param offset Optional. Sequential number of the first photo to be returned. By default, all photos are returned. - * @param limit Optional. Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100. - * @return A UserProfilePhotos object. - */ - UserProfilePhotos::Ptr getUserProfilePhotos(int32_t userId, int32_t offset = 0, int32_t limit = 100) const; - - /** - * @brief Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. - * @param fileId File identifier to get info about - * @return A File object. - */ - File::Ptr getFile(const std::string &fileId) const; - - /** - * @brief Use this method for your bot to leave a group, supergroup or channel. - * @param chatId Unique identifier for the target chat of the target supergroup or channel. - * @return True on success - */ - bool leaveChat(int64_t chatId) const; - - /** - * @brief Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success. - * @param chatId Unique identifier for the target chat of the target supergroup or channel. - * @return Chat object. - */ - Chat::Ptr getChat(int64_t chatId) const; - - /** - * @brief Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned. - * @param chatId Unique identifier for the target chat of the target supergroup or channel. - * @return ChatMember object. - */ - std::vector<ChatMember::Ptr> getChatAdministrators(int64_t chatId) const; - - /** - * @brief Use this method to get the number of members in a chat. Returns Int on success. - * @param chatId Unique identifier for the target chat of the target supergroup or channel. - * @return Int. - */ - int32_t getChatMembersCount(int64_t chatId) const; - - /** - * @brief Use this method to get information about a member of a chat. Returns a ChatMember object on success. - * @param chatId Unique identifier for the target chat of the target supergroup or channel. - * @param userId Unique identifier of the target user - * @return ChatMember object. - */ - ChatMember::Ptr getChatMember(int64_t chatId, int32_t userId) const; - - /** - * @brief Use this method to get information about a member of a chat. Returns a ChatMember object on success. - * @param chatId Unique identifier for the target chat of the target supergroup or channel. - * @param stickerSetName Name of the sticker set to be set as the group sticker set. - * @return Returns True on success. - */ - bool setChatStickerSet(int64_t chatId, const std::string& stickerSetName) const; - - /** - * @brief Use this method to get information about a member of a chat. Returns a ChatMember object on success. - * @param chatId Unique identifier for the target chat of the target supergroup or channel. - * @return Returns True on success. - */ - bool deleteChatStickerSet(int64_t chatId) const; - - - /** - * @brief Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. - * @param callbackQueryId Unique identifier for the query to be answered - * @param text Optional Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters - * @param showAlert Optional If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false. - * @param url Optional URL that will be opened by the user's client. If you have created a Game and accepted the conditions via @Botfather, specify the URL that opens your game – note that this will only work if the query comes from a callback_game button - * @param cacheTime Optional The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0. - * @return True on success - */ - bool answerCallbackQuery(const std::string & callbackQueryId, const std::string & text="", bool showAlert=false, const std::string &url="", int32_t cacheTime=0) const; - - /** - * @brief Use this method to edit text and game messages sent by the bot or via the bot (for inline bots) - * @param text New text of the message - * @param chatId Optional Required if inline_message_id is not specified. Unique identifier for the target chat of the target channel. - * @param messageId Optional Required if inline_message_id is not specified. Identifier of the sent message - * @param inlineMessageId Optional Required if chat_id and message_id are not specified. Identifier of the inline message - * @param parseMode Optional Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. - * @param disableWebPagePreview Optional Disables link previews for links in this message - * @param replyMarkup Optional A JSON-serialized object for an inline keyboard. - * @return Message object on success, otherwise nullptr - */ - Message::Ptr editMessageText(const std::string& text, int64_t chatId=0, int32_t messageId=0, const std::string& inlineMessageId="", - const std::string& parseMode = "", bool disableWebPagePreview = false, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const; - - /** - * @brief Use this method to edit captions of messages sent by the bot or via the bot (for inline bots). - * @param chatId Optional Required if inline_message_id is not specified. Unique identifier for the target chat of the target channel. - * @param messageId Optional Required if inline_message_id is not specified. Identifier of the sent message - * @param caption Optional New caption of the message - * @param inlineMessageId Optional Required if chat_id and message_id are not specified. Identifier of the inline message - * @param replyMarkup Optional A JSON-serialized object for an inline keyboard. - * @return Message object on success, otherwise nullptr - */ - Message::Ptr editMessageCaption(int64_t chatId = 0, int32_t messageId = 0, const std::string& caption = "", - const std::string& inlineMessageId = "", const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const; - - /** - * @brief Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). - * @param chatId Optional Required if inline_message_id is not specified. Unique identifier for the target chat of the target channel. - * @param messageId Optional Required if inline_message_id is not specified. Identifier of the sent message - * @param inlineMessageId Optional Required if chat_id and message_id are not specified. Identifier of the inline message - * @param replyMarkup Optional A JSON-serialized object for an inline keyboard. - * @return Message object on success, otherwise nullptr - */ - Message::Ptr editMessageReplyMarkup(int64_t chatId = 0, int32_t messageId = 0, const std::string& inlineMessageId = "", - const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const; - - /** - * @brief Use this method to delete messages sent by bot (or by other users if bot is admin). - * @param chatId Unique identifier for the target chat. - * @param messageId Unique identifier for the target message. - */ - void deleteMessage(int64_t chatId, int32_t messageId) const; - - /** - * @brief Use this method to receive incoming updates using long polling. - * - * This method will not work if an outgoing webhook is set up. - * In order to avoid getting duplicate updates, recalculate offset after each server response. - * - * @param offset Optional. Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. - * @param limit Optional. Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100. - * @param timeout Optional. Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. - * @param allowed_updates Optional. List the types of updates 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. - * @return An Array of Update objects - */ - std::vector<Update::Ptr> getUpdates(int32_t offset = 0, int32_t limit = 100, int32_t timeout = 0, 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 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. www.example.com/<token>. Since nobody else knows your bot‘s token, you can be pretty sure it’s us. - * You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up. - * We currently do not support self-signed certificates. - * Ports currently supported for Webhooks: 443, 80, 88, 8443. - * - * @param url Optional. HTTPS url to send updates to. Use an empty string to remove webhook integration. - */ - void setWebhook(const std::string& url = "", const InputFile::Ptr certificate = nullptr, int32_t maxConnection = 40, const StringArrayPtr &allowedUpdates = nullptr) const; - - /** - * @brief Use this method to remove webhook integration if you decide to switch back to getUpdates. - * - * Requires no parameters. - * - * @return Returns True on success. - */ - bool deleteWebhook() const; - - /** - * @brief Use this method to get current webhook status. - * - * Requires no parameters. - * If the bot is using getUpdates, will return an object with the url field empty. - * - * @return On success, returns a WebhookInfo object. - */ - WebhookInfo::Ptr getWebhookInfo() const; - - /** - * @brief Use this method to send answers to an inline query. - * No mode that 50 results per query are allowed. - * @param inlineQueryId Unique identifier for the answered query. - * @param results Array of results for the inline query. - * @param cacheTime The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300. - * @param isPersonal Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query. - * @param nextOffset Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes. - * @param switchPmText If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter - * @param switchPmParameter Parameter for the start message sent to the bot when user presses the switch button - * @return True on success - */ - bool answerInlineQuery(const std::string& inlineQueryId, const std::vector<InlineQueryResult::Ptr>& results, - 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 kick a user from a group or a supergroup. - * @param chatId Unique identifier for the target group. - * @param userId Unique identifier of the target user. - * @param untilDate Optional. Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. - * @return True on success - */ - bool kickChatMember(int64_t chatId, int32_t userId, uint64_t untilDate = 0) const; - - /** - * @brief Use this method to unban a previously kicked user in a supergroup. - * @param chatId Unique identifier for the target group. - * @param userId Unique identifier of the target user. - * @return True on success - */ - bool unbanChatMember(int64_t chatId, int32_t userId) const; - - /** - * @brief Use this method to restrict a user in a supergroup. - * @param chatId Unique identifier for the target chat of the target supergroup. - * @param userId Unique identifier of the target user. - * @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 canSendMessages Optional. Pass True, if the user can send text messages, contacts, locations and venues. - * @param canSendMediaMessages Optional. Pass True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages. - * @param canSendOtherMessages Optional. Pass True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages. - * @param canAddWebPagePreviews Optional. Pass True, if the user may add web page previews to their messages, implies can_send_media_messages. - * @return True on success - */ - bool restrictChatMember(int64_t chatId, int32_t userId, uint64_t untilDate = 0, bool canSendMessages = false, - bool canSendMediaMessages = false, bool canSendOtherMessages = false, bool canAddWebPagePreviews = false) const; - - /** - * @brief Use this method to promote or demote a user in a supergroup or a channel. - * @param chatId Unique identifier for the target chat of the target supergroup or channal. - * @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 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 canRestrictMembers Optional. Pass True, if the administrator can restrict, ban or unban chat members. - * @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 his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him). - * @return True on success - */ - bool promoteChatMember(int64_t chatId, int32_t userId, bool canChangeInfo = false, bool canPostMessages = false, - bool canEditMessages = false, bool canDeleteMessages = false, bool canInviteUsers = false, bool canPinMessages = false, bool canPromoteMembers = false) const; - - /** - * @brief Use this method to generate a new invite link for a chat; any previously generated link is revoked. - * @param chatId Unique identifier for the target chat. - * @return The new invite link as String on success. - */ - std::string exportChatInviteLink(int64_t chatId) const; - - /** - * @brief Use this method to set a new profile photo for the chat. - * - * Photos can't be changed for private chats. - * - * @param chatId Unique identifier for the target chat. - * @param photo New chat photo. - * @return True on success - */ - bool setChatPhoto(int64_t chatId, const InputFile::Ptr photo) const; - - /** - * @brief Use this method to delete a chat photo. - * - * Photos can't be changed for private chats. - * - * @param chatId Unique identifier for the target chat. - * @return True on success - */ - bool deleteChatPhoto(int64_t chatId) const; - - /** - * @brief Use this method to change the title of a chat. - * - * Titles can't be changed for private chats. - * - * @param chatId Unique identifier for the target chat. - * @param title New chat title, 1-255 characters. - * @return True on success - */ - bool setChatTitle(int64_t chatId, const std::string& title) const; - - /** - * @brief Use this method to change the description of a supergroup or a channel. - * @param chatId Unique identifier for the target chat. - * @param description New chat description, 1-255 characters. - * @return True on success - */ - bool setChatDescription(int64_t chatId, const std::string& description) const; - - /** - * @brief Use this method to pin a message in a supergroup or a channel. - * @param chatId Unique identifier for the target chat. - * @param messageId Identifier of a message to pin. - * @param disableNotification Optional. Pass True, if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels. - * @return True on success - */ - bool pinChatMessage(int64_t chatId, int32_t messageId, bool disableNotification = false) const; - - /** - * @brief Use this method to unpin a message in a supergroup or a channel. - * @param chatId Unique identifier for the target chat. - * @return True on success - */ - bool unpinChatMessage(int64_t chatId) const; - - /** - * @brief Use this method to set the score of the specified user in a game. - * - * Returns an error, if the new score is not greater than the user's current score in the chat and force is False. - * - * @param userId User identifier. - * @param score New score, must be non-negative. - * @param force Optional. Pass True, if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters. - * @param disableEditMessage Optional. Pass True, if the game message should not be automatically edited to include the current scoreboard. - * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat - * @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the sent message - * @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message - * @return On success, if the message was sent by the bot, returns the edited Message, otherwise returns nullptr. - */ - Message::Ptr setGameScore(int32_t userId, int32_t score, bool force = false, bool disableEditMessage = false, - int64_t chatId = 0, int32_t messageId = 0, const std::string& inlineMessageId = "") const; - - /** - * @brief Use this method to get data for high score tables. - * - * Will return the score of the specified user and several of his neighbors in a game. - * - * @param userId User identifier. - * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat - * @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the sent message - * @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message - * @return On success, returns an Array of GameHighScore objects. - */ - std::vector<GameHighScore::Ptr> getGameHighScores(int32_t userId, int32_t score, bool force = false, - bool disableEditMessage = false, int64_t chatId = 0, int32_t messageId = 0, const std::string& inlineMessageId = "") const; - - - /** - * @brief Downloads file from Telegram and saves it in memory. - * @param filePath Telegram file path. - * @param args Additional api parameters. - * @return File contents in a string. - */ - std::string downloadFile(const std::string& filePath, const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>()) const; + int32_t duration = 0, int32_t length = 0, GenericReply::Ptr replyMarkup = GenericReply::Ptr()); + + /** + * @brief Use this method to send a group of photos or videos as an album. + * @param chatId Unique identifier for the target chat of the target channel. + * @param media A JSON-serialized array describing photos and videos to be sent, must include 2–10 items. + * @param disableNotification Optional. Sends the messages silently. Users will receive a notification with no sound. + * @param replyToMessageId Optional. If the messages are a reply, ID of the original message. + * @return On success, an array of the sent Messages is returned. + */ + std::vector<Message::Ptr> sendMediaGroup(int64_t chatId, const std::vector<InputMedia::Ptr>& media, + bool disableNotification = false, int32_t replyToMessageId = 0) const; + + /** + * @brief Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. + * @param chatId Unique identifier for the target chat. + * @param voice Audio file to send. + * @param caption Voice message caption, 0-200 characters + * @param duration Duration of send audio in seconds. + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr sendVoice(int64_t chatId, InputFile::Ptr voice, const std::string& caption = "", int duration = 0, int32_t replyToMessageId = 0, + GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; + + /** + * @brief Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. + * @param chatId Unique identifier for the target chat. + * @param voiceId Id of the voice that is already on the Telegram servers. + * @param caption Voice message caption, 0-200 characters + * @param duration Duration of send audio in seconds. + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * @param parseMode Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr sendVoice(int64_t chatId, const std::string& voiceId, const std::string& caption = "", int duration = 0, int32_t replyToMessageId = 0, + GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; + + /** + * @brief Use this method to send a game. + * @param chatId Unique identifier for the target chat. + * @param gameShortName Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather. + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. A JSON-serialized object for an inline keyboard. If empty, one ‘Play game_title’ button will be shown. If not empty, the first button must launch the game. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr sendGame(int64_t chatId, const std::string& gameShortName, int32_t replyToMessageId = 0, + InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>(), bool disableNotification = false) const; + + /** + * @brief Use this method to send point on the map. + * @param chatId Unique identifier for the target chat. + * @param latitude Latitude of location. + * @param longitude Longitude of location. + * @param livePeriod Optional. Period in seconds for which the location will be updated (see Live Locations, should be between 60 and 86400). + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr sendLocation(int64_t chatId, float latitude, float longitude, uint32_t livePeriod = 0, + int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const; + + /** + * @brief Use this method to edit live location messages sent by the bot or via the bot (for inline bots). + * @param latitude Latitude of new location. + * @param longitude Longitude of new location. + * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat of the target channel. + * @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the sent message. + * @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message. + * @param replyMarkup Optional. A JSON-serialized object for a new inline keyboard. + * @return On success, if the edited message was sent by the bot, the edited Message is returned, otherwise nullptr is returned. + */ + Message::Ptr editMessageLiveLocation(float latitude, float longitude, int64_t chatId = 0, int32_t messageId = 0, + int32_t inlineMessageId = 0, InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>()) const; + + /** + * @brief Use this method to edit live location messages sent by the bot or via the bot (for inline bots). + * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat of the target channel. + * @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the sent message. + * @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message. + * @param replyMarkup Optional. A JSON-serialized object for a new inline keyboard. + * @return On success, if the edited message was sent by the bot, the edited Message is returned, otherwise nullptr is returned. + */ + Message::Ptr stopMessageLiveLocation(int64_t chatId = 0, int32_t messageId = 0, int32_t inlineMessageId = 0, + InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>()) const; + + + /** + * @brief Use this method to send information about a venue. On success, the sent Message is returned. + * @param chatId Unique identifier for the target chat. + * @param latitude Latitude of location. + * @param longitude Longitude of location. + * @param title Name of the venue. + * @param address Address of the venue. + * @param foursquare_id Foursquare identifier of the venue. + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * @param disableNotification Optional. Sends the message silenty. + * @return On success, the sent message is returned. + */ + Message::Ptr sendVenue(int64_t chatId, float latitude, float longitude, const std::string& title, const std::string& address, const std::string& foursquareId = "", + bool disableNotification = false, int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const; + + /** + * @brief Use this method to send phone contacts. On success, the sent Message is returned. + * @param chatId Unique identifier for the target chat. + * @param phoneNumber Contact's phone number. + * @param firstName Contact's first name. + * @param lastName Contact's last name. + * @param disableNotification Optional. Sends the message silenty. + * @param replyToMessageId Optional. If the message is a reply, ID of the original message. + * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * @return On success, the sent message is returned. + */ + Message::Ptr sendContact(int64_t chatId, const std::string& phoneNumber, const std::string& firstName, const std::string& lastName = "", bool disableNotification = false, + int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const; + + /** + * @brief Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). + * + * Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot. + * We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive. + * + * @param chatId Unique identifier for the target chat. + * @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_audio or upload_audio for audio files, upload_document for general files, find_location for location data. + */ + void sendChatAction(int64_t chatId, const std::string& action) const; + + /** + * @brief Use this method to get a list of profile pictures for a user. + * @param userId Unique identifier of the target user. + * @param offset Optional. Sequential number of the first photo to be returned. By default, all photos are returned. + * @param limit Optional. Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100. + * @return A UserProfilePhotos object. + */ + UserProfilePhotos::Ptr getUserProfilePhotos(int32_t userId, int32_t offset = 0, int32_t limit = 100) const; + + /** + * @brief Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. + * @param fileId File identifier to get info about + * @return A File object. + */ + File::Ptr getFile(const std::string &fileId) const; + + /** + * @brief Use this method for your bot to leave a group, supergroup or channel. + * @param chatId Unique identifier for the target chat of the target supergroup or channel. + * @return True on success + */ + bool leaveChat(int64_t chatId) const; + + /** + * @brief Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success. + * @param chatId Unique identifier for the target chat of the target supergroup or channel. + * @return Chat object. + */ + Chat::Ptr getChat(int64_t chatId) const; + + /** + * @brief Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned. + * @param chatId Unique identifier for the target chat of the target supergroup or channel. + * @return ChatMember object. + */ + std::vector<ChatMember::Ptr> getChatAdministrators(int64_t chatId) const; + + /** + * @brief Use this method to get the number of members in a chat. Returns Int on success. + * @param chatId Unique identifier for the target chat of the target supergroup or channel. + * @return Int. + */ + int32_t getChatMembersCount(int64_t chatId) const; + + /** + * @brief Use this method to get information about a member of a chat. Returns a ChatMember object on success. + * @param chatId Unique identifier for the target chat of the target supergroup or channel. + * @param userId Unique identifier of the target user + * @return ChatMember object. + */ + ChatMember::Ptr getChatMember(int64_t chatId, int32_t userId) const; + + /** + * @brief Use this method to get information about a member of a chat. Returns a ChatMember object on success. + * @param chatId Unique identifier for the target chat of the target supergroup or channel. + * @param stickerSetName Name of the sticker set to be set as the group sticker set. + * @return Returns True on success. + */ + bool setChatStickerSet(int64_t chatId, const std::string& stickerSetName) const; + + /** + * @brief Use this method to get information about a member of a chat. Returns a ChatMember object on success. + * @param chatId Unique identifier for the target chat of the target supergroup or channel. + * @return Returns True on success. + */ + bool deleteChatStickerSet(int64_t chatId) const; + + + /** + * @brief Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. + * @param callbackQueryId Unique identifier for the query to be answered + * @param text Optional Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters + * @param showAlert Optional If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false. + * @param url Optional URL that will be opened by the user's client. If you have created a Game and accepted the conditions via @Botfather, specify the URL that opens your game – note that this will only work if the query comes from a callback_game button + * @param cacheTime Optional The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0. + * @return True on success + */ + bool answerCallbackQuery(const std::string & callbackQueryId, const std::string & text="", bool showAlert=false, const std::string &url="", int32_t cacheTime=0) const; + + /** + * @brief Use this method to edit text and game messages sent by the bot or via the bot (for inline bots) + * @param text New text of the message + * @param chatId Optional Required if inline_message_id is not specified. Unique identifier for the target chat of the target channel. + * @param messageId Optional Required if inline_message_id is not specified. Identifier of the sent message + * @param inlineMessageId Optional Required if chat_id and message_id are not specified. Identifier of the inline message + * @param parseMode Optional Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. + * @param disableWebPagePreview Optional Disables link previews for links in this message + * @param replyMarkup Optional A JSON-serialized object for an inline keyboard. + * @return Message object on success, otherwise nullptr + */ + Message::Ptr editMessageText(const std::string& text, int64_t chatId=0, int32_t messageId=0, const std::string& inlineMessageId="", + const std::string& parseMode = "", bool disableWebPagePreview = false, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const; + + /** + * @brief Use this method to edit captions of messages sent by the bot or via the bot (for inline bots). + * @param chatId Optional Required if inline_message_id is not specified. Unique identifier for the target chat of the target channel. + * @param messageId Optional Required if inline_message_id is not specified. Identifier of the sent message + * @param caption Optional New caption of the message + * @param inlineMessageId Optional Required if chat_id and message_id are not specified. Identifier of the inline message + * @param replyMarkup Optional A JSON-serialized object for an inline keyboard. + * @return Message object on success, otherwise nullptr + */ + Message::Ptr editMessageCaption(int64_t chatId = 0, int32_t messageId = 0, const std::string& caption = "", + const std::string& inlineMessageId = "", GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const; + + /** + * @brief Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). + * @param chatId Optional Required if inline_message_id is not specified. Unique identifier for the target chat of the target channel. + * @param messageId Optional Required if inline_message_id is not specified. Identifier of the sent message + * @param inlineMessageId Optional Required if chat_id and message_id are not specified. Identifier of the inline message + * @param replyMarkup Optional A JSON-serialized object for an inline keyboard. + * @return Message object on success, otherwise nullptr + */ + Message::Ptr editMessageReplyMarkup(int64_t chatId = 0, int32_t messageId = 0, const std::string& inlineMessageId = "", + const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const; + + /** + * @brief Use this method to delete messages sent by bot (or by other users if bot is admin). + * @param chatId Unique identifier for the target chat. + * @param messageId Unique identifier for the target message. + */ + void deleteMessage(int64_t chatId, int32_t messageId) const; + + /** + * @brief Use this method to receive incoming updates using long polling. + * + * This method will not work if an outgoing webhook is set up. + * In order to avoid getting duplicate updates, recalculate offset after each server response. + * + * @param offset Optional. Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. + * @param limit Optional. Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100. + * @param timeout Optional. Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. + * @param allowed_updates Optional. List the types of updates 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. + * @return An Array of Update objects + */ + std::vector<Update::Ptr> getUpdates(int32_t offset = 0, int32_t limit = 100, int32_t timeout = 0, 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 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. www.example.com/<token>. Since nobody else knows your bot‘s token, you can be pretty sure it’s us. + * You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up. + * We currently do not support self-signed certificates. + * Ports currently supported for Webhooks: 443, 80, 88, 8443. + * + * @param url Optional. HTTPS url to send updates to. Use an empty string to remove webhook integration. + */ + void setWebhook(const std::string& url = "", InputFile::Ptr certificate = nullptr, int32_t maxConnection = 40, const StringArrayPtr &allowedUpdates = nullptr) const; + + /** + * @brief Use this method to remove webhook integration if you decide to switch back to getUpdates. + * + * Requires no parameters. + * + * @return Returns True on success. + */ + bool deleteWebhook() const; + + /** + * @brief Use this method to get current webhook status. + * + * Requires no parameters. + * If the bot is using getUpdates, will return an object with the url field empty. + * + * @return On success, returns a WebhookInfo object. + */ + WebhookInfo::Ptr getWebhookInfo() const; + + /** + * @brief Use this method to send answers to an inline query. + * No mode that 50 results per query are allowed. + * @param inlineQueryId Unique identifier for the answered query. + * @param results Array of results for the inline query. + * @param cacheTime The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300. + * @param isPersonal Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query. + * @param nextOffset Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes. + * @param switchPmText If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter + * @param switchPmParameter Parameter for the start message sent to the bot when user presses the switch button + * @return True on success + */ + bool answerInlineQuery(const std::string& inlineQueryId, const std::vector<InlineQueryResult::Ptr>& results, + 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 kick a user from a group or a supergroup. + * @param chatId Unique identifier for the target group. + * @param userId Unique identifier of the target user. + * @param untilDate Optional. Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. + * @return True on success + */ + bool kickChatMember(int64_t chatId, int32_t userId, uint64_t untilDate = 0) const; + + /** + * @brief Use this method to unban a previously kicked user in a supergroup. + * @param chatId Unique identifier for the target group. + * @param userId Unique identifier of the target user. + * @return True on success + */ + bool unbanChatMember(int64_t chatId, int32_t userId) const; + + /** + * @brief Use this method to restrict a user in a supergroup. + * @param chatId Unique identifier for the target chat of the target supergroup. + * @param userId Unique identifier of the target user. + * @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 canSendMessages Optional. Pass True, if the user can send text messages, contacts, locations and venues. + * @param canSendMediaMessages Optional. Pass True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages. + * @param canSendOtherMessages Optional. Pass True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages. + * @param canAddWebPagePreviews Optional. Pass True, if the user may add web page previews to their messages, implies can_send_media_messages. + * @return True on success + */ + bool restrictChatMember(int64_t chatId, int32_t userId, uint64_t untilDate = 0, bool canSendMessages = false, + bool canSendMediaMessages = false, bool canSendOtherMessages = false, bool canAddWebPagePreviews = false) const; + + /** + * @brief Use this method to promote or demote a user in a supergroup or a channel. + * @param chatId Unique identifier for the target chat of the target supergroup or channal. + * @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 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 canRestrictMembers Optional. Pass True, if the administrator can restrict, ban or unban chat members. + * @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 his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him). + * @return True on success + */ + bool promoteChatMember(int64_t chatId, int32_t userId, bool canChangeInfo = false, bool canPostMessages = false, + bool canEditMessages = false, bool canDeleteMessages = false, bool canInviteUsers = false, bool canPinMessages = false, bool canPromoteMembers = false) const; + + /** + * @brief Use this method to generate a new invite link for a chat; any previously generated link is revoked. + * @param chatId Unique identifier for the target chat. + * @return The new invite link as String on success. + */ + std::string exportChatInviteLink(int64_t chatId) const; + + /** + * @brief Use this method to set a new profile photo for the chat. + * + * Photos can't be changed for private chats. + * + * @param chatId Unique identifier for the target chat. + * @param photo New chat photo. + * @return True on success + */ + bool setChatPhoto(int64_t chatId, InputFile::Ptr photo) const; + + /** + * @brief Use this method to delete a chat photo. + * + * Photos can't be changed for private chats. + * + * @param chatId Unique identifier for the target chat. + * @return True on success + */ + bool deleteChatPhoto(int64_t chatId) const; + + /** + * @brief Use this method to change the title of a chat. + * + * Titles can't be changed for private chats. + * + * @param chatId Unique identifier for the target chat. + * @param title New chat title, 1-255 characters. + * @return True on success + */ + bool setChatTitle(int64_t chatId, const std::string& title) const; + + /** + * @brief Use this method to change the description of a supergroup or a channel. + * @param chatId Unique identifier for the target chat. + * @param description New chat description, 1-255 characters. + * @return True on success + */ + bool setChatDescription(int64_t chatId, const std::string& description) const; + + /** + * @brief Use this method to pin a message in a supergroup or a channel. + * @param chatId Unique identifier for the target chat. + * @param messageId Identifier of a message to pin. + * @param disableNotification Optional. Pass True, if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels. + * @return True on success + */ + bool pinChatMessage(int64_t chatId, int32_t messageId, bool disableNotification = false) const; + + /** + * @brief Use this method to unpin a message in a supergroup or a channel. + * @param chatId Unique identifier for the target chat. + * @return True on success + */ + bool unpinChatMessage(int64_t chatId) const; + + /** + * @brief Use this method to set the score of the specified user in a game. + * + * Returns an error, if the new score is not greater than the user's current score in the chat and force is False. + * + * @param userId User identifier. + * @param score New score, must be non-negative. + * @param force Optional. Pass True, if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters. + * @param disableEditMessage Optional. Pass True, if the game message should not be automatically edited to include the current scoreboard. + * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat + * @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the sent message + * @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message + * @return On success, if the message was sent by the bot, returns the edited Message, otherwise returns nullptr. + */ + Message::Ptr setGameScore(int32_t userId, int32_t score, bool force = false, bool disableEditMessage = false, + int64_t chatId = 0, int32_t messageId = 0, const std::string& inlineMessageId = "") const; + + /** + * @brief Use this method to get data for high score tables. + * + * Will return the score of the specified user and several of his neighbors in a game. + * + * @param userId User identifier. + * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat + * @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the sent message + * @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message + * @return On success, returns an Array of GameHighScore objects. + */ + std::vector<GameHighScore::Ptr> getGameHighScores(int32_t userId, int32_t score, bool force = false, + bool disableEditMessage = false, int64_t chatId = 0, int32_t messageId = 0, const std::string& inlineMessageId = "") const; + + + /** + * @brief Downloads file from Telegram and saves it in memory. + * @param filePath Telegram file path. + * @param args Additional api parameters. + * @return File contents in a string. + */ + std::string downloadFile(const std::string& filePath, const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>()) const; private: - boost::property_tree::ptree sendRequest(const std::string& method, const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>()) const; + boost::property_tree::ptree sendRequest(const std::string& method, const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>()) const; - const std::string _token; - const HttpClient& _httpClientDriver; + const std::string _token; + const HttpClient& _httpClient; + const TgTypeParser _tgTypeParser; }; } diff --git a/include/tgbot/Bot.h b/include/tgbot/Bot.h index b8c8a85..e2d9027 100644 --- a/include/tgbot/Bot.h +++ b/include/tgbot/Bot.h @@ -24,11 +24,12 @@ #define TGBOT_CPP_BOT_H #include <string> - +#include <utility> #include "tgbot/Api.h" #include "tgbot/EventBroadcaster.h" #include "tgbot/EventHandler.h" #include "tgbot/net/HttpClient.h" +#include "tgbot/net/BoostHttpOnlySslClient.h" namespace TgBot { @@ -40,44 +41,48 @@ namespace TgBot { class Bot { public: - explicit Bot(const std::string& token, const HttpClient &httpClientDriver = BoostHttpClient::getInstance()) - : _token(token), _api(token, httpClientDriver), _eventHandler(&_eventBroadcaster), _httpClientDriver(httpClientDriver) { - } + explicit Bot(std::string token, const HttpClient& httpClient = _getDefaultHttpClient()) + : _token(std::move(token)), _api(_token, httpClient), _eventHandler(_eventBroadcaster) { + } - /** - * @return Token for accessing api. - */ - inline const std::string& getToken() const { - return _token; - } + /** + * @return Token for accessing api. + */ + inline const std::string& getToken() const { + return _token; + } - /** - * @return Object which can execute Telegram Bot API methods. - */ - inline const Api& getApi() const { - return _api; - } + /** + * @return Object which can execute Telegram Bot API methods. + */ + inline const Api& getApi() const { + return _api; + } - /** - * @return Object which holds all event listeners. - */ - inline EventBroadcaster& getEvents() { - return _eventBroadcaster; - } + /** + * @return Object which holds all event listeners. + */ + inline EventBroadcaster& getEvents() { + return _eventBroadcaster; + } - /** - * @return Object which handles new update objects. Usually it's only needed for TgLongPoll, TgWebhookLocalServer and TgWebhookTcpServer objects. - */ - inline const EventHandler& getEventHandler() const { - return _eventHandler; - } + /** + * @return Object which handles new update objects. Usually it's only needed for TgLongPoll, TgWebhookLocalServer and TgWebhookTcpServer objects. + */ + inline const EventHandler& getEventHandler() const { + return _eventHandler; + } private: - const std::string _token; - const Api _api; - EventBroadcaster _eventBroadcaster; - const EventHandler _eventHandler; - const HttpClient& _httpClientDriver; + static HttpClient& _getDefaultHttpClient() { + static BoostHttpOnlySslClient instance; + return instance; + } + + const std::string _token; + const Api _api; + EventBroadcaster _eventBroadcaster; + const EventHandler _eventHandler; }; } diff --git a/include/tgbot/EventBroadcaster.h b/include/tgbot/EventBroadcaster.h index 0a4ebe9..d879ab4 100644 --- a/include/tgbot/EventBroadcaster.h +++ b/include/tgbot/EventBroadcaster.h @@ -47,127 +47,127 @@ class EventBroadcaster { friend EventHandler; public: - typedef std::function<void (const Message::Ptr)> MessageListener; - typedef std::function<void (const InlineQuery::Ptr)> InlineQueryListener; - typedef std::function<void (const ChosenInlineResult::Ptr)> ChosenInlineResultListener; - typedef std::function<void (const CallbackQuery::Ptr)> CallbackQueryListener; - - /** - * @brief Registers listener which receives all messages which the bot can ever receive. - * @param listener Listener. - */ - inline void onAnyMessage(const MessageListener& listener) { - _onAnyMessageListeners.push_back(listener); - } - - /** - * @brief Registers listener which receives all messages with commands (messages with leading '/' char). - * @param commandName Command name which listener can handle. - * @param listener Listener. - */ - inline void onCommand(const std::string& commandName, const MessageListener& listener) { - _onCommandListeners[commandName] = listener; - } - - /** - * @brief Registers listener which receives all messages with commands (messages with leading '/' char). - * @param commandsList Commands names which listener can handle. - * @param listener Listener. - */ - inline void onCommand(const std::initializer_list<std::string>& commandsList, const MessageListener& listener) { - for (const auto& command : commandsList) - { - _onCommandListeners[command] = listener; - } - } - - /** - * @brief Registers listener which receives all messages with commands (messages with leading '/' char) which haven't been handled by other listeners. - * @param listener Listener. - */ - inline void onUnknownCommand(const MessageListener& listener) { - _onUnknownCommandListeners.push_back(listener); - } - - /** - * @brief Registers listener which receives all messages without commands (messages with no leading '/' char) - * @param listener Listener. - */ - inline void onNonCommandMessage(const MessageListener& listener) { - _onNonCommandMessageListeners.push_back(listener); - } - - /** - * @brief Registers listener which receives all the inline query. - * @param listener Listener. - */ - inline void onInlineQuery(const InlineQueryListener& listener) { - _onInlineQueryListeners.push_back(listener); - } - - /** - * @brief Registers listener which receives all the chosen inline result. - * @param listener Listener. - */ - inline void onChosenInlineResult(const ChosenInlineResultListener& listener){ - _onChosenInlineResultListeners.push_back(listener); - } - - inline void onCallbackQuery(const CallbackQueryListener& listener){ - _onCallbackQueryListeners.push_back(listener); - } + typedef std::function<void (const Message::Ptr)> MessageListener; + typedef std::function<void (const InlineQuery::Ptr)> InlineQueryListener; + typedef std::function<void (const ChosenInlineResult::Ptr)> ChosenInlineResultListener; + typedef std::function<void (const CallbackQuery::Ptr)> CallbackQueryListener; + + /** + * @brief Registers listener which receives all messages which the bot can ever receive. + * @param listener Listener. + */ + inline void onAnyMessage(const MessageListener& listener) { + _onAnyMessageListeners.push_back(listener); + } + + /** + * @brief Registers listener which receives all messages with commands (messages with leading '/' char). + * @param commandName Command name which listener can handle. + * @param listener Listener. + */ + inline void onCommand(const std::string& commandName, const MessageListener& listener) { + _onCommandListeners[commandName] = listener; + } + + /** + * @brief Registers listener which receives all messages with commands (messages with leading '/' char). + * @param commandsList Commands names which listener can handle. + * @param listener Listener. + */ + inline void onCommand(const std::initializer_list<std::string>& commandsList, const MessageListener& listener) { + for (const auto& command : commandsList) + { + _onCommandListeners[command] = listener; + } + } + + /** + * @brief Registers listener which receives all messages with commands (messages with leading '/' char) which haven't been handled by other listeners. + * @param listener Listener. + */ + inline void onUnknownCommand(const MessageListener& listener) { + _onUnknownCommandListeners.push_back(listener); + } + + /** + * @brief Registers listener which receives all messages without commands (messages with no leading '/' char) + * @param listener Listener. + */ + inline void onNonCommandMessage(const MessageListener& listener) { + _onNonCommandMessageListeners.push_back(listener); + } + + /** + * @brief Registers listener which receives all the inline query. + * @param listener Listener. + */ + inline void onInlineQuery(const InlineQueryListener& listener) { + _onInlineQueryListeners.push_back(listener); + } + + /** + * @brief Registers listener which receives all the chosen inline result. + * @param listener Listener. + */ + inline void onChosenInlineResult(const ChosenInlineResultListener& listener){ + _onChosenInlineResultListeners.push_back(listener); + } + + inline void onCallbackQuery(const CallbackQueryListener& listener){ + _onCallbackQueryListeners.push_back(listener); + } private: - template<typename ListenerType, typename ObjectType> - inline void broadcast(const std::vector<ListenerType>& listeners, const ObjectType object) const { - if (!object) - return; - - for (const ListenerType& item : listeners) { - item(object); - } - } - - inline void broadcastAnyMessage(const Message::Ptr message) const { - broadcast<MessageListener, Message::Ptr>(_onAnyMessageListeners, message); - } - - inline bool broadcastCommand(const std::string command, const Message::Ptr message) const { - std::unordered_map<std::string, MessageListener>::const_iterator iter = _onCommandListeners.find(command); - if (iter == _onCommandListeners.end()) { - return false; - } - iter->second(message); - return true; - } - - inline void broadcastUnknownCommand(const Message::Ptr message) const { - broadcast<MessageListener, Message::Ptr>(_onUnknownCommandListeners, message); - } - - inline void broadcastNonCommandMessage(const Message::Ptr message) const { - broadcast<MessageListener, Message::Ptr>(_onNonCommandMessageListeners, message); - } - - inline void broadcastInlineQuery(const InlineQuery::Ptr query) const { - broadcast<InlineQueryListener, InlineQuery::Ptr>(_onInlineQueryListeners, query); - } - - inline void broadcastChosenInlineResult(const ChosenInlineResult::Ptr result) const { - broadcast<ChosenInlineResultListener, ChosenInlineResult::Ptr>(_onChosenInlineResultListeners, result); - } - - inline void broadcastCallbackQuery(const CallbackQuery::Ptr result) const { - broadcast<CallbackQueryListener, CallbackQuery::Ptr>(_onCallbackQueryListeners, result); - } - - std::vector<MessageListener> _onAnyMessageListeners; - std::unordered_map<std::string, MessageListener> _onCommandListeners; - std::vector<MessageListener> _onUnknownCommandListeners; - std::vector<MessageListener> _onNonCommandMessageListeners; - std::vector<InlineQueryListener> _onInlineQueryListeners; - std::vector<ChosenInlineResultListener> _onChosenInlineResultListeners; - std::vector<CallbackQueryListener> _onCallbackQueryListeners; + template<typename ListenerType, typename ObjectType> + inline void broadcast(const std::vector<ListenerType>& listeners, const ObjectType object) const { + if (!object) + return; + + for (const ListenerType& item : listeners) { + item(object); + } + } + + inline void broadcastAnyMessage(const Message::Ptr message) const { + broadcast<MessageListener, Message::Ptr>(_onAnyMessageListeners, message); + } + + inline bool broadcastCommand(const std::string command, const Message::Ptr message) const { + std::unordered_map<std::string, MessageListener>::const_iterator iter = _onCommandListeners.find(command); + if (iter == _onCommandListeners.end()) { + return false; + } + iter->second(message); + return true; + } + + inline void broadcastUnknownCommand(const Message::Ptr message) const { + broadcast<MessageListener, Message::Ptr>(_onUnknownCommandListeners, message); + } + + inline void broadcastNonCommandMessage(const Message::Ptr message) const { + broadcast<MessageListener, Message::Ptr>(_onNonCommandMessageListeners, message); + } + + inline void broadcastInlineQuery(const InlineQuery::Ptr query) const { + broadcast<InlineQueryListener, InlineQuery::Ptr>(_onInlineQueryListeners, query); + } + + inline void broadcastChosenInlineResult(const ChosenInlineResult::Ptr result) const { + broadcast<ChosenInlineResultListener, ChosenInlineResult::Ptr>(_onChosenInlineResultListeners, result); + } + + inline void broadcastCallbackQuery(const CallbackQuery::Ptr result) const { + broadcast<CallbackQueryListener, CallbackQuery::Ptr>(_onCallbackQueryListeners, result); + } + + std::vector<MessageListener> _onAnyMessageListeners; + std::unordered_map<std::string, MessageListener> _onCommandListeners; + std::vector<MessageListener> _onUnknownCommandListeners; + std::vector<MessageListener> _onNonCommandMessageListeners; + std::vector<InlineQueryListener> _onInlineQueryListeners; + std::vector<ChosenInlineResultListener> _onChosenInlineResultListeners; + std::vector<CallbackQueryListener> _onCallbackQueryListeners; }; } diff --git a/include/tgbot/EventHandler.h b/include/tgbot/EventHandler.h index 7fa68ee..edc84dc 100644 --- a/include/tgbot/EventHandler.h +++ b/include/tgbot/EventHandler.h @@ -32,15 +32,15 @@ namespace TgBot { class EventHandler { public: - explicit EventHandler(const EventBroadcaster* broadcaster) : _broadcaster(broadcaster) { - } + explicit EventHandler(const EventBroadcaster& broadcaster) : _broadcaster(broadcaster) { + } - void handleUpdate(const Update::Ptr update) const; + void handleUpdate(Update::Ptr update) const; private: - const EventBroadcaster* _broadcaster; + const EventBroadcaster& _broadcaster; - void handleMessage(const Message::Ptr message) const; + void handleMessage(Message::Ptr message) const; }; } diff --git a/include/tgbot/TgException.h b/include/tgbot/TgException.h index 4b03e1c..d6ff7d7 100644 --- a/include/tgbot/TgException.h +++ b/include/tgbot/TgException.h @@ -36,7 +36,7 @@ namespace TgBot { class TgException : public std::runtime_error { public: - explicit TgException(const std::string description); + explicit TgException(const std::string description); }; } diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h index 356b69e..656007b 100644 --- a/include/tgbot/TgTypeParser.h +++ b/include/tgbot/TgTypeParser.h @@ -105,348 +105,371 @@ namespace TgBot { class TgTypeParser { public: - template<typename T> - using JsonToTgTypeFunc = std::shared_ptr<T> (TgTypeParser::*)(const boost::property_tree::ptree&) const; - - template<typename T> - using TgTypeToJsonFunc = std::string (TgTypeParser::*)(const std::shared_ptr<T>&) const; - - static TgTypeParser& getInstance(); - - Chat::Ptr parseJsonAndGetChat(const boost::property_tree::ptree& data) const; - std::string parseChat(const Chat::Ptr& object) const; - User::Ptr parseJsonAndGetUser(const boost::property_tree::ptree& data) const; - std::string parseUser(const User::Ptr& object) const; - MessageEntity::Ptr parseJsonAndGetMessageEntity(const boost::property_tree::ptree& data) const; - std::string parseMessageEntity(const MessageEntity::Ptr& object) const; - Message::Ptr parseJsonAndGetMessage(const boost::property_tree::ptree& data) const; - std::string parseMessage(const Message::Ptr& object) const; - PhotoSize::Ptr parseJsonAndGetPhotoSize(const boost::property_tree::ptree& data) const; - std::string parsePhotoSize(const PhotoSize::Ptr& object) const; - Audio::Ptr parseJsonAndGetAudio(const boost::property_tree::ptree& data) const; - std::string parseAudio(const Audio::Ptr& object) const; - Document::Ptr parseJsonAndGetDocument(const boost::property_tree::ptree& data) const; - std::string parseDocument(const Document::Ptr& object) const; - Sticker::Ptr parseJsonAndGetSticker(const boost::property_tree::ptree& data) const; - std::string parseSticker(const Sticker::Ptr& object) const; - StickerSet::Ptr parseJsonAndGetStickerSet(const boost::property_tree::ptree& data) const; - std::string parseStickerSet(const StickerSet::Ptr& object) const; - MaskPosition::Ptr parseJsonAndGetMaskPosition(const boost::property_tree::ptree& data) const; - std::string parseMaskPosition(const MaskPosition::Ptr& object) const; - Video::Ptr parseJsonAndGetVideo(const boost::property_tree::ptree& data) const; - std::string parseVideo(const Video::Ptr& object) const; - VideoNote::Ptr parseJsonAndGetVideoNote(const boost::property_tree::ptree& data) const; - std::string parseVideoNote(const VideoNote::Ptr& object) const; - Game::Ptr parseJsonAndGetGame(const boost::property_tree::ptree& data) const; - std::string parseGame(const Game::Ptr& object) const; - GameHighScore::Ptr parseJsonAndGetGameHighScore(const boost::property_tree::ptree& data) const; - std::string parseGameHighScore(const GameHighScore::Ptr& object) const; - Animation::Ptr parseJsonAndGetAnimation(const boost::property_tree::ptree& data) const; - std::string parseAnimation(const Animation::Ptr& object) const; - Contact::Ptr parseJsonAndGetContact(const boost::property_tree::ptree& data) const; - std::string parseContact(const Contact::Ptr& object) const; - Location::Ptr parseJsonAndGetLocation(const boost::property_tree::ptree& data) const; - std::string parseLocation(const Location::Ptr& object) const; - Update::Ptr parseJsonAndGetUpdate(const boost::property_tree::ptree& data) const; - std::string parseUpdate(const Update::Ptr& object) const; - UserProfilePhotos::Ptr parseJsonAndGetUserProfilePhotos(const boost::property_tree::ptree& data) const; - std::string parseUserProfilePhotos(const UserProfilePhotos::Ptr& object) const; - InputMedia::Ptr parseJsonAndGetInputMedia(const boost::property_tree::ptree& data) const; - std::string parseInputMedia(const InputMedia::Ptr& object) const; - - File::Ptr parseJsonAndGetFile(const boost::property_tree::ptree& data) const; - std::string parseFile(const File::Ptr& object) const; - - ReplyKeyboardMarkup::Ptr parseJsonAndGetReplyKeyboardMarkup(const boost::property_tree::ptree& data) const; - std::string parseReplyKeyboardMarkup(const ReplyKeyboardMarkup::Ptr& object) const; - - KeyboardButton::Ptr parseJsonAndGetKeyboardButton(const boost::property_tree::ptree& data) const; - std::string parseKeyboardButton(const KeyboardButton::Ptr& object) const; - - ReplyKeyboardRemove::Ptr parseJsonAndGetReplyKeyboardRemove(const boost::property_tree::ptree& data) const; - std::string parseReplyKeyboardRemove(const ReplyKeyboardRemove::Ptr& object) const; - - ForceReply::Ptr parseJsonAndGetForceReply(const boost::property_tree::ptree& data) const; - std::string parseForceReply(const ForceReply::Ptr& object) const; - - ChatMember::Ptr parseJsonAndGetChatMember(const boost::property_tree::ptree& data) const; - std::string parseChatMember(const ChatMember::Ptr& object) const; - - ChatPhoto::Ptr parseJsonAndGetChatPhoto(const boost::property_tree::ptree& data) const; - std::string parseChatPhoto(const ChatPhoto::Ptr& object) const; - - ResponseParameters::Ptr parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const; - std::string parseResponseParameters(const ResponseParameters::Ptr& object) const; - - GenericReply::Ptr parseJsonAndGetGenericReply(const boost::property_tree::ptree& data) const; - std::string parseGenericReply(const GenericReply::Ptr& object) const; - - InlineQuery::Ptr parseJsonAndGetInlineQuery(const boost::property_tree::ptree& data) const; - std::string parseInlineQuery(const InlineQuery::Ptr& object) const; - - InlineQueryResult::Ptr parseJsonAndGetInlineQueryResult(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResult(const InlineQueryResult::Ptr& object) const; - - InlineQueryResultCachedAudio::Ptr parseJsonAndGetInlineQueryResultCachedAudio(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultCachedAudio(const InlineQueryResultCachedAudio::Ptr& object) const; - - InlineQueryResultCachedDocument::Ptr parseJsonAndGetInlineQueryResultCachedDocument(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultCachedDocument(const InlineQueryResultCachedDocument::Ptr& object) const; - - InlineQueryResultCachedGif::Ptr parseJsonAndGetInlineQueryResultCachedGif(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultCachedGif(const InlineQueryResultCachedGif::Ptr& object) const; - - InlineQueryResultCachedMpeg4Gif::Ptr parseJsonAndGetInlineQueryResultCachedMpeg4Gif(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultCachedMpeg4Gif(const InlineQueryResultCachedMpeg4Gif::Ptr& object) const; - - InlineQueryResultCachedPhoto::Ptr parseJsonAndGetInlineQueryResultCachedPhoto(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultCachedPhoto(const InlineQueryResultCachedPhoto::Ptr& object) const; - - InlineQueryResultCachedSticker::Ptr parseJsonAndGetInlineQueryResultCachedSticker(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultCachedSticker(const InlineQueryResultCachedSticker::Ptr& object) const; - - InlineQueryResultCachedVideo::Ptr parseJsonAndGetInlineQueryResultCachedVideo(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultCachedVideo(const InlineQueryResultCachedVideo::Ptr& object) const; - - InlineQueryResultCachedVoice::Ptr parseJsonAndGetInlineQueryResultCachedVoice(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultCachedVoice(const InlineQueryResultCachedVoice::Ptr& object) const; - - InlineQueryResultArticle::Ptr parseJsonAndGetInlineQueryResultArticle(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultArticle(const InlineQueryResultArticle::Ptr& object) const; - - InlineQueryResultAudio::Ptr parseJsonAndGetInlineQueryResultAudio(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultAudio(const InlineQueryResultAudio::Ptr& object) const; - - InlineQueryResultContact::Ptr parseJsonAndGetInlineQueryResultContact(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultContact(const InlineQueryResultContact::Ptr& object) const; - - InlineQueryResultGame::Ptr parseJsonAndGetInlineQueryResultGame(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultGame(const InlineQueryResultGame::Ptr& object) const; - - InlineQueryResultDocument::Ptr parseJsonAndGetInlineQueryResultDocument(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultDocument(const InlineQueryResultDocument::Ptr& object) const; - - InlineQueryResultLocation::Ptr parseJsonAndGetInlineQueryResultLocation(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultLocation(const InlineQueryResultLocation::Ptr& object) const; - - InlineQueryResultVenue::Ptr parseJsonAndGetInlineQueryResultVenue(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultVenue(const InlineQueryResultVenue::Ptr& object) const; - - InlineQueryResultVoice::Ptr parseJsonAndGetInlineQueryResultVoice(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultVoice(const InlineQueryResultVoice::Ptr& object) const; - - InlineQueryResultPhoto::Ptr parseJsonAndGetInlineQueryResultPhoto(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultPhoto(const InlineQueryResultPhoto::Ptr& object) const; - InlineQueryResultGif::Ptr parseJsonAndGetInlineQueryResultGif(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultGif(const InlineQueryResultGif::Ptr& object) const; - InlineQueryResultMpeg4Gif::Ptr parseJsonAndGetInlineQueryResultMpeg4Gif(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultMpeg4Gif(const InlineQueryResultMpeg4Gif::Ptr& object) const; - InlineQueryResultVideo::Ptr parseJsonAndGetInlineQueryResultVideo(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultVideo(const InlineQueryResultVideo::Ptr& object) const; - ChosenInlineResult::Ptr parseJsonAndGetChosenInlineResult(const boost::property_tree::ptree& data) const; - std::string parseChosenInlineResult(const ChosenInlineResult::Ptr& object) const; - - CallbackQuery::Ptr parseJsonAndGetCallbackQuery(const boost::property_tree::ptree& data) const; - std::string parseCallbackQuery(const CallbackQuery::Ptr& object) const; - InlineKeyboardMarkup::Ptr parseJsonAndGetInlineKeyboardMarkup(const boost::property_tree::ptree& data) const; - std::string parseInlineKeyboardMarkup(const InlineKeyboardMarkup::Ptr& object) const; - InlineKeyboardButton::Ptr parseJsonAndGetInlineKeyboardButton(const boost::property_tree::ptree& data) const; - std::string parseInlineKeyboardButton(const InlineKeyboardButton::Ptr& object) const; - - WebhookInfo::Ptr parseJsonAndGetWebhookInfo(const boost::property_tree::ptree& data) const; - std::string parseWebhookInfo(const WebhookInfo::Ptr& object) const; - - InputMessageContent::Ptr parseJsonAndGetInputMessageContent(const boost::property_tree::ptree& data) const; - std::string parseInputMessageContent(const InputMessageContent::Ptr& object) const; - - InputTextMessageContent::Ptr parseJsonAndGetInputTextMessageContent(const boost::property_tree::ptree& data) const; - std::string parseInputTextMessageContent(const InputTextMessageContent::Ptr& object) const; - - InputLocationMessageContent::Ptr parseJsonAndGetInputLocationMessageContent(const boost::property_tree::ptree& data) const; - std::string parseInputLocationMessageContent(const InputLocationMessageContent::Ptr& object) const; - - InputVenueMessageContent::Ptr parseJsonAndGetInputVenueMessageContent(const boost::property_tree::ptree& data) const; - std::string parseInputVenueMessageContent(const InputVenueMessageContent::Ptr& object) const; - - InputContactMessageContent::Ptr parseJsonAndGetInputContactMessageContent(const boost::property_tree::ptree& data) const; - std::string parseInputContactMessageContent(const InputContactMessageContent::Ptr& object) const; - - Invoice::Ptr parseJsonAndGetInvoice(const boost::property_tree::ptree& data) const; - std::string parseInvoice(const Invoice::Ptr& object) const; - - LabeledPrice::Ptr parseJsonAndGetLabeledPrice(const boost::property_tree::ptree& data) const; - std::string parseLabeledPrice(const LabeledPrice::Ptr& object) const; - - OrderInfo::Ptr parseJsonAndGetOrderInfo(const boost::property_tree::ptree& data) const; - std::string parseOrderInfo(const OrderInfo::Ptr& object) const; - - PreCheckoutQuery::Ptr parseJsonAndGetPreCheckoutQuery(const boost::property_tree::ptree& data) const; - std::string parsePreCheckoutQuery(const PreCheckoutQuery::Ptr& object) const; - - ShippingAddress::Ptr parseJsonAndGetShippingAddress(const boost::property_tree::ptree& data) const; - std::string parseShippingAddress(const ShippingAddress::Ptr& object) const; - - ShippingOption::Ptr parseJsonAndGetShippingOption(const boost::property_tree::ptree& data) const; - std::string parseShippingOption(const ShippingOption::Ptr& object) const; - - ShippingQuery::Ptr parseJsonAndGetShippingQuery(const boost::property_tree::ptree& data) const; - std::string parseShippingQuery(const ShippingQuery::Ptr& object) const; - - SuccessfulPayment::Ptr parseJsonAndGetSuccessfulPayment(const boost::property_tree::ptree& data) const; - std::string parseSuccessfulPayment(const SuccessfulPayment::Ptr& object) const; - - inline boost::property_tree::ptree parseJson(const std::string& json) const { - boost::property_tree::ptree tree; - std::istringstream input(json); - boost::property_tree::read_json(input, tree); - return tree; - } - - template<typename T> - std::shared_ptr<T> tryParseJson(JsonToTgTypeFunc<T> parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { - auto treeItem = data.find(keyName); - if (treeItem == data.not_found()) { - return std::shared_ptr<T>(); - } - return (this->*parseFunc)(treeItem->second); - } - - template<typename T> - std::vector<std::shared_ptr<T>> parseJsonAndGetArray(JsonToTgTypeFunc<T> parseFunc, const boost::property_tree::ptree& data) const { - std::vector<std::shared_ptr<T>> result; - result.reserve(data.size()); - for (const std::pair<const std::string, boost::property_tree::ptree>& innerTreeItem : data) { - result.push_back((this->*parseFunc)(innerTreeItem.second)); - } - return result; - } - - template<typename T> - std::vector<T> parseJsonAndGetArray(std::function<T(const boost::property_tree::ptree&)> parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { - std::vector<T> result; - auto treeItem = data.find(keyName); - if (treeItem == data.not_found()) { - return result; - } - result.reserve(treeItem->second.size()); - for (const std::pair<const std::string, boost::property_tree::ptree>& innerTreeItem : treeItem->second) { - result.push_back(parseFunc(innerTreeItem.second)); - } - return result; - } - - template<typename T> - std::vector<std::shared_ptr<T>> parseJsonAndGetArray(JsonToTgTypeFunc<T> parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { - std::vector<std::shared_ptr<T>> result; - auto treeItem = data.find(keyName); - if (treeItem == data.not_found()) { - return result; - } - result.reserve(treeItem->second.size()); - for (const std::pair<const std::string, boost::property_tree::ptree>& innerTreeItem : treeItem->second) { - result.push_back((this->*parseFunc)(innerTreeItem.second)); - } - return result; - } - - template<typename T> - std::vector<std::vector<std::shared_ptr<T>>> parseJsonAndGet2DArray(JsonToTgTypeFunc<T> parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { - std::vector<std::vector<std::shared_ptr<T>>> result; - auto treeItem = data.find(keyName); - if (treeItem == data.not_found()) { - return result; - } - result.reserve(treeItem->second.size()); - for (const std::pair<const std::string, boost::property_tree::ptree>& innerTreeItem : treeItem->second) { - std::vector<std::shared_ptr<T>> innerResult; - for (const std::pair<const std::string, boost::property_tree::ptree>& innerInnerTreeItem : innerTreeItem.second) { - innerResult.push_back((this->*parseFunc)(innerInnerTreeItem.second)); - } - result.push_back(innerResult); - } - return result; - } - - template<typename T> - std::string parseArray(TgTypeToJsonFunc<T> parseFunc, const std::vector<std::shared_ptr<T>>& objects) const { - if (objects.empty()) - return ""; - std::string result; - result += '['; - for (const std::shared_ptr<T>& item : objects) { - result += (this->*parseFunc)(item); - result += ','; - } - result.erase(result.length() - 1); - result += ']'; - return result; - } - - template<typename T> - std::string parseArray(std::function<T(const T&)> parseFunc, const std::vector<T>& objects) const { - if (objects.empty()) - return ""; - std::string result; - result += '['; - for (const T& item : objects) { - result += parseFunc(item); - result += ','; - } - result.erase(result.length() - 1); - result += ']'; - return result; - } - - template<typename T> - std::string parse2DArray(TgTypeToJsonFunc<T> parseFunc, const std::vector<std::vector<std::shared_ptr<T>>>& objects) const { - if (objects.empty()) - return ""; - std::string result; - result += '['; - for (const std::vector<std::shared_ptr<T>>& item : objects) { - result += parseArray(parseFunc, item); - result += ','; - } - result.erase(result.length() - 1); - result += ']'; - return result; - } + template<typename T> + using JsonToTgTypeFunc = std::shared_ptr<T> (TgTypeParser::*)(const boost::property_tree::ptree&) const; + + template<typename T> + using TgTypeToJsonFunc = std::string (TgTypeParser::*)(const std::shared_ptr<T>&) const; + + Chat::Ptr parseJsonAndGetChat(const boost::property_tree::ptree& data) const; + std::string parseChat(const Chat::Ptr& object) const; + + User::Ptr parseJsonAndGetUser(const boost::property_tree::ptree& data) const; + std::string parseUser(const User::Ptr& object) const; + + MessageEntity::Ptr parseJsonAndGetMessageEntity(const boost::property_tree::ptree& data) const; + std::string parseMessageEntity(const MessageEntity::Ptr& object) const; + + Message::Ptr parseJsonAndGetMessage(const boost::property_tree::ptree& data) const; + std::string parseMessage(const Message::Ptr& object) const; + + PhotoSize::Ptr parseJsonAndGetPhotoSize(const boost::property_tree::ptree& data) const; + std::string parsePhotoSize(const PhotoSize::Ptr& object) const; + + Audio::Ptr parseJsonAndGetAudio(const boost::property_tree::ptree& data) const; + std::string parseAudio(const Audio::Ptr& object) const; + + Document::Ptr parseJsonAndGetDocument(const boost::property_tree::ptree& data) const; + std::string parseDocument(const Document::Ptr& object) const; + + Sticker::Ptr parseJsonAndGetSticker(const boost::property_tree::ptree& data) const; + std::string parseSticker(const Sticker::Ptr& object) const; + + StickerSet::Ptr parseJsonAndGetStickerSet(const boost::property_tree::ptree& data) const; + std::string parseStickerSet(const StickerSet::Ptr& object) const; + + MaskPosition::Ptr parseJsonAndGetMaskPosition(const boost::property_tree::ptree& data) const; + std::string parseMaskPosition(const MaskPosition::Ptr& object) const; + + Video::Ptr parseJsonAndGetVideo(const boost::property_tree::ptree& data) const; + std::string parseVideo(const Video::Ptr& object) const; + + VideoNote::Ptr parseJsonAndGetVideoNote(const boost::property_tree::ptree& data) const; + std::string parseVideoNote(const VideoNote::Ptr& object) const; + + Game::Ptr parseJsonAndGetGame(const boost::property_tree::ptree& data) const; + std::string parseGame(const Game::Ptr& object) const; + + GameHighScore::Ptr parseJsonAndGetGameHighScore(const boost::property_tree::ptree& data) const; + std::string parseGameHighScore(const GameHighScore::Ptr& object) const; + + Animation::Ptr parseJsonAndGetAnimation(const boost::property_tree::ptree& data) const; + std::string parseAnimation(const Animation::Ptr& object) const; + + Contact::Ptr parseJsonAndGetContact(const boost::property_tree::ptree& data) const; + std::string parseContact(const Contact::Ptr& object) const; + + Location::Ptr parseJsonAndGetLocation(const boost::property_tree::ptree& data) const; + std::string parseLocation(const Location::Ptr& object) const; + + Update::Ptr parseJsonAndGetUpdate(const boost::property_tree::ptree& data) const; + std::string parseUpdate(const Update::Ptr& object) const; + + UserProfilePhotos::Ptr parseJsonAndGetUserProfilePhotos(const boost::property_tree::ptree& data) const; + std::string parseUserProfilePhotos(const UserProfilePhotos::Ptr& object) const; + + InputMedia::Ptr parseJsonAndGetInputMedia(const boost::property_tree::ptree& data) const; + std::string parseInputMedia(const InputMedia::Ptr& object) const; + + File::Ptr parseJsonAndGetFile(const boost::property_tree::ptree& data) const; + std::string parseFile(const File::Ptr& object) const; + + ReplyKeyboardMarkup::Ptr parseJsonAndGetReplyKeyboardMarkup(const boost::property_tree::ptree& data) const; + std::string parseReplyKeyboardMarkup(const ReplyKeyboardMarkup::Ptr& object) const; + + KeyboardButton::Ptr parseJsonAndGetKeyboardButton(const boost::property_tree::ptree& data) const; + std::string parseKeyboardButton(const KeyboardButton::Ptr& object) const; + + ReplyKeyboardRemove::Ptr parseJsonAndGetReplyKeyboardRemove(const boost::property_tree::ptree& data) const; + std::string parseReplyKeyboardRemove(const ReplyKeyboardRemove::Ptr& object) const; + + ForceReply::Ptr parseJsonAndGetForceReply(const boost::property_tree::ptree& data) const; + std::string parseForceReply(const ForceReply::Ptr& object) const; + + ChatMember::Ptr parseJsonAndGetChatMember(const boost::property_tree::ptree& data) const; + std::string parseChatMember(const ChatMember::Ptr& object) const; + + ChatPhoto::Ptr parseJsonAndGetChatPhoto(const boost::property_tree::ptree& data) const; + std::string parseChatPhoto(const ChatPhoto::Ptr& object) const; + + ResponseParameters::Ptr parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const; + std::string parseResponseParameters(const ResponseParameters::Ptr& object) const; + + GenericReply::Ptr parseJsonAndGetGenericReply(const boost::property_tree::ptree& data) const; + std::string parseGenericReply(const GenericReply::Ptr& object) const; + + InlineQuery::Ptr parseJsonAndGetInlineQuery(const boost::property_tree::ptree& data) const; + std::string parseInlineQuery(const InlineQuery::Ptr& object) const; + + InlineQueryResult::Ptr parseJsonAndGetInlineQueryResult(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResult(const InlineQueryResult::Ptr& object) const; + + InlineQueryResultCachedAudio::Ptr parseJsonAndGetInlineQueryResultCachedAudio(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultCachedAudio(const InlineQueryResultCachedAudio::Ptr& object) const; + + InlineQueryResultCachedDocument::Ptr parseJsonAndGetInlineQueryResultCachedDocument(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultCachedDocument(const InlineQueryResultCachedDocument::Ptr& object) const; + + InlineQueryResultCachedGif::Ptr parseJsonAndGetInlineQueryResultCachedGif(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultCachedGif(const InlineQueryResultCachedGif::Ptr& object) const; + + InlineQueryResultCachedMpeg4Gif::Ptr parseJsonAndGetInlineQueryResultCachedMpeg4Gif(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultCachedMpeg4Gif(const InlineQueryResultCachedMpeg4Gif::Ptr& object) const; + + InlineQueryResultCachedPhoto::Ptr parseJsonAndGetInlineQueryResultCachedPhoto(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultCachedPhoto(const InlineQueryResultCachedPhoto::Ptr& object) const; + + InlineQueryResultCachedSticker::Ptr parseJsonAndGetInlineQueryResultCachedSticker(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultCachedSticker(const InlineQueryResultCachedSticker::Ptr& object) const; + + InlineQueryResultCachedVideo::Ptr parseJsonAndGetInlineQueryResultCachedVideo(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultCachedVideo(const InlineQueryResultCachedVideo::Ptr& object) const; + + InlineQueryResultCachedVoice::Ptr parseJsonAndGetInlineQueryResultCachedVoice(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultCachedVoice(const InlineQueryResultCachedVoice::Ptr& object) const; + + InlineQueryResultArticle::Ptr parseJsonAndGetInlineQueryResultArticle(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultArticle(const InlineQueryResultArticle::Ptr& object) const; + + InlineQueryResultAudio::Ptr parseJsonAndGetInlineQueryResultAudio(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultAudio(const InlineQueryResultAudio::Ptr& object) const; + + InlineQueryResultContact::Ptr parseJsonAndGetInlineQueryResultContact(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultContact(const InlineQueryResultContact::Ptr& object) const; + + InlineQueryResultGame::Ptr parseJsonAndGetInlineQueryResultGame(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultGame(const InlineQueryResultGame::Ptr& object) const; + + InlineQueryResultDocument::Ptr parseJsonAndGetInlineQueryResultDocument(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultDocument(const InlineQueryResultDocument::Ptr& object) const; + + InlineQueryResultLocation::Ptr parseJsonAndGetInlineQueryResultLocation(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultLocation(const InlineQueryResultLocation::Ptr& object) const; + + InlineQueryResultVenue::Ptr parseJsonAndGetInlineQueryResultVenue(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultVenue(const InlineQueryResultVenue::Ptr& object) const; + + InlineQueryResultVoice::Ptr parseJsonAndGetInlineQueryResultVoice(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultVoice(const InlineQueryResultVoice::Ptr& object) const; + + InlineQueryResultPhoto::Ptr parseJsonAndGetInlineQueryResultPhoto(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultPhoto(const InlineQueryResultPhoto::Ptr& object) const; + + InlineQueryResultGif::Ptr parseJsonAndGetInlineQueryResultGif(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultGif(const InlineQueryResultGif::Ptr& object) const; + + InlineQueryResultMpeg4Gif::Ptr parseJsonAndGetInlineQueryResultMpeg4Gif(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultMpeg4Gif(const InlineQueryResultMpeg4Gif::Ptr& object) const; + + InlineQueryResultVideo::Ptr parseJsonAndGetInlineQueryResultVideo(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultVideo(const InlineQueryResultVideo::Ptr& object) const; + + ChosenInlineResult::Ptr parseJsonAndGetChosenInlineResult(const boost::property_tree::ptree& data) const; + std::string parseChosenInlineResult(const ChosenInlineResult::Ptr& object) const; + + CallbackQuery::Ptr parseJsonAndGetCallbackQuery(const boost::property_tree::ptree& data) const; + std::string parseCallbackQuery(const CallbackQuery::Ptr& object) const; + + InlineKeyboardMarkup::Ptr parseJsonAndGetInlineKeyboardMarkup(const boost::property_tree::ptree& data) const; + std::string parseInlineKeyboardMarkup(const InlineKeyboardMarkup::Ptr& object) const; + + InlineKeyboardButton::Ptr parseJsonAndGetInlineKeyboardButton(const boost::property_tree::ptree& data) const; + std::string parseInlineKeyboardButton(const InlineKeyboardButton::Ptr& object) const; + + WebhookInfo::Ptr parseJsonAndGetWebhookInfo(const boost::property_tree::ptree& data) const; + std::string parseWebhookInfo(const WebhookInfo::Ptr& object) const; + + InputMessageContent::Ptr parseJsonAndGetInputMessageContent(const boost::property_tree::ptree& data) const; + std::string parseInputMessageContent(const InputMessageContent::Ptr& object) const; + + InputTextMessageContent::Ptr parseJsonAndGetInputTextMessageContent(const boost::property_tree::ptree& data) const; + std::string parseInputTextMessageContent(const InputTextMessageContent::Ptr& object) const; + + InputLocationMessageContent::Ptr parseJsonAndGetInputLocationMessageContent(const boost::property_tree::ptree& data) const; + std::string parseInputLocationMessageContent(const InputLocationMessageContent::Ptr& object) const; + + InputVenueMessageContent::Ptr parseJsonAndGetInputVenueMessageContent(const boost::property_tree::ptree& data) const; + std::string parseInputVenueMessageContent(const InputVenueMessageContent::Ptr& object) const; + + InputContactMessageContent::Ptr parseJsonAndGetInputContactMessageContent(const boost::property_tree::ptree& data) const; + std::string parseInputContactMessageContent(const InputContactMessageContent::Ptr& object) const; + + Invoice::Ptr parseJsonAndGetInvoice(const boost::property_tree::ptree& data) const; + std::string parseInvoice(const Invoice::Ptr& object) const; + + LabeledPrice::Ptr parseJsonAndGetLabeledPrice(const boost::property_tree::ptree& data) const; + std::string parseLabeledPrice(const LabeledPrice::Ptr& object) const; + + OrderInfo::Ptr parseJsonAndGetOrderInfo(const boost::property_tree::ptree& data) const; + std::string parseOrderInfo(const OrderInfo::Ptr& object) const; + + PreCheckoutQuery::Ptr parseJsonAndGetPreCheckoutQuery(const boost::property_tree::ptree& data) const; + std::string parsePreCheckoutQuery(const PreCheckoutQuery::Ptr& object) const; + + ShippingAddress::Ptr parseJsonAndGetShippingAddress(const boost::property_tree::ptree& data) const; + std::string parseShippingAddress(const ShippingAddress::Ptr& object) const; + + ShippingOption::Ptr parseJsonAndGetShippingOption(const boost::property_tree::ptree& data) const; + std::string parseShippingOption(const ShippingOption::Ptr& object) const; + + ShippingQuery::Ptr parseJsonAndGetShippingQuery(const boost::property_tree::ptree& data) const; + std::string parseShippingQuery(const ShippingQuery::Ptr& object) const; + + SuccessfulPayment::Ptr parseJsonAndGetSuccessfulPayment(const boost::property_tree::ptree& data) const; + std::string parseSuccessfulPayment(const SuccessfulPayment::Ptr& object) const; + + inline boost::property_tree::ptree parseJson(const std::string& json) const { + boost::property_tree::ptree tree; + std::istringstream input(json); + boost::property_tree::read_json(input, tree); + return tree; + } + + template<typename T> + std::shared_ptr<T> tryParseJson(JsonToTgTypeFunc<T> parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { + auto treeItem = data.find(keyName); + if (treeItem == data.not_found()) { + return std::shared_ptr<T>(); + } + return (this->*parseFunc)(treeItem->second); + } + + template<typename T> + std::vector<std::shared_ptr<T>> parseJsonAndGetArray(JsonToTgTypeFunc<T> parseFunc, const boost::property_tree::ptree& data) const { + std::vector<std::shared_ptr<T>> result; + result.reserve(data.size()); + for (const std::pair<const std::string, boost::property_tree::ptree>& innerTreeItem : data) { + result.push_back((this->*parseFunc)(innerTreeItem.second)); + } + return result; + } + + template<typename T> + std::vector<T> parseJsonAndGetArray(std::function<T(const boost::property_tree::ptree&)> parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { + std::vector<T> result; + auto treeItem = data.find(keyName); + if (treeItem == data.not_found()) { + return result; + } + result.reserve(treeItem->second.size()); + for (const std::pair<const std::string, boost::property_tree::ptree>& innerTreeItem : treeItem->second) { + result.push_back(parseFunc(innerTreeItem.second)); + } + return result; + } + + template<typename T> + std::vector<std::shared_ptr<T>> parseJsonAndGetArray(JsonToTgTypeFunc<T> parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { + std::vector<std::shared_ptr<T>> result; + auto treeItem = data.find(keyName); + if (treeItem == data.not_found()) { + return result; + } + result.reserve(treeItem->second.size()); + for (const std::pair<const std::string, boost::property_tree::ptree>& innerTreeItem : treeItem->second) { + result.push_back((this->*parseFunc)(innerTreeItem.second)); + } + return result; + } + + template<typename T> + std::vector<std::vector<std::shared_ptr<T>>> parseJsonAndGet2DArray(JsonToTgTypeFunc<T> parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { + std::vector<std::vector<std::shared_ptr<T>>> result; + auto treeItem = data.find(keyName); + if (treeItem == data.not_found()) { + return result; + } + result.reserve(treeItem->second.size()); + for (const std::pair<const std::string, boost::property_tree::ptree>& innerTreeItem : treeItem->second) { + std::vector<std::shared_ptr<T>> innerResult; + for (const std::pair<const std::string, boost::property_tree::ptree>& innerInnerTreeItem : innerTreeItem.second) { + innerResult.push_back((this->*parseFunc)(innerInnerTreeItem.second)); + } + result.push_back(innerResult); + } + return result; + } + + template<typename T> + std::string parseArray(TgTypeToJsonFunc<T> parseFunc, const std::vector<std::shared_ptr<T>>& objects) const { + if (objects.empty()) + return ""; + std::string result; + result += '['; + for (const std::shared_ptr<T>& item : objects) { + result += (this->*parseFunc)(item); + result += ','; + } + result.erase(result.length() - 1); + result += ']'; + return result; + } + + template<typename T> + std::string parseArray(std::function<T(const T&)> parseFunc, const std::vector<T>& objects) const { + if (objects.empty()) + return ""; + std::string result; + result += '['; + for (const T& item : objects) { + result += parseFunc(item); + result += ','; + } + result.erase(result.length() - 1); + result += ']'; + return result; + } + + template<typename T> + std::string parse2DArray(TgTypeToJsonFunc<T> parseFunc, const std::vector<std::vector<std::shared_ptr<T>>>& objects) const { + if (objects.empty()) + return ""; + std::string result; + result += '['; + for (const std::vector<std::shared_ptr<T>>& item : objects) { + result += parseArray(parseFunc, item); + result += ','; + } + result.erase(result.length() - 1); + result += ']'; + return result; + } private: - inline void removeLastComma(std::string& input) const { - input.erase(input.length() - 1); - } - - template<typename T> - inline void appendToJson(std::string& json, const std::string& varName, const std::shared_ptr<T>& value) const { - if (value == nullptr) { - return; - } - json += '"'; - json += varName; - json += R"(":)"; - json += value; - json += ','; - } - - template<typename T> - inline void appendToJson(std::string& json, const std::string& varName, const T& value) const { - json += '"'; - json += varName; - json += R"(":)"; - json += value; - json += ','; - } - - inline void appendToJson(std::string& json, const std::string& varName, const bool& value) const { - json += '"'; - json += varName; - json += R"(":)"; - json += (value ? "true" : "false"); - json += ','; - } - - void appendToJson(std::string& json, const std::string& varName, const std::string& value) const; + inline void removeLastComma(std::string& input) const { + input.erase(input.length() - 1); + } + + template<typename T> + inline void appendToJson(std::string& json, const std::string& varName, const std::shared_ptr<T>& value) const { + if (value == nullptr) { + return; + } + json += '"'; + json += varName; + json += R"(":)"; + json += value; + json += ','; + } + + template<typename T> + inline void appendToJson(std::string& json, const std::string& varName, const T& value) const { + json += '"'; + json += varName; + json += R"(":)"; + json += value; + json += ','; + } + + inline void appendToJson(std::string& json, const std::string& varName, const bool& value) const { + json += '"'; + json += varName; + json += R"(":)"; + json += (value ? "true" : "false"); + json += ','; + } + + void appendToJson(std::string& json, const std::string& varName, const std::string& value) const; }; } diff --git a/include/tgbot/net/BoostHttpOnlySslClient.h b/include/tgbot/net/BoostHttpOnlySslClient.h new file mode 100644 index 0000000..615abdc --- /dev/null +++ b/include/tgbot/net/BoostHttpOnlySslClient.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2015 Oleg Morozenkov + * Copyright (c) 2018 JellyBrick + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef TGBOT_BOOSTHTTPCLIENT_H +#define TGBOT_BOOSTHTTPCLIENT_H + +#include <string> + +#include <boost/asio.hpp> + +#include "tgbot/net/HttpClient.h" +#include "tgbot/net/Url.h" +#include "tgbot/net/HttpReqArg.h" +#include "tgbot/net/HttpParser.h" + +namespace TgBot { + +/** + * @brief This class makes http requests via boost::asio. + * + * @ingroup net + */ +class BoostHttpOnlySslClient : public HttpClient { + +public: + BoostHttpOnlySslClient(); + ~BoostHttpOnlySslClient() override; + + /** + * @brief Sends a request to the url. + * + * If there's no args specified, a GET request will be sent, otherwise a POST request will be sent. + * If at least 1 arg is marked as file, the content type of a request will be multipart/form-data, otherwise it will be application/x-www-form-urlencoded. + */ + std::string makeRequest(const Url& url, const std::vector<HttpReqArg>& args) const override; + +private: + mutable boost::asio::io_service _ioService; + const HttpParser _httpParser; +}; + +} + +#endif //TGBOT_BOOSTHTTPCLIENT_H diff --git a/include/tgbot/net/CurlHttpClient.h b/include/tgbot/net/CurlHttpClient.h new file mode 100644 index 0000000..b0ff6c3 --- /dev/null +++ b/include/tgbot/net/CurlHttpClient.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2018 Egor Pugin + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef TGBOT_CURLHTTPCLIENT_H +#define TGBOT_CURLHTTPCLIENT_H + +#ifdef HAVE_CURL + +#include <string> + +#include <curl/curl.h> + +#include "tgbot/net/HttpClient.h" +#include "tgbot/net/Url.h" +#include "tgbot/net/HttpReqArg.h" +#include "tgbot/net/HttpParser.h" + +namespace TgBot { + +/** + * @brief This class makes http requests via libcurl. + * + * @ingroup net + */ +class CurlHttpClient : public HttpClient { + +public: + CurlHttpClient(); + ~CurlHttpClient() override; + + /** + * @brief Sends a request to the url. + * + * If there's no args specified, a GET request will be sent, otherwise a POST request will be sent. + * If at least 1 arg is marked as file, the content type of a request will be multipart/form-data, otherwise it will be application/x-www-form-urlencoded. + */ + std::string makeRequest(const Url& url, const std::vector<HttpReqArg>& args) const override; + + /** + * @brief Raw curl settings storage for fine tuning. + */ + CURL* curlSettings; + +private: + const HttpParser _httpParser; +}; + +} + +#endif + +#endif //TGBOT_CURLHTTPCLIENT_H diff --git a/include/tgbot/net/HttpClient.h b/include/tgbot/net/HttpClient.h index 4378623..62b1875 100644 --- a/include/tgbot/net/HttpClient.h +++ b/include/tgbot/net/HttpClient.h @@ -1,4 +1,4 @@ -/* + /* * Copyright (c) 2015 Oleg Morozenkov * Copyright (c) 2018 Egor Pugin * @@ -26,14 +26,8 @@ #include <string> -#include <boost/asio.hpp> -#ifdef HAVE_CURL -#include <curl/curl.h> -#endif - #include "tgbot/net/Url.h" #include "tgbot/net/HttpReqArg.h" -#include "tgbot/net/HttpParser.h" namespace TgBot { @@ -56,66 +50,7 @@ public: virtual std::string makeRequest(const Url& url, const std::vector<HttpReqArg>& args) const = 0; }; -/** - * @brief This class makes http requests via boost::asio. - * - * @ingroup net - */ -class BoostHttpClient : public HttpClient { - -public: - /** - * @brief Returns instance which lives during all application lifetime. - */ - static BoostHttpClient& getInstance(); - - /** - * @brief Sends a request to the url. - * - * If there's no args specified, a GET request will be sent, otherwise a POST request will be sent. - * If at least 1 arg is marked as file, the content type of a request will be multipart/form-data, otherwise it will be application/x-www-form-urlencoded. - */ - std::string makeRequest(const Url& url, const std::vector<HttpReqArg>& args) const override; - -private: - mutable boost::asio::io_service _ioService; -}; - -#ifdef HAVE_CURL - -/** - * @brief This class makes http requests via libcurl. - * - * @ingroup net - */ -class CurlHttpClient : public HttpClient { - -public: - - /** - * @brief Raw curl settings storage for fine tuning. - */ - CURL* curlSettings; - - CurlHttpClient(); - ~CurlHttpClient(); - - /** - * @brief Returns instance which lives during all application lifetime. - */ - static CurlHttpClient& getInstance(); - - /** - * @brief Sends a request to the url. - * - * If there's no args specified, a GET request will be sent, otherwise a POST request will be sent. - * If at least 1 arg is marked as file, the content type of a request will be multipart/form-data, otherwise it will be application/x-www-form-urlencoded. - */ - std::string makeRequest(const Url& url, const std::vector<HttpReqArg>& args) const override; -}; - -#endif - } + #endif //TGBOT_HTTPCLIENT_H diff --git a/include/tgbot/net/HttpParser.h b/include/tgbot/net/HttpParser.h index d40619a..d4900a1 100644 --- a/include/tgbot/net/HttpParser.h +++ b/include/tgbot/net/HttpParser.h @@ -35,33 +35,13 @@ namespace TgBot { class HttpParser { public: - static HttpParser& getInstance(); - - std::string generateRequest(const Url& url, const std::vector<HttpReqArg>& args, bool isKeepAlive = false); - std::string generateMultipartFormData(const std::vector<HttpReqArg>& args, const std::string& bondary); - std::string generateMultipartBoundary(const std::vector<HttpReqArg>& args); - std::string generateWwwFormUrlencoded(const std::vector<HttpReqArg>& args); - std::string generateResponse(const std::string& data, const std::string& mimeType = "text/plain", short unsigned statusCode = 200, const std::string& statusStr = "OK", bool isKeepAlive = false); - - inline std::string parseRequest(const std::string& data, std::unordered_map<std::string, std::string>& headers) { - return parseHttp(true, data, headers); - } - - inline std::string parseRequest(const std::string& data) { - return parseHttp(true, data); - } - - inline std::string parseResponse(const std::string& data, std::unordered_map<std::string, std::string>& headers) { - return parseHttp(false, data, headers); - } - - inline std::string parseResponse(const std::string& data) { - return parseHttp(false, data); - } - -private: - std::string parseHttp(bool isRequest, const std::string& data, std::unordered_map<std::string, std::string>& headers); - std::string parseHttp(bool isRequest, const std::string& data); + std::string generateRequest(const Url& url, const std::vector<HttpReqArg>& args, bool isKeepAlive = false) const; + std::string generateMultipartFormData(const std::vector<HttpReqArg>& args, const std::string& bondary) const; + std::string generateMultipartBoundary(const std::vector<HttpReqArg>& args) const; + std::string generateWwwFormUrlencoded(const std::vector<HttpReqArg>& args) const; + std::string generateResponse(const std::string& data, const std::string& mimeType, unsigned short statusCode, const std::string& statusStr, bool isKeepAlive) const; + std::unordered_map<std::string, std::string> parseHeader(const std::string& data, bool isRequest) const; + std::string extractBody(const std::string& data) const; }; } diff --git a/include/tgbot/net/HttpReqArg.h b/include/tgbot/net/HttpReqArg.h index 7476366..a263224 100644 --- a/include/tgbot/net/HttpReqArg.h +++ b/include/tgbot/net/HttpReqArg.h @@ -24,6 +24,7 @@ #define TGBOT_HTTPPARAMETER_H #include <string> +#include <utility> #include <vector> #include <functional> @@ -39,36 +40,36 @@ namespace TgBot { class HttpReqArg { public: - template<typename T> - HttpReqArg(const std::string& name, const T& value, bool isFile = false, const std::string& mimeType = "text/plain", const std::string& fileName = "") : - name(name), value(boost::lexical_cast<std::string>(value)), isFile(isFile), mimeType(mimeType), fileName(fileName) - { - } + template<typename T> + HttpReqArg(std::string name, const T& value, bool isFile = false, std::string mimeType = "text/plain", std::string fileName = "") : + name(std::move(name)), value(boost::lexical_cast<std::string>(value)), isFile(isFile), mimeType(std::move(mimeType)), fileName(std::move(fileName)) + { + } - /** - * @brief Name of an argument. - */ - std::string name; + /** + * @brief Name of an argument. + */ + std::string name; - /** - * @brief Value of an argument. - */ - std::string value; + /** + * @brief Value of an argument. + */ + std::string value; - /** - * @brief Should be true if an argument value hold some file contents - */ - bool isFile = false; + /** + * @brief Should be true if an argument value hold some file contents + */ + bool isFile = false; - /** - * @brief Mime type of an argument value. This field makes sense only if isFile is true. - */ - std::string mimeType = "text/plain"; + /** + * @brief Mime type of an argument value. This field makes sense only if isFile is true. + */ + std::string mimeType = "text/plain"; - /** - * @brief Should be set if an argument value hold some file contents - */ - std::string fileName; + /** + * @brief Should be set if an argument value hold some file contents + */ + std::string fileName; }; } diff --git a/include/tgbot/net/HttpServer.h b/include/tgbot/net/HttpServer.h index 34cd9c7..a1c5a49 100644 --- a/include/tgbot/net/HttpServer.h +++ b/include/tgbot/net/HttpServer.h @@ -23,7 +23,9 @@ #ifndef TGBOT_HTTPSERVER_H #define TGBOT_HTTPSERVER_H +#include <iostream> #include <string> +#include <utility> #include <boost/asio.hpp> @@ -40,62 +42,146 @@ template<typename Protocol> class HttpServer { protected: - class Connection; + class Connection; public: - typedef std::function<std::string (const std::string&, const std::unordered_map<std::string, std::string>)> ServerHandler; - - HttpServer(std::shared_ptr<boost::asio::basic_socket_acceptor<Protocol>> acceptor, const ServerHandler& handler) : _acceptor(acceptor), _handler(handler) { - } - - /** - * @brief Starts receiving new connections. - */ - void start() { - auto socket(std::make_shared<boost::asio::basic_stream_socket<Protocol>>(_acceptor->get_io_service())); - auto connection(std::make_shared<Connection>(socket, _handler)); - _acceptor->async_accept(*connection->socket, [this, connection]() { - connection->start(); - start(); - }); - _ioService.run(); - } - - /** - * @brief Stops receiving new connections. - */ - void stop() { - _ioService.stop(); - } + typedef std::function<std::string (const std::string&, const std::unordered_map<std::string, std::string>&)> ServerHandler; + + HttpServer(const typename boost::asio::basic_socket_acceptor<Protocol>::endpoint_type& endpoint, ServerHandler handler) + : _ioService(), _acceptor(_ioService, endpoint), _socket(_ioService), _handler(std::move(handler)), _httpParser() + { + } + + /** + * @brief Starts receiving new connections. + */ + void start() { + _startAccept(); + _ioService.run(); + } + + /** + * @brief Stops receiving new connections. + */ + void stop() { + _ioService.stop(); + } protected: - class Connection { - - public: - Connection(std::shared_ptr<boost::asio::basic_stream_socket<Protocol>>& socket, const ServerHandler& handler) : socket(socket), _handler(handler) { - boost::asio::socket_base::keep_alive option(true); - socket.set_option(option); - } - - void start() { - data.reserve(10240); - socket->async_receive(data, [this]() { - std::unordered_map<std::string, std::string> headers; - std::string body = HttpParser::getInstance().parseResponse(data, headers); - socket->async_send(_handler(body, headers)); - }); - } - - std::shared_ptr<boost::asio::basic_stream_socket<Protocol>> socket; - std::string data; - - protected: - const ServerHandler _handler; - }; - - boost::asio::io_service _ioService; - std::shared_ptr<boost::asio::basic_socket_acceptor<Protocol>> _acceptor; - const ServerHandler _handler; + class Connection : public std::enable_shared_from_this<Connection> { + + public: + Connection(boost::asio::basic_stream_socket<Protocol> socket, ServerHandler handler, const HttpParser& httpParser) + : _socket(std::move(socket)), _handler(std::move(handler)), _httpParser(httpParser) + { + } + + void start() { + _readHeader(); + } + + protected: + boost::asio::basic_stream_socket<Protocol> _socket; + const ServerHandler _handler; + const HttpParser& _httpParser; + + void _readHeader() { + auto self(this->shared_from_this()); + + auto data(std::make_shared<boost::asio::streambuf>()); + data->prepare(1024); + + boost::asio::async_read_until( + _socket, + *data, + "\r\n\r\n", + [self, data](const boost::system::error_code& e, size_t n) { + if (e) { + std::cout << "error in HttpServer::Connection#_readHeader: " << e << std::endl; + return; + } + + boost::asio::streambuf::const_buffers_type bufs = data->data(); + std::string dataAsString(boost::asio::buffers_begin(bufs), boost::asio::buffers_begin(bufs) + n); + + auto headers(std::make_shared<std::unordered_map<std::string, std::string>>(self->_httpParser.parseHeader(dataAsString, true))); + + unsigned long long size; + auto contentLengthIter = headers->find("Content-Length"); + if (contentLengthIter != headers->end()) { + size = std::stoull(contentLengthIter->second); + } else { + size = 0; + } + + if (size == 0) { + std::string answer = self->_httpParser.generateResponse("Bad request", "text/plain", 400, "Bad request", false); + boost::asio::async_write( + self->_socket, + boost::asio::buffer(answer), + [](const boost::system::error_code& e, size_t n) { }); + return; + } + + data->consume(n); + self->_readBody(data, size, headers); + }); + } + + void _readBody(std::shared_ptr<boost::asio::streambuf> data, unsigned long long size, std::shared_ptr<std::unordered_map<std::string, std::string>> headers) { + auto self(this->shared_from_this()); + + data->prepare(size); + + boost::asio::async_read(_socket, + *data, + boost::asio::transfer_exactly(size - data->size()), + [self, data, size, headers](const boost::system::error_code& e, size_t n) { + if (e) { + std::cout << "error in HttpServer::Connection#_readBody: " << e << std::endl; + return; + } + + boost::asio::streambuf::const_buffers_type bufs = data->data(); + std::string dataAsString(boost::asio::buffers_begin(bufs), boost::asio::buffers_begin(bufs) + size); + + std::string answer; + try { + answer = self->_handler(dataAsString, *headers); + } catch (std::exception& e) { + std::cout << "error in HttpServer::Connection#_readBody answer: " << e.what() << std::endl; + answer = self->_httpParser.generateResponse("Internal server error", "text/plain", 500, "Internal server error", false); + } + boost::asio::async_write( + self->_socket, + boost::asio::buffer(answer), + [](const boost::system::error_code& e, size_t n) { }); + + self->_socket.close(); + }); + } + }; + + void _startAccept() { + _acceptor.async_accept(_socket, [this](const boost::system::error_code& e) { + if (e) { + std::cout << "error in HttpServer: " << e << std::endl; + _startAccept(); + return; + } + + auto connection(std::make_shared<Connection>(std::move(_socket), _handler, _httpParser)); + connection->start(); + + _startAccept(); + }); + } + + boost::asio::io_service _ioService; + boost::asio::basic_socket_acceptor<Protocol> _acceptor; + boost::asio::basic_stream_socket<Protocol> _socket; + const ServerHandler _handler; + const HttpParser _httpParser; }; } diff --git a/include/tgbot/net/TgLongPoll.h b/include/tgbot/net/TgLongPoll.h index a0281f1..643031e 100644 --- a/include/tgbot/net/TgLongPoll.h +++ b/include/tgbot/net/TgLongPoll.h @@ -37,21 +37,21 @@ namespace TgBot { class TgLongPoll { public: - TgLongPoll(const Api* api, const EventHandler* eventHandler, int32_t, int32_t, const std::shared_ptr<std::vector<std::string>>&); - TgLongPoll(const Bot& bot, int32_t = 100, int32_t = 60, const std::shared_ptr<std::vector<std::string>>& = nullptr); + TgLongPoll(const Api* api, const EventHandler* eventHandler, int32_t, int32_t, const std::shared_ptr<std::vector<std::string>>&); + TgLongPoll(const Bot& bot, int32_t = 100, int32_t = 60, const std::shared_ptr<std::vector<std::string>>& = nullptr); - /** - * @brief Starts long poll. After new update will come, this method will parse it and send to EventHandler which invokes your listeners. Designed to be executed in a loop. - */ - void start(); + /** + * @brief Starts long poll. After new update will come, this method will parse it and send to EventHandler which invokes your listeners. Designed to be executed in a loop. + */ + void start(); private: - const Api* _api; - const EventHandler* _eventHandler; - int32_t _lastUpdateId = 0; - int32_t _limit; - int32_t _timeout; - std::shared_ptr<std::vector<std::string>> _allowupdates; + const Api* _api; + const EventHandler* _eventHandler; + int32_t _lastUpdateId = 0; + int32_t _limit; + int32_t _timeout; + std::shared_ptr<std::vector<std::string>> _allowupdates; }; } diff --git a/include/tgbot/net/TgWebhookLocalServer.h b/include/tgbot/net/TgWebhookLocalServer.h index 685979d..d7cb06e 100644 --- a/include/tgbot/net/TgWebhookLocalServer.h +++ b/include/tgbot/net/TgWebhookLocalServer.h @@ -20,8 +20,8 @@ * SOFTWARE. */ -#ifndef TGBOT_TGWEBHOOKTCPSERVER_H -#define TGBOT_TGWEBHOOKTCPSERVER_H +#ifndef TGBOT_TGWEBHOOKLOCALSERVER_H +#define TGBOT_TGWEBHOOKLOCALSERVER_H #ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS @@ -37,19 +37,21 @@ namespace TgBot { class TgWebhookLocalServer : public TgWebhookServer<boost::asio::local::stream_protocol> { public: - TgWebhookLocalServer(std::shared_ptr<boost::asio::basic_socket_acceptor<boost::asio::local::stream_protocol>>& acceptor, const std::string& path, EventHandler* eventHandler) = delete; - - TgWebhookLocalServer(const std::string& path, const EventHandler* eventHandler) : - TgWebhookServer<boost::asio::local::stream_protocol>(std::make_shared<boost::asio::basic_socket_acceptor<boost::asio::local::stream_protocol>>(_ioService, boost::asio::local::stream_protocol::endpoint(path)), path, eventHandler) - { - } - - TgWebhookLocalServer(const std::string& path, const Bot& bot) : TgWebhookLocalServer(path, &bot.getEventHandler()) { - } + TgWebhookLocalServer(const std::string& unixSocketPath, const std::string& path, const EventHandler& eventHandler) + : TgWebhookServer<boost::asio::local::stream_protocol>(boost::asio::local::stream_protocol::endpoint(unixSocketPath), + path, eventHandler) + { + } + + TgWebhookLocalServer(const std::string& unixSocketPath, const Bot& bot) + : TgWebhookServer<boost::asio::local::stream_protocol>(boost::asio::local::stream_protocol::endpoint(unixSocketPath), + bot) + { + } }; } #endif //BOOST_ASIO_HAS_LOCAL_SOCKETS -#endif //TGBOT_TGWEBHOOKTCPSERVER_H +#endif //TGBOT_TGWEBHOOKLOCALSERVER_H diff --git a/include/tgbot/net/TgWebhookServer.h b/include/tgbot/net/TgWebhookServer.h index 696d126..953c1a9 100644 --- a/include/tgbot/net/TgWebhookServer.h +++ b/include/tgbot/net/TgWebhookServer.h @@ -23,6 +23,8 @@ #ifndef TGBOT_TGHTTPSERVER_H #define TGBOT_TGHTTPSERVER_H +#include <utility> + #include "tgbot/Bot.h" #include "tgbot/EventHandler.h" #include "tgbot/TgTypeParser.h" @@ -34,22 +36,31 @@ template<typename Protocol> class TgWebhookServer : public HttpServer<Protocol> { public: - TgWebhookServer(std::shared_ptr<boost::asio::basic_socket_acceptor<Protocol>> acceptor, const typename HttpServer<Protocol>::ServerHandler& handler) = delete; - - TgWebhookServer(std::shared_ptr<boost::asio::basic_socket_acceptor<Protocol>> acceptor, const std::string& path, const EventHandler* eventHandler) : - HttpServer<Protocol>(acceptor, [eventHandler, &path](const std::string& data, const std::unordered_map<std::string, std::string>& headers) -> std::string { - if (headers.at("method") == "POST" && headers.at("path") == path) { - eventHandler->handleUpdate(TgTypeParser::getInstance().parseJsonAndGetUpdate(TgTypeParser::getInstance().parseJson(data))); - } - return HttpParser::getInstance().generateResponse(""); - }) - { - } - - TgWebhookServer(std::shared_ptr<boost::asio::basic_socket_acceptor<Protocol>> acceptor, const std::string& path, const Bot& bot) : - TgWebhookServer(acceptor, path, &bot.getEventHandler()) - { - } + TgWebhookServer(const typename boost::asio::basic_socket_acceptor<Protocol>::endpoint_type& endpoint, const typename HttpServer<Protocol>::ServerHandler& handler) = delete; + + TgWebhookServer(const typename boost::asio::basic_socket_acceptor<Protocol>::endpoint_type& endpoint, std::string path, const EventHandler& eventHandler) + : HttpServer<Protocol>(endpoint, + [this](const std::string& _1, const std::unordered_map<std::string, std::string>& _2) { return _handle(_1, _2); }), + _path(std::move(path)), _eventHandler(eventHandler), _tgTypeParser() + { + } + + TgWebhookServer(const typename boost::asio::basic_socket_acceptor<Protocol>::endpoint_type& endpoint, const Bot& bot) + : TgWebhookServer(endpoint, "/" + bot.getToken(), bot.getEventHandler()) + { + } + +private: + std::string _handle(const std::string& data, const std::unordered_map<std::string, std::string>& headers) { + if (headers.at("_method") == "POST" && headers.at("_path") == _path) { + _eventHandler.handleUpdate(_tgTypeParser.parseJsonAndGetUpdate(_tgTypeParser.parseJson(data))); + } + return HttpServer<Protocol>::_httpParser.generateResponse("", "text/plain", 200, "OK", false); + } + + const EventHandler& _eventHandler; + const std::string _path; + const TgTypeParser _tgTypeParser; }; } diff --git a/include/tgbot/net/TgWebhookTcpServer.h b/include/tgbot/net/TgWebhookTcpServer.h index de1f3e7..ad5a5b8 100644 --- a/include/tgbot/net/TgWebhookTcpServer.h +++ b/include/tgbot/net/TgWebhookTcpServer.h @@ -34,15 +34,17 @@ namespace TgBot { class TgWebhookTcpServer : public TgWebhookServer<boost::asio::ip::tcp> { public: - TgWebhookTcpServer(std::shared_ptr<boost::asio::basic_socket_acceptor<boost::asio::ip::tcp>> acceptor, const std::string& path, EventHandler* eventHandler) = delete; - - TgWebhookTcpServer(unsigned short port, const std::string& path, const EventHandler* eventHandler) : - TgWebhookServer(std::shared_ptr<boost::asio::basic_socket_acceptor<boost::asio::ip::tcp>>(new boost::asio::ip::tcp::acceptor(_ioService, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port))), path, eventHandler) - { - } - - TgWebhookTcpServer(const std::string& path, const Bot& bot) : TgWebhookTcpServer(path, &bot.getEventHandler()) { - } + TgWebhookTcpServer(unsigned short port, const std::string& path, const EventHandler& eventHandler) + : TgWebhookServer<boost::asio::ip::tcp>(boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port), + path, eventHandler) + { + } + + TgWebhookTcpServer(unsigned short port, const Bot& bot) + : TgWebhookServer<boost::asio::ip::tcp>(boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port), + bot) + { + } }; } diff --git a/include/tgbot/net/Url.h b/include/tgbot/net/Url.h index c039355..f9226e5 100644 --- a/include/tgbot/net/Url.h +++ b/include/tgbot/net/Url.h @@ -35,32 +35,32 @@ namespace TgBot { class Url { public: - Url(const std::string& url); + Url(const std::string& url); - /** - * @brief Protocol part of an url. Example: https:// - */ - std::string protocol; + /** + * @brief Protocol part of an url. Example: https:// + */ + std::string protocol; - /** - * @brief Host part of an url. Example: www.example.com - */ - std::string host; + /** + * @brief Host part of an url. Example: www.example.com + */ + std::string host; - /** - * @brief Path part of an url including preceding '/' char. Example: /index.html - */ - std::string path; + /** + * @brief Path part of an url including preceding '/' char. Example: /index.html + */ + std::string path; - /** - * @brief Query part of an url without '?' char. Example: a=1&b=2&c=3 - */ - std::string query; + /** + * @brief Query part of an url without '?' char. Example: a=1&b=2&c=3 + */ + std::string query; - /** - * @brief Fragment part of an url without '#' char. Example: section1 - */ - std::string fragment; + /** + * @brief Fragment part of an url without '#' char. Example: section1 + */ + std::string fragment; }; } diff --git a/include/tgbot/tgbot.h b/include/tgbot/tgbot.h index 687783b..0e43f18 100644 --- a/include/tgbot/tgbot.h +++ b/include/tgbot/tgbot.h @@ -23,48 +23,101 @@ #ifndef TGBOT_TGBOT_H #define TGBOT_TGBOT_H -#include "tgbot/Bot.h" #include "tgbot/Api.h" -#include "tgbot/TgException.h" -#include "tgbot/TgTypeParser.h" +#include "tgbot/Bot.h" #include "tgbot/EventBroadcaster.h" #include "tgbot/EventHandler.h" +#include "tgbot/TgException.h" +#include "tgbot/TgTypeParser.h" +#include "tgbot/net/BoostHttpOnlySslClient.h" +#include "tgbot/net/CurlHttpClient.h" +#include "tgbot/net/HttpClient.h" +#include "tgbot/net/HttpParser.h" +#include "tgbot/net/HttpReqArg.h" +#include "tgbot/net/HttpServer.h" +#include "tgbot/net/TgLongPoll.h" +#include "tgbot/net/TgWebhookLocalServer.h" +#include "tgbot/net/TgWebhookServer.h" +#include "tgbot/net/TgWebhookTcpServer.h" +#include "tgbot/net/Url.h" +#include "tgbot/tgbot.h" +#include "tgbot/tools/FileTools.h" +#include "tgbot/tools/StringTools.h" +#include "tgbot/types/Animation.h" #include "tgbot/types/Audio.h" +#include "tgbot/types/CallbackGame.h" +#include "tgbot/types/CallbackQuery.h" +#include "tgbot/types/Chat.h" +#include "tgbot/types/ChatMember.h" +#include "tgbot/types/ChatPhoto.h" +#include "tgbot/types/ChosenInlineResult.h" #include "tgbot/types/Contact.h" #include "tgbot/types/Document.h" +#include "tgbot/types/File.h" #include "tgbot/types/ForceReply.h" +#include "tgbot/types/Game.h" +#include "tgbot/types/GameHighScore.h" #include "tgbot/types/GenericReply.h" +#include "tgbot/types/InlineKeyboardButton.h" +#include "tgbot/types/InlineKeyboardMarkup.h" +#include "tgbot/types/InlineQuery.h" +#include "tgbot/types/InlineQueryResult.h" +#include "tgbot/types/InlineQueryResultArticle.h" +#include "tgbot/types/InlineQueryResultAudio.h" +#include "tgbot/types/InlineQueryResultCachedAudio.h" +#include "tgbot/types/InlineQueryResultCachedDocument.h" +#include "tgbot/types/InlineQueryResultCachedGif.h" +#include "tgbot/types/InlineQueryResultCachedMpeg4Gif.h" +#include "tgbot/types/InlineQueryResultCachedPhoto.h" +#include "tgbot/types/InlineQueryResultCachedSticker.h" +#include "tgbot/types/InlineQueryResultCachedVideo.h" +#include "tgbot/types/InlineQueryResultCachedVoice.h" +#include "tgbot/types/InlineQueryResultContact.h" +#include "tgbot/types/InlineQueryResultDocument.h" +#include "tgbot/types/InlineQueryResultGame.h" +#include "tgbot/types/InlineQueryResultGif.h" +#include "tgbot/types/InlineQueryResultLocation.h" +#include "tgbot/types/InlineQueryResultMpeg4Gif.h" +#include "tgbot/types/InlineQueryResultPhoto.h" +#include "tgbot/types/InlineQueryResultVenue.h" +#include "tgbot/types/InlineQueryResultVideo.h" +#include "tgbot/types/InlineQueryResultVoice.h" +#include "tgbot/types/InputContactMessageContent.h" #include "tgbot/types/InputFile.h" +#include "tgbot/types/InputLocationMessageContent.h" +#include "tgbot/types/InputMedia.h" +#include "tgbot/types/InputMediaPhoto.h" +#include "tgbot/types/InputMediaVideo.h" +#include "tgbot/types/InputMessageContent.h" +#include "tgbot/types/InputTextMessageContent.h" +#include "tgbot/types/InputVenueMessageContent.h" +#include "tgbot/types/Invoice.h" +#include "tgbot/types/KeyboardButton.h" +#include "tgbot/types/LabeledPrice.h" #include "tgbot/types/Location.h" +#include "tgbot/types/MaskPosition.h" #include "tgbot/types/Message.h" +#include "tgbot/types/MessageEntity.h" +#include "tgbot/types/OrderInfo.h" #include "tgbot/types/PhotoSize.h" -#include "tgbot/types/ReplyKeyboardRemove.h" +#include "tgbot/types/PreCheckoutQuery.h" #include "tgbot/types/ReplyKeyboardMarkup.h" +#include "tgbot/types/ReplyKeyboardRemove.h" +#include "tgbot/types/ResponseParameters.h" +#include "tgbot/types/ShippingAddress.h" +#include "tgbot/types/ShippingOption.h" +#include "tgbot/types/ShippingQuery.h" #include "tgbot/types/Sticker.h" +#include "tgbot/types/StickerSet.h" +#include "tgbot/types/SuccessfulPayment.h" #include "tgbot/types/Update.h" #include "tgbot/types/User.h" #include "tgbot/types/UserProfilePhotos.h" +#include "tgbot/types/Venue.h" #include "tgbot/types/Video.h" #include "tgbot/types/VideoNote.h" -#include "tgbot/types/InlineQuery.h" -#include "tgbot/types/InlineQueryResult.h" -#include "tgbot/types/InlineQueryResultArticle.h" -#include "tgbot/types/InlineQueryResultGif.h" -#include "tgbot/types/InlineQueryResultMpeg4Gif.h" -#include "tgbot/types/InlineQueryResultPhoto.h" -#include "tgbot/types/InlineQueryResultVideo.h" -#include "tgbot/types/ChosenInlineResult.h" -#include "tgbot/tools/StringTools.h" -#include "tgbot/tools/FileTools.h" -#include "tgbot/net/HttpClient.h" -#include "tgbot/net/HttpParser.h" -#include "tgbot/net/HttpReqArg.h" -#include "tgbot/net/HttpServer.h" -#include "tgbot/net/TgLongPoll.h" -#include "tgbot/net/TgWebhookLocalServer.h" -#include "tgbot/net/TgWebhookServer.h" -#include "tgbot/net/TgWebhookTcpServer.h" -#include "tgbot/net/Url.h" +#include "tgbot/types/Voice.h" +#include "tgbot/types/WebhookInfo.h" /** * @defgroup general diff --git a/include/tgbot/tools/StringTools.h b/include/tgbot/tools/StringTools.h index 002757a..0f72045 100644 --- a/include/tgbot/tools/StringTools.h +++ b/include/tgbot/tools/StringTools.h @@ -82,9 +82,9 @@ std::string urlDecode(const std::string& value); * @return Array of substrings */ inline std::vector<std::string> split(const std::string& str, char delimiter) { - std::vector<std::string> result; - split(str, delimiter, result); - return result; + std::vector<std::string> result; + split(str, delimiter, result); + return result; } } diff --git a/include/tgbot/types/Animation.h b/include/tgbot/types/Animation.h index ab8dd54..ddd7ca0 100644 --- a/include/tgbot/types/Animation.h +++ b/include/tgbot/types/Animation.h @@ -40,32 +40,32 @@ namespace TgBot { */ class Animation { public: - typedef std::shared_ptr<Animation> Ptr; + typedef std::shared_ptr<Animation> Ptr; - /** - * @brief Unique file identifier. - */ - std::string fileId; + /** + * @brief Unique file identifier. + */ + std::string fileId; - /** - * @brief Optional. Animation thumbnail as defined by sender. - */ - PhotoSize::Ptr thumb; + /** + * @brief Optional. Animation thumbnail as defined by sender. + */ + PhotoSize::Ptr thumb; - /** - * @brief Optional. Original animation filename as defined by sender. - */ - std::string fileName; + /** + * @brief Optional. Original animation filename as defined by sender. + */ + std::string fileName; - /** - * @brief Optional. MIME type of the file as defined by sender. - */ - std::string mimeType; + /** + * @brief Optional. MIME type of the file as defined by sender. + */ + std::string mimeType; - /** - * @brief Optional. File size. - */ - int32_t fileSize; + /** + * @brief Optional. File size. + */ + int32_t fileSize; }; } diff --git a/include/tgbot/types/Audio.h b/include/tgbot/types/Audio.h index e640bce..3b8b3e3 100644 --- a/include/tgbot/types/Audio.h +++ b/include/tgbot/types/Audio.h @@ -36,39 +36,39 @@ namespace TgBot { class Audio { public: - typedef std::shared_ptr<Audio> Ptr; + typedef std::shared_ptr<Audio> Ptr; - /** - * @brief Unique identifier for this file. - */ - std::string fileId; + /** + * @brief Unique identifier for this file. + */ + std::string fileId; - /** - * @brief Duration of the audio in seconds as defined by sender. - */ - int32_t duration; + /** + * @brief Duration of the audio in seconds as defined by sender. + */ + int32_t duration; - /** - * @brief Optional. Performer of the audio as defined by sender - * or by audio tags - */ - std::string performer; + /** + * @brief Optional. Performer of the audio as defined by sender + * or by audio tags + */ + std::string performer; - /** - * @brief Optional. Title of the audio as defined by sender or - * by audio tags - */ - std::string title; + /** + * @brief Optional. Title of the audio as defined by sender or + * by audio tags + */ + std::string title; - /** - * @brief Optional. MIME type of the file as defined by sender. - */ - std::string mimeType; + /** + * @brief Optional. MIME type of the file as defined by sender. + */ + std::string mimeType; - /** - * @brief Optional. File size. - */ - int32_t fileSize; + /** + * @brief Optional. File size. + */ + int32_t fileSize; }; } diff --git a/include/tgbot/types/CallbackGame.h b/include/tgbot/types/CallbackGame.h index 9aabc0a..e7f5cef 100644 --- a/include/tgbot/types/CallbackGame.h +++ b/include/tgbot/types/CallbackGame.h @@ -35,7 +35,7 @@ namespace TgBot { */ class CallbackGame { public: - typedef std::shared_ptr<CallbackGame> Ptr; + typedef std::shared_ptr<CallbackGame> Ptr; }; } diff --git a/include/tgbot/types/CallbackQuery.h b/include/tgbot/types/CallbackQuery.h index 4ee4538..e0d25f7 100644 --- a/include/tgbot/types/CallbackQuery.h +++ b/include/tgbot/types/CallbackQuery.h @@ -19,42 +19,42 @@ namespace TgBot { */ class CallbackQuery { public: - typedef std::shared_ptr<CallbackQuery> Ptr; - - /** - * @brief Unique identifier for this query. - */ - std::string id; - - /** - * @brief Sender. - */ - User::Ptr from; - - /** - * @brief Optional. Message with the callback button that originated the query. Note that message content and message date will not be available if the message is too old. - */ - Message::Ptr message; - - /** - * @brief Optional. Identifier of the message sent via the bot in inline mode, that originated the query. - */ - std::string inlineMessageId; - - /** - * @brief Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games. - */ - std::string chatInstance; - - /** - * @brief Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field. - */ - std::string data; - - /* - * @brief Optional. Short name of a Game to be returned, serves as the unique identifier for the game - */ - std::string gameShortName; + typedef std::shared_ptr<CallbackQuery> Ptr; + + /** + * @brief Unique identifier for this query. + */ + std::string id; + + /** + * @brief Sender. + */ + User::Ptr from; + + /** + * @brief Optional. Message with the callback button that originated the query. Note that message content and message date will not be available if the message is too old. + */ + Message::Ptr message; + + /** + * @brief Optional. Identifier of the message sent via the bot in inline mode, that originated the query. + */ + std::string inlineMessageId; + + /** + * @brief Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games. + */ + std::string chatInstance; + + /** + * @brief Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field. + */ + std::string data; + + /* + * @brief Optional. Short name of a Game to be returned, serves as the unique identifier for the game + */ + std::string gameShortName; }; } diff --git a/include/tgbot/types/Chat.h b/include/tgbot/types/Chat.h index 37e1cd0..a402ebb 100644 --- a/include/tgbot/types/Chat.h +++ b/include/tgbot/types/Chat.h @@ -38,89 +38,89 @@ class Message; class Chat { public: - typedef std::shared_ptr<Chat> Ptr; - - /** - * @brief Enum of possible types of a chat. - */ - enum class Type { - Private, Group, Supergroup, Channel - }; - - /** - * @brief Unique identifier for this chat, not exceeding 1e13 by absolute value - */ - int64_t id; - - /** - * @brief Type of chat: can be either "private", "group", "supergroup, or "channel". - */ - Type type; - - /** - * @brief Optional. Title for channels and group chat - */ - std::string title; - - /** - * @brief Optional. Username for - * private chats and channels - */ - std::string username; - - /** - * @brief Optional. First name of the - * other party in private chat - */ - std::string firstName; - - /** - * @brief Optional. Last name of the - * other party in private chat - */ - std::string lastName; - - /** - * @brief Optional. True if a group - * has ‘All Members Are Admins’ enabled. - */ - bool allMembersAreAdministrators; - - /** - * @brief Optional. Chat photo. - * Returned only in getChat. - */ - ChatPhoto::Ptr photo; - - /** - * @brief Optional. Description, for supergroups and channel chats. - * Returned only in getChat. - */ - std::string description; - - /** - * @brief Optional. Chat invite link, for supergroups and channel chats. - * Returned only in getChat. - */ - std::string inviteLink; - - /** - * @brief Optional. Pinned message, for supergroups and channel chats. - * Returned only in getChat. - */ - std::shared_ptr<Message> pinnedMessage; - - /** - * @brief Optional. For supergroups, name of group sticker set. - * Returned only in getChat. - */ - std::string stickerSetName; - - /** - * @brief Optional. True, if the bot can change the group sticker set. - * Returned only in getChat. - */ - bool canSetStickerSet; + typedef std::shared_ptr<Chat> Ptr; + + /** + * @brief Enum of possible types of a chat. + */ + enum class Type { + Private, Group, Supergroup, Channel + }; + + /** + * @brief Unique identifier for this chat, not exceeding 1e13 by absolute value + */ + int64_t id; + + /** + * @brief Type of chat: can be either "private", "group", "supergroup, or "channel". + */ + Type type; + + /** + * @brief Optional. Title for channels and group chat + */ + std::string title; + + /** + * @brief Optional. Username for + * private chats and channels + */ + std::string username; + + /** + * @brief Optional. First name of the + * other party in private chat + */ + std::string firstName; + + /** + * @brief Optional. Last name of the + * other party in private chat + */ + std::string lastName; + + /** + * @brief Optional. True if a group + * has ‘All Members Are Admins’ enabled. + */ + bool allMembersAreAdministrators; + + /** + * @brief Optional. Chat photo. + * Returned only in getChat. + */ + ChatPhoto::Ptr photo; + + /** + * @brief Optional. Description, for supergroups and channel chats. + * Returned only in getChat. + */ + std::string description; + + /** + * @brief Optional. Chat invite link, for supergroups and channel chats. + * Returned only in getChat. + */ + std::string inviteLink; + + /** + * @brief Optional. Pinned message, for supergroups and channel chats. + * Returned only in getChat. + */ + std::shared_ptr<Message> pinnedMessage; + + /** + * @brief Optional. For supergroups, name of group sticker set. + * Returned only in getChat. + */ + std::string stickerSetName; + + /** + * @brief Optional. True, if the bot can change the group sticker set. + * Returned only in getChat. + */ + bool canSetStickerSet; }; } diff --git a/include/tgbot/types/ChatMember.h b/include/tgbot/types/ChatMember.h index cc16ae2..facfec2 100644 --- a/include/tgbot/types/ChatMember.h +++ b/include/tgbot/types/ChatMember.h @@ -19,87 +19,87 @@ namespace TgBot { */ class ChatMember { public: - typedef std::shared_ptr<ChatMember> Ptr; - - /** - * @brief Information about the user - */ - User::Ptr user; - - /** - * @brief The member's status in the chat. Can be “creator”, “administrator”, “member”, “restricted”, “left” or “kicked” - */ - std::string status; - - /** - * @brief Optional. Restricted and kicked only. Date when restrictions will be lifted for this user, unix time. - */ - uint64_t untilDate; - - /** - * @brief Optional. Administrators only. True, if the bot is allowed to edit administrator privileges of that user. - */ - bool canBeEdited = false; - - /** - * @brief Optional. Administrators only. True, if the administrator can change the chat title, photo and other settings. - */ - bool canChangeInfo = false; - - /** - * @brief Optional. Administrators only. True, if the administrator can post in the channel, channels only. - */ - bool canPostMessages = false; - - /** - * @brief Optional. Administrators only. True, if the administrator can edit messages of other users and can pin messages, channels only. - */ - bool canEditMessages = false; - - /** - * @brief Optional. Administrators only. True, if the administrator can delete messages of other users. - */ - bool canDeleteMessages = false; - - /** - * @brief Optional. Administrators only. True, if the administrator can invite new users to the chat. - */ - bool canInviteUsers = false; - - /** - * @brief Optional. Administrators only. True, if the administrator can restrict, ban or unban chat members. - */ - bool canRestrictMembers = false; - - /** - * @brief Optional. Administrators only. True, if the administrator can pin messages, supergroups only. - */ - bool canPinMessages = false; - - /** - * @brief Optional. Administrators only. True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user). - */ - bool canPromoteMembers = false; - - /** - * @brief Optional. Restricted only. True, if the user can send text messages, contacts, locations and venues. - */ - bool canSendMessages = false; - - /** - * @brief Optional. Restricted only. True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages. - */ - bool canSendMediaMessages = false; - - /** - * @brief Optional. Restricted only. True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages. - */ - bool canSendOtherMessages = false; - - /** - * @brief Optional. Restricted only. True, if user may add web page previews to his messages, implies can_send_media_messages. - */ - bool canAddWebPagePreviews = false; + typedef std::shared_ptr<ChatMember> Ptr; + + /** + * @brief Information about the user + */ + User::Ptr user; + + /** + * @brief The member's status in the chat. Can be “creator”, “administrator”, “member”, “restricted”, “left” or “kicked” + */ + std::string status; + + /** + * @brief Optional. Restricted and kicked only. Date when restrictions will be lifted for this user, unix time. + */ + uint64_t untilDate; + + /** + * @brief Optional. Administrators only. True, if the bot is allowed to edit administrator privileges of that user. + */ + bool canBeEdited = false; + + /** + * @brief Optional. Administrators only. True, if the administrator can change the chat title, photo and other settings. + */ + bool canChangeInfo = false; + + /** + * @brief Optional. Administrators only. True, if the administrator can post in the channel, channels only. + */ + bool canPostMessages = false; + + /** + * @brief Optional. Administrators only. True, if the administrator can edit messages of other users and can pin messages, channels only. + */ + bool canEditMessages = false; + + /** + * @brief Optional. Administrators only. True, if the administrator can delete messages of other users. + */ + bool canDeleteMessages = false; + + /** + * @brief Optional. Administrators only. True, if the administrator can invite new users to the chat. + */ + bool canInviteUsers = false; + + /** + * @brief Optional. Administrators only. True, if the administrator can restrict, ban or unban chat members. + */ + bool canRestrictMembers = false; + + /** + * @brief Optional. Administrators only. True, if the administrator can pin messages, supergroups only. + */ + bool canPinMessages = false; + + /** + * @brief Optional. Administrators only. True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user). + */ + bool canPromoteMembers = false; + + /** + * @brief Optional. Restricted only. True, if the user can send text messages, contacts, locations and venues. + */ + bool canSendMessages = false; + + /** + * @brief Optional. Restricted only. True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages. + */ + bool canSendMediaMessages = false; + + /** + * @brief Optional. Restricted only. True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages. + */ + bool canSendOtherMessages = false; + + /** + * @brief Optional. Restricted only. True, if user may add web page previews to his messages, implies can_send_media_messages. + */ + bool canAddWebPagePreviews = false; }; } diff --git a/include/tgbot/types/ChatPhoto.h b/include/tgbot/types/ChatPhoto.h index a79ed3d..d39b87a 100644 --- a/include/tgbot/types/ChatPhoto.h +++ b/include/tgbot/types/ChatPhoto.h @@ -35,17 +35,17 @@ namespace TgBot { */ class ChatPhoto { public: - typedef std::shared_ptr<ChatPhoto> Ptr; + typedef std::shared_ptr<ChatPhoto> Ptr; - /** - * @brief Unique file identifier of small (160x160) chat photo. This file_id can be used only for photo download. - */ - std::string smallFileId; + /** + * @brief Unique file identifier of small (160x160) chat photo. This file_id can be used only for photo download. + */ + std::string smallFileId; - /** - * @brief Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download. - */ - std::string bigFileId; + /** + * @brief Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download. + */ + std::string bigFileId; }; } diff --git a/include/tgbot/types/ChosenInlineResult.h b/include/tgbot/types/ChosenInlineResult.h index 9808366..7d00520 100644 --- a/include/tgbot/types/ChosenInlineResult.h +++ b/include/tgbot/types/ChosenInlineResult.h @@ -20,35 +20,35 @@ namespace TgBot { */ class ChosenInlineResult { public: - typedef std::shared_ptr<ChosenInlineResult> Ptr; - - /** - * @brief The unique identifier for the result that was chosen. - */ - std::string resultId; - - /** - * @brief The user that chose the result. - */ - User::Ptr from; - - /** - * @brief Optional. Sender location, only for bots that require user location - */ - Location::Ptr location; - - /** - * @brief Optional. Identifier of the sent inline message. - * - * Available only if there is an inline keyboard attached to the message. - * Will be also received in callback queries and can be used to edit the message. - */ - std::string inlineMessageId; - - /** - * @brief The query that was used to obtain the result. - */ - std::string query; + typedef std::shared_ptr<ChosenInlineResult> Ptr; + + /** + * @brief The unique identifier for the result that was chosen. + */ + std::string resultId; + + /** + * @brief The user that chose the result. + */ + User::Ptr from; + + /** + * @brief Optional. Sender location, only for bots that require user location + */ + Location::Ptr location; + + /** + * @brief Optional. Identifier of the sent inline message. + * + * Available only if there is an inline keyboard attached to the message. + * Will be also received in callback queries and can be used to edit the message. + */ + std::string inlineMessageId; + + /** + * @brief The query that was used to obtain the result. + */ + std::string query; }; } diff --git a/include/tgbot/types/Contact.h b/include/tgbot/types/Contact.h index 3b08a15..eb17e5a 100644 --- a/include/tgbot/types/Contact.h +++ b/include/tgbot/types/Contact.h @@ -36,27 +36,27 @@ namespace TgBot { class Contact { public: - typedef std::shared_ptr<Contact> Ptr; + typedef std::shared_ptr<Contact> Ptr; - /** - * @brief Contact's phone number. - */ - std::string phoneNumber; + /** + * @brief Contact's phone number. + */ + std::string phoneNumber; - /** - * @brief Contact's first name. - */ - std::string firstName; + /** + * @brief Contact's first name. + */ + std::string firstName; - /** - * @brief Optional. Contact's last name. - */ - std::string lastName; + /** + * @brief Optional. Contact's last name. + */ + std::string lastName; - /** - * @brief Optional. Contact's user identifier in Telegram. - */ - std::string userId; + /** + * @brief Optional. Contact's user identifier in Telegram. + */ + std::string userId; }; } diff --git a/include/tgbot/types/Document.h b/include/tgbot/types/Document.h index 4fb43c2..09be9a5 100644 --- a/include/tgbot/types/Document.h +++ b/include/tgbot/types/Document.h @@ -38,32 +38,32 @@ namespace TgBot { class Document { public: - typedef std::shared_ptr<Document> Ptr; + typedef std::shared_ptr<Document> Ptr; - /** - * @brief Unique file identifier. - */ - std::string fileId; + /** + * @brief Unique file identifier. + */ + std::string fileId; - /** - * @brief Optional. Document thumbnail as defined by sender. - */ - PhotoSize::Ptr thumb; + /** + * @brief Optional. Document thumbnail as defined by sender. + */ + PhotoSize::Ptr thumb; - /** - * @brief Optional. Original filename as defined by sender. - */ - std::string fileName; + /** + * @brief Optional. Original filename as defined by sender. + */ + std::string fileName; - /** - * @brief Optional. MIME type of the file as defined by sender. - */ - std::string mimeType; + /** + * @brief Optional. MIME type of the file as defined by sender. + */ + std::string mimeType; - /** - * @brief Optional. File size. - */ - int32_t fileSize; + /** + * @brief Optional. File size. + */ + int32_t fileSize; }; } diff --git a/include/tgbot/types/File.h b/include/tgbot/types/File.h index 8040d95..c2daee7 100644 --- a/include/tgbot/types/File.h +++ b/include/tgbot/types/File.h @@ -23,24 +23,24 @@ namespace TgBot { class File { public: - typedef std::shared_ptr<File> Ptr; - - /** - * @brief Unique identifier for this file - */ - std::string fileId; - - /** - * @brief Optional. File size, if known - */ - int32_t fileSize; - - /** - * @brief Optional. File path. - * - * Use https://api.telegram.org/file/bot<token>/<file_path> to get the file. - */ - std::string filePath; + typedef std::shared_ptr<File> Ptr; + + /** + * @brief Unique identifier for this file + */ + std::string fileId; + + /** + * @brief Optional. File size, if known + */ + int32_t fileSize; + + /** + * @brief Optional. File path. + * + * Use https://api.telegram.org/file/bot<token>/<file_path> to get the file. + */ + std::string filePath; }; } diff --git a/include/tgbot/types/ForceReply.h b/include/tgbot/types/ForceReply.h index c5c5a7b..f1bf5da 100644 --- a/include/tgbot/types/ForceReply.h +++ b/include/tgbot/types/ForceReply.h @@ -42,17 +42,17 @@ namespace TgBot { class ForceReply : public GenericReply { public: - typedef std::shared_ptr<ForceReply> Ptr; + typedef std::shared_ptr<ForceReply> Ptr; - /** - * @brief Shows reply interface to the user, as if they manually selected the bot‘s message and tapped ’Reply' - */ - const bool forceReply = true; + /** + * @brief Shows reply interface to the user, as if they manually selected the bot‘s message and tapped ’Reply' + */ + const bool forceReply = true; - /** - * @brief Optional. Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. - */ - bool selective = false; + /** + * @brief Optional. Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. + */ + bool selective = false; }; } diff --git a/include/tgbot/types/Game.h b/include/tgbot/types/Game.h index b3723b7..acbd20a 100644 --- a/include/tgbot/types/Game.h +++ b/include/tgbot/types/Game.h @@ -43,39 +43,39 @@ namespace TgBot { */ class Game { public: - typedef std::shared_ptr<Game> Ptr; + typedef std::shared_ptr<Game> Ptr; - /** - * @brief Title of the game. - */ - std::string title; + /** + * @brief Title of the game. + */ + std::string title; - /** - * @brief Description of the game. - */ - std::string description; + /** + * @brief Description of the game. + */ + std::string description; - /** - * @brief Photo that will be displayed in the game message in chats. - */ - std::vector<PhotoSize::Ptr> photo; + /** + * @brief Photo that will be displayed in the game message in chats. + */ + std::vector<PhotoSize::Ptr> photo; - /** - * @brief Optional. Brief description of the game or high scores included in the game message. - * - * Can be automatically edited to include current high scores for the game when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters. - */ - std::string text; + /** + * @brief Optional. Brief description of the game or high scores included in the game message. + * + * Can be automatically edited to include current high scores for the game when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters. + */ + std::string text; - /** - * @brief Optional. Special entities that appear in text, such as usernames, URLs, bot commands, etc. - */ - std::vector<MessageEntity::Ptr> textEntities; + /** + * @brief Optional. Special entities that appear in text, such as usernames, URLs, bot commands, etc. + */ + std::vector<MessageEntity::Ptr> textEntities; - /** - * @brief Optional. Animation that will be displayed in the game message in chats. Upload via BotFather. - */ - Animation::Ptr animation; + /** + * @brief Optional. Animation that will be displayed in the game message in chats. Upload via BotFather. + */ + Animation::Ptr animation; }; } diff --git a/include/tgbot/types/GameHighScore.h b/include/tgbot/types/GameHighScore.h index f78fbf0..1b91e96 100644 --- a/include/tgbot/types/GameHighScore.h +++ b/include/tgbot/types/GameHighScore.h @@ -39,22 +39,22 @@ namespace TgBot { */ class GameHighScore { public: - typedef std::shared_ptr<GameHighScore> Ptr; - - /** - * @brief Position in high score table for the game. - */ - std::string position; - - /** - * @brief User. - */ - User::Ptr user; - - /** - * @brief Score. - */ - int32_t score; + typedef std::shared_ptr<GameHighScore> Ptr; + + /** + * @brief Position in high score table for the game. + */ + std::string position; + + /** + * @brief User. + */ + User::Ptr user; + + /** + * @brief Score. + */ + int32_t score; }; } diff --git a/include/tgbot/types/GenericReply.h b/include/tgbot/types/GenericReply.h index 4b20b14..83d28ab 100644 --- a/include/tgbot/types/GenericReply.h +++ b/include/tgbot/types/GenericReply.h @@ -34,9 +34,9 @@ namespace TgBot { class GenericReply { public: - typedef std::shared_ptr<GenericReply> Ptr; + typedef std::shared_ptr<GenericReply> Ptr; - virtual ~GenericReply() { } + virtual ~GenericReply() { } }; } diff --git a/include/tgbot/types/InlineKeyboardButton.h b/include/tgbot/types/InlineKeyboardButton.h index bee3398..4b83087 100644 --- a/include/tgbot/types/InlineKeyboardButton.h +++ b/include/tgbot/types/InlineKeyboardButton.h @@ -19,48 +19,48 @@ namespace TgBot { */ class InlineKeyboardButton { public: - typedef std::shared_ptr<InlineKeyboardButton> Ptr; + typedef std::shared_ptr<InlineKeyboardButton> Ptr; - /** - * @brief Label text on the button - */ - std::string text; + /** + * @brief Label text on the button + */ + std::string text; - /** - * @brief Optional. HTTP url to be opened when button is pressed. - */ - std::string url; + /** + * @brief Optional. HTTP url to be opened when button is pressed. + */ + std::string url; - /** - * @brief Optional. Data to be sent in a callback query to the bot when button is pressed. - */ - std::string callbackData; + /** + * @brief Optional. Data to be sent in a callback query to the bot when button is pressed. + */ + std::string callbackData; - /** - * @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. - */ - std::string switchInlineQuery; + /** + * @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. + */ + 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. - */ - std::string switchInlineQueryCurrentChat; + /** + * @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. + */ + 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. - */ - CallbackGame::Ptr callbackGame; + /** + * @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. + */ + 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. - */ - bool pay = false; + /** + * @brief Optional. Specify True, to send a Pay button. + * + * Note: This type of button must always be the first button in the first row. + */ + bool pay = false; }; } diff --git a/include/tgbot/types/InlineKeyboardMarkup.h b/include/tgbot/types/InlineKeyboardMarkup.h index ef039a5..e1d2994 100644 --- a/include/tgbot/types/InlineKeyboardMarkup.h +++ b/include/tgbot/types/InlineKeyboardMarkup.h @@ -20,12 +20,12 @@ namespace TgBot { */ class InlineKeyboardMarkup : public GenericReply { public: - typedef std::shared_ptr<InlineKeyboardMarkup> Ptr; + typedef std::shared_ptr<InlineKeyboardMarkup> Ptr; - /** - * @brief Array of button rows, each represented by an Array of InlineKeyboardButton objects. - */ - std::vector<std::vector<InlineKeyboardButton::Ptr>> inlineKeyboard; + /** + * @brief Array of button rows, each represented by an Array of InlineKeyboardButton objects. + */ + std::vector<std::vector<InlineKeyboardButton::Ptr>> inlineKeyboard; }; } diff --git a/include/tgbot/types/InlineQuery.h b/include/tgbot/types/InlineQuery.h index b88c830..790711a 100644 --- a/include/tgbot/types/InlineQuery.h +++ b/include/tgbot/types/InlineQuery.h @@ -20,32 +20,32 @@ namespace TgBot { */ class InlineQuery { public: - typedef std::shared_ptr<InlineQuery> Ptr; - - /** - * @brief Unique query identifier. - */ - std::string id; - - /** - * @brief Sender. - */ - User::Ptr from; - - /** - * @brief Optional. Sender location, only for bots that request user location - */ - Location::Ptr location; - - /** - * @brief Text of the query. - */ - std::string query; - - /** - * @brief Offset of the results to be returned. - */ - std::string offset; + typedef std::shared_ptr<InlineQuery> Ptr; + + /** + * @brief Unique query identifier. + */ + std::string id; + + /** + * @brief Sender. + */ + User::Ptr from; + + /** + * @brief Optional. Sender location, only for bots that request user location + */ + Location::Ptr location; + + /** + * @brief Text of the query. + */ + std::string query; + + /** + * @brief Offset of the results to be returned. + */ + std::string offset; }; } diff --git a/include/tgbot/types/InlineQueryResult.h b/include/tgbot/types/InlineQueryResult.h index 67542f2..10153a1 100644 --- a/include/tgbot/types/InlineQueryResult.h +++ b/include/tgbot/types/InlineQueryResult.h @@ -20,43 +20,41 @@ namespace TgBot { */ class InlineQueryResult { public: - typedef std::shared_ptr<InlineQueryResult> Ptr; + typedef std::shared_ptr<InlineQueryResult> Ptr; - InlineQueryResult() { + InlineQueryResult() { } - } + virtual ~InlineQueryResult() { } - virtual ~InlineQueryResult() { } + /** + * @brief Type of the result. + */ + std::string type; - /** - * @brief Type of the result. - */ - std::string type; + /** + * @brief Unique identifier for this result. (1-64 bytes) + */ + std::string id; - /** - * @brief Unique identifier for this result. (1-64 bytes) - */ - std::string id; + /** + * @brief Requred, optional or missing. See description of derived classes. Title of the result. + */ + std::string title; - /** - * @brief Requred, optional or missing. See description of derived classes. Title of the result. - */ - std::string title; + /** + * @brief Optional or missing. See description of derived classes. Caption of the file to be sent, 0-200 characters + */ + std::string caption; - /** - * @brief Optional or missing. See description of derived classes. Caption of the file to be sent, 0-200 characters - */ - std::string caption; + /** + * @brief Optional. Inline keyboard attached to the message + */ + InlineKeyboardMarkup::Ptr replyMarkup; - /** - * @brief Optional. Inline keyboard attached to the message - */ - InlineKeyboardMarkup::Ptr replyMarkup; - - /** - * @brief Requred, optional or missing. See description of derived classes. Content of the message to be sent - */ - InputMessageContent::Ptr inputMessageContent; + /** + * @brief Requred, optional or missing. See description of derived classes. Content of the message to be sent + */ + InputMessageContent::Ptr inputMessageContent; }; } diff --git a/include/tgbot/types/InlineQueryResultArticle.h b/include/tgbot/types/InlineQueryResultArticle.h index 88d11ba..bb7ddc6 100644 --- a/include/tgbot/types/InlineQueryResultArticle.h +++ b/include/tgbot/types/InlineQueryResultArticle.h @@ -19,46 +19,46 @@ namespace TgBot { */ class InlineQueryResultArticle : public InlineQueryResult { public: - static const std::string TYPE; + static const std::string TYPE; - typedef std::shared_ptr<InlineQueryResultArticle> Ptr; + typedef std::shared_ptr<InlineQueryResultArticle> Ptr; - InlineQueryResultArticle() { - this->type = TYPE; - this->hideUrl = false; - this->thumbHeight = 0; - this->thumbWidth = 0; - } + InlineQueryResultArticle() { + this->type = TYPE; + this->hideUrl = false; + this->thumbHeight = 0; + this->thumbWidth = 0; + } - /** - * @brief Optional. URL of the result. - */ - std::string url; + /** + * @brief Optional. URL of the result. + */ + std::string url; - /** - * @brief Optional. Pass True if you don't want the URL to be shown in the message. - */ - bool hideUrl; + /** + * @brief Optional. Pass True if you don't want the URL to be shown in the message. + */ + bool hideUrl; - /** - * @brief Optional. Short description of the result. - */ - std::string description; + /** + * @brief Optional. Short description of the result. + */ + std::string description; - /** - * @brief Optional. Url of the thumbnail for the result - */ - std::string thumbUrl; + /** + * @brief Optional. Url of the thumbnail for the result + */ + std::string thumbUrl; - /** - * @brief Optional. Thumbnail width. - */ - int32_t thumbWidth; + /** + * @brief Optional. Thumbnail width. + */ + int32_t thumbWidth; - /** - * @brief Optinal. Thumbnail height - */ - int32_t thumbHeight; + /** + * @brief Optinal. Thumbnail height + */ + int32_t thumbHeight; }; } diff --git a/include/tgbot/types/InlineQueryResultAudio.h b/include/tgbot/types/InlineQueryResultAudio.h index 047c8af..016875c 100644 --- a/include/tgbot/types/InlineQueryResultAudio.h +++ b/include/tgbot/types/InlineQueryResultAudio.h @@ -19,29 +19,29 @@ namespace TgBot { */ class InlineQueryResultAudio : public InlineQueryResult { public: - static const std::string TYPE; + static const std::string TYPE; - typedef std::shared_ptr<InlineQueryResultAudio> Ptr; + typedef std::shared_ptr<InlineQueryResultAudio> Ptr; - InlineQueryResultAudio() { - this->type = TYPE; - this->audioDuration = 0; - } + InlineQueryResultAudio() { + this->type = TYPE; + this->audioDuration = 0; + } - /** - * @brief A valid URL for the audio file - */ - std::string audioUrl; + /** + * @brief A valid URL for the audio file + */ + std::string audioUrl; - /** - * @brief Optional. Performer - */ - std::string performer; + /** + * @brief Optional. Performer + */ + std::string performer; - /** - * @brief Optional. Audio duration in seconds - */ - int32_t audioDuration; + /** + * @brief Optional. Audio duration in seconds + */ + int32_t audioDuration; }; } diff --git a/include/tgbot/types/InlineQueryResultCachedAudio.h b/include/tgbot/types/InlineQueryResultCachedAudio.h index e5299cf..ba6ba4c 100644 --- a/include/tgbot/types/InlineQueryResultCachedAudio.h +++ b/include/tgbot/types/InlineQueryResultCachedAudio.h @@ -19,18 +19,18 @@ namespace TgBot { */ class InlineQueryResultCachedAudio : public InlineQueryResult { public: - static const std::string TYPE; + static const std::string TYPE; - typedef std::shared_ptr<InlineQueryResultCachedAudio> Ptr; + typedef std::shared_ptr<InlineQueryResultCachedAudio> Ptr; - InlineQueryResultCachedAudio() { - this->type = TYPE; - } + InlineQueryResultCachedAudio() { + this->type = TYPE; + } - /** - * @brief A valid file identifier for the audio file - */ - std::string audioFileId; + /** + * @brief A valid file identifier for the audio file + */ + std::string audioFileId; }; } diff --git a/include/tgbot/types/InlineQueryResultCachedDocument.h b/include/tgbot/types/InlineQueryResultCachedDocument.h index da99f78..29086c3 100644 --- a/include/tgbot/types/InlineQueryResultCachedDocument.h +++ b/include/tgbot/types/InlineQueryResultCachedDocument.h @@ -19,23 +19,23 @@ namespace TgBot { */ class InlineQueryResultCachedDocument : public InlineQueryResult { public: - static const std::string TYPE; + static const std::string TYPE; - typedef std::shared_ptr<InlineQueryResultCachedDocument> Ptr; + typedef std::shared_ptr<InlineQueryResultCachedDocument> Ptr; - InlineQueryResultCachedDocument() { - this->type = TYPE; - } + InlineQueryResultCachedDocument() { + this->type = TYPE; + } - /** - * @brief A valid file identifier for the file - */ - std::string documentFileId; + /** + * @brief A valid file identifier for the file + */ + std::string documentFileId; - /** - * @brief Optional. Short description of the result - */ - std::string description; + /** + * @brief Optional. Short description of the result + */ + std::string description; }; } diff --git a/include/tgbot/types/InlineQueryResultCachedGif.h b/include/tgbot/types/InlineQueryResultCachedGif.h index 17e2d46..85b309b 100644 --- a/include/tgbot/types/InlineQueryResultCachedGif.h +++ b/include/tgbot/types/InlineQueryResultCachedGif.h @@ -19,18 +19,18 @@ namespace TgBot { */ class InlineQueryResultCachedGif : public InlineQueryResult { public: - static const std::string TYPE; + static const std::string TYPE; - typedef std::shared_ptr<InlineQueryResultCachedGif> Ptr; + typedef std::shared_ptr<InlineQueryResultCachedGif> Ptr; - InlineQueryResultCachedGif() { - this->type = TYPE; - } + InlineQueryResultCachedGif() { + this->type = TYPE; + } - /** - * @brief A valid file identifier for the GIF file - */ - std::string gifFileId; + /** + * @brief A valid file identifier for the GIF file + */ + std::string gifFileId; }; } diff --git a/include/tgbot/types/InlineQueryResultCachedMpeg4Gif.h b/include/tgbot/types/InlineQueryResultCachedMpeg4Gif.h index 6c87f08..8f75763 100644 --- a/include/tgbot/types/InlineQueryResultCachedMpeg4Gif.h +++ b/include/tgbot/types/InlineQueryResultCachedMpeg4Gif.h @@ -19,18 +19,18 @@ namespace TgBot { */ class InlineQueryResultCachedMpeg4Gif : public InlineQueryResult { public: - static const std::string TYPE; + static const std::string TYPE; - typedef std::shared_ptr<InlineQueryResultCachedMpeg4Gif> Ptr; + typedef std::shared_ptr<InlineQueryResultCachedMpeg4Gif> Ptr; - InlineQueryResultCachedMpeg4Gif() { - this->type = TYPE; - } + InlineQueryResultCachedMpeg4Gif() { + this->type = TYPE; + } - /** - * @brief A valid file identifier for the MP4 file - */ - std::string mpeg4FileId; + /** + * @brief A valid file identifier for the MP4 file + */ + std::string mpeg4FileId; }; } diff --git a/include/tgbot/types/InlineQueryResultCachedPhoto.h b/include/tgbot/types/InlineQueryResultCachedPhoto.h index 7cf6289..ed190f2 100644 --- a/include/tgbot/types/InlineQueryResultCachedPhoto.h +++ b/include/tgbot/types/InlineQueryResultCachedPhoto.h @@ -19,23 +19,23 @@ namespace TgBot { */ class InlineQueryResultCachedPhoto : public InlineQueryResult { public: - static const std::string TYPE; + static const std::string TYPE; - typedef std::shared_ptr<InlineQueryResultCachedPhoto> Ptr; + typedef std::shared_ptr<InlineQueryResultCachedPhoto> Ptr; - InlineQueryResultCachedPhoto() { - this->type = TYPE; - } + InlineQueryResultCachedPhoto() { + this->type = TYPE; + } - /** - * @brief A valid file identifier of the photo - */ - std::string photoFileId; + /** + * @brief A valid file identifier of the photo + */ + std::string photoFileId; - /** - * @brief Optional. Short description of the result - */ - std::string description; + /** + * @brief Optional. Short description of the result + */ + std::string description; }; } diff --git a/include/tgbot/types/InlineQueryResultCachedSticker.h b/include/tgbot/types/InlineQueryResultCachedSticker.h index 77f66f0..42474d1 100644 --- a/include/tgbot/types/InlineQueryResultCachedSticker.h +++ b/include/tgbot/types/InlineQueryResultCachedSticker.h @@ -19,18 +19,18 @@ namespace TgBot { */ class InlineQueryResultCachedSticker : public InlineQueryResult { public: - static const std::string TYPE; + static const std::string TYPE; - typedef std::shared_ptr<InlineQueryResultCachedSticker> Ptr; + typedef std::shared_ptr<InlineQueryResultCachedSticker> Ptr; - InlineQueryResultCachedSticker() { - this->type = TYPE; - } + InlineQueryResultCachedSticker() { + this->type = TYPE; + } - /** - * @brief A valid file identifier of the sticker - */ - std::string stickerFileId; + /** + * @brief A valid file identifier of the sticker + */ + std::string stickerFileId; }; } diff --git a/include/tgbot/types/InlineQueryResultCachedVideo.h b/include/tgbot/types/InlineQueryResultCachedVideo.h index 8b24c76..67c9b95 100644 --- a/include/tgbot/types/InlineQueryResultCachedVideo.h +++ b/include/tgbot/types/InlineQueryResultCachedVideo.h @@ -19,23 +19,23 @@ namespace TgBot { */ class InlineQueryResultCachedVideo : public InlineQueryResult { public: - static const std::string TYPE; + static const std::string TYPE; - typedef std::shared_ptr<InlineQueryResultCachedVideo> Ptr; + typedef std::shared_ptr<InlineQueryResultCachedVideo> Ptr; - InlineQueryResultCachedVideo() { - this->type = TYPE; - } + InlineQueryResultCachedVideo() { + this->type = TYPE; + } - /** - * @brief A valid file identifier of the video - */ - std::string videoFileId; + /** + * @brief A valid file identifier of the video + */ + std::string videoFileId; - /** - * @brief Optional. Short description of the result - */ - std::string description; + /** + * @brief Optional. Short description of the result + */ + std::string description; }; } diff --git a/include/tgbot/types/InlineQueryResultCachedVoice.h b/include/tgbot/types/InlineQueryResultCachedVoice.h index 8b4fb42..679aae6 100644 --- a/include/tgbot/types/InlineQueryResultCachedVoice.h +++ b/include/tgbot/types/InlineQueryResultCachedVoice.h @@ -19,18 +19,18 @@ namespace TgBot { */ class InlineQueryResultCachedVoice : public InlineQueryResult { public: - static const std::string TYPE; + static const std::string TYPE; - typedef std::shared_ptr<InlineQueryResultCachedVoice> Ptr; + typedef std::shared_ptr<InlineQueryResultCachedVoice> Ptr; - InlineQueryResultCachedVoice() { - this->type = TYPE; - } + InlineQueryResultCachedVoice() { + this->type = TYPE; + } - /** - * @brief A valid file identifier of the voice message - */ - std::string voiceFileId; + /** + * @brief A valid file identifier of the voice message + */ + std::string voiceFileId; }; } diff --git a/include/tgbot/types/InlineQueryResultContact.h b/include/tgbot/types/InlineQueryResultContact.h index a6a562a..39bd570 100644 --- a/include/tgbot/types/InlineQueryResultContact.h +++ b/include/tgbot/types/InlineQueryResultContact.h @@ -19,45 +19,45 @@ namespace TgBot { */ class InlineQueryResultContact : public InlineQueryResult { public: - static const std::string TYPE; + static const std::string TYPE; - typedef std::shared_ptr<InlineQueryResultContact> Ptr; + typedef std::shared_ptr<InlineQueryResultContact> Ptr; - InlineQueryResultContact() { - this->type = TYPE; - this->thumbHeight = 0; - this->thumbWidth = 0; - } + InlineQueryResultContact() { + this->type = TYPE; + this->thumbHeight = 0; + this->thumbWidth = 0; + } - /** - * @brief Contact's phone number - */ - std::string phoneNumber; + /** + * @brief Contact's phone number + */ + std::string phoneNumber; - /** - * @brief Contact's first name - */ - std::string firstName; + /** + * @brief Contact's first name + */ + std::string firstName; - /** - * @brief Optional. Contact's last name - */ - std::string lastName; + /** + * @brief Optional. Contact's last name + */ + std::string lastName; - /** - * @brief Optional. Url of the thumbnail for the result - */ - std::string thumbUrl; + /** + * @brief Optional. Url of the thumbnail for the result + */ + std::string thumbUrl; - /** - * @brief Optional. Thumbnail width. - */ - int32_t thumbWidth; + /** + * @brief Optional. Thumbnail width. + */ + int32_t thumbWidth; - /** - * @brief Optinal. Thumbnail height - */ - int32_t thumbHeight; + /** + * @brief Optinal. Thumbnail height + */ + int32_t thumbHeight; }; } diff --git a/include/tgbot/types/InlineQueryResultDocument.h b/include/tgbot/types/InlineQueryResultDocument.h index 7f08ba8..14ea8cd 100644 --- a/include/tgbot/types/InlineQueryResultDocument.h +++ b/include/tgbot/types/InlineQueryResultDocument.h @@ -19,45 +19,45 @@ namespace TgBot { */ class InlineQueryResultDocument : public InlineQueryResult { public: - static const std::string TYPE; + static const std::string TYPE; - typedef std::shared_ptr<InlineQueryResultDocument> Ptr; + typedef std::shared_ptr<InlineQueryResultDocument> Ptr; - InlineQueryResultDocument() { - this->type = TYPE; - this->thumbHeight = 0; - this->thumbWidth = 0; - } + InlineQueryResultDocument() { + this->type = TYPE; + this->thumbHeight = 0; + this->thumbWidth = 0; + } - /** - * @brief A valid URL for the file - */ - std::string documentUrl; + /** + * @brief A valid URL for the file + */ + std::string documentUrl; - /** - * @brief Mime type of the content of the file, either 'application/pdf' or 'application/zip' - */ - std::string mimeType; + /** + * @brief Mime type of the content of the file, either 'application/pdf' or 'application/zip' + */ + std::string mimeType; - /** - * @brief Optional. Short description of the result - */ - std::string description; + /** + * @brief Optional. Short description of the result + */ + std::string description; - /** - * @brief Optional. Url of the thumbnail for the result - */ - std::string thumbUrl; + /** + * @brief Optional. Url of the thumbnail for the result + */ + std::string thumbUrl; - /** - * @brief Optional. Thumbnail width. - */ - int32_t thumbWidth; + /** + * @brief Optional. Thumbnail width. + */ + int32_t thumbWidth; - /** - * @brief Optinal. Thumbnail height - */ - int32_t thumbHeight; + /** + * @brief Optinal. Thumbnail height + */ + int32_t thumbHeight; }; } diff --git a/include/tgbot/types/InlineQueryResultGame.h b/include/tgbot/types/InlineQueryResultGame.h index 46fb626..83ae8d4 100644 --- a/include/tgbot/types/InlineQueryResultGame.h +++ b/include/tgbot/types/InlineQueryResultGame.h @@ -19,18 +19,18 @@ namespace TgBot { */ class InlineQueryResultGame : public InlineQueryResult { public: - static const std::string TYPE; + static const std::string TYPE; - typedef std::shared_ptr<InlineQueryResultGame> Ptr; + typedef std::shared_ptr<InlineQueryResultGame> Ptr; - InlineQueryResultGame() { - this->type = TYPE; - } + InlineQueryResultGame() { + this->type = TYPE; + } - /** - * @brief Short name of the game - */ - std::string gameShortName; + /** + * @brief Short name of the game + */ + std::string gameShortName; }; } diff --git a/include/tgbot/types/InlineQueryResultGif.h b/include/tgbot/types/InlineQueryResultGif.h index 55789c3..05f5fcf 100644 --- a/include/tgbot/types/InlineQueryResultGif.h +++ b/include/tgbot/types/InlineQueryResultGif.h @@ -19,40 +19,40 @@ namespace TgBot { */ class InlineQueryResultGif : public InlineQueryResult { public: - static const std::string TYPE; - - typedef std::shared_ptr<InlineQueryResultGif> Ptr; - - InlineQueryResultGif() { - this->type = TYPE; - this->gifWidth = 0; - this->gifHeight = 0; - } - - /** - * @brief A valid URL for the GIF file. - */ - std::string gifUrl; - - /** - * @brief Optional. Width of the GIF. - */ - int32_t gifWidth; - - /** - * @brief Optional. Height of the GIF. - */ - int32_t gifHeight; - - /** - * @brief Optional. Duration of the GIF - */ - int32_t gifDuration; - - /** - * @brief URL of the static thumbnail for the result (jpeg or gif) - */ - std::string thumbUrl; + static const std::string TYPE; + + typedef std::shared_ptr<InlineQueryResultGif> Ptr; + + InlineQueryResultGif() { + this->type = TYPE; + this->gifWidth = 0; + this->gifHeight = 0; + } + + /** + * @brief A valid URL for the GIF file. + */ + std::string gifUrl; + + /** + * @brief Optional. Width of the GIF. + */ + int32_t gifWidth; + + /** + * @brief Optional. Height of the GIF. + */ + int32_t gifHeight; + + /** + * @brief Optional. Duration of the GIF + */ + int32_t gifDuration; + + /** + * @brief URL of the static thumbnail for the result (jpeg or gif) + */ + std::string thumbUrl; }; } diff --git a/include/tgbot/types/InlineQueryResultLocation.h b/include/tgbot/types/InlineQueryResultLocation.h index c3fd22c..f5e0d79 100644 --- a/include/tgbot/types/InlineQueryResultLocation.h +++ b/include/tgbot/types/InlineQueryResultLocation.h @@ -19,40 +19,40 @@ namespace TgBot { */ class InlineQueryResultLocation : public InlineQueryResult { public: - static const std::string TYPE; - - typedef std::shared_ptr<InlineQueryResultLocation> Ptr; - - InlineQueryResultLocation() { - this->type = TYPE; - this->thumbHeight = 0; - this->thumbWidth = 0; - } - - /** - * @brief Location latitude in degrees - */ - float latitude; - - /** - * @brief Location longitude in degrees - */ - float longitude; - - /** - * @brief Optional. Url of the thumbnail for the result - */ - std::string thumbUrl; - - /** - * @brief Optional. Thumbnail width. - */ - int32_t thumbWidth; - - /** - * @brief Optinal. Thumbnail height - */ - int32_t thumbHeight; + static const std::string TYPE; + + typedef std::shared_ptr<InlineQueryResultLocation> Ptr; + + InlineQueryResultLocation() { + this->type = TYPE; + this->thumbHeight = 0; + this->thumbWidth = 0; + } + + /** + * @brief Location latitude in degrees + */ + float latitude; + + /** + * @brief Location longitude in degrees + */ + float longitude; + + /** + * @brief Optional. Url of the thumbnail for the result + */ + std::string thumbUrl; + + /** + * @brief Optional. Thumbnail width. + */ + int32_t thumbWidth; + + /** + * @brief Optinal. Thumbnail height + */ + int32_t thumbHeight; }; } diff --git a/include/tgbot/types/InlineQueryResultMpeg4Gif.h b/include/tgbot/types/InlineQueryResultMpeg4Gif.h index 347d8cb..582ee73 100644 --- a/include/tgbot/types/InlineQueryResultMpeg4Gif.h +++ b/include/tgbot/types/InlineQueryResultMpeg4Gif.h @@ -14,40 +14,40 @@ namespace TgBot { */ class InlineQueryResultMpeg4Gif : public InlineQueryResult { public: - static const std::string TYPE; - - typedef std::shared_ptr<InlineQueryResultMpeg4Gif> Ptr; - - InlineQueryResultMpeg4Gif() { - this->type = TYPE; - this->mpeg4Width = 0; - this->mpeg4Height = 0; - } - - /** - * @brief A valid URL for the MP4 file. - */ - std::string mpeg4Url; - - /** - * @brief Optional. Video width. - */ - int32_t mpeg4Width; - - /** - * @brief Optional. Video height. - */ - int32_t mpeg4Height; - - /** - * @brief Optional. Video duration. - */ - int32_t mpeg4Duration; - - /** - * @brief URL of the static thumbnail (jpeg or gif) for the result - */ - std::string thumbUrl; + static const std::string TYPE; + + typedef std::shared_ptr<InlineQueryResultMpeg4Gif> Ptr; + + InlineQueryResultMpeg4Gif() { + this->type = TYPE; + this->mpeg4Width = 0; + this->mpeg4Height = 0; + } + + /** + * @brief A valid URL for the MP4 file. + */ + std::string mpeg4Url; + + /** + * @brief Optional. Video width. + */ + int32_t mpeg4Width; + + /** + * @brief Optional. Video height. + */ + int32_t mpeg4Height; + + /** + * @brief Optional. Video duration. + */ + int32_t mpeg4Duration; + + /** + * @brief URL of the static thumbnail (jpeg or gif) for the result + */ + std::string thumbUrl; }; } diff --git a/include/tgbot/types/InlineQueryResultPhoto.h b/include/tgbot/types/InlineQueryResultPhoto.h index 011362c..1c1ae1e 100644 --- a/include/tgbot/types/InlineQueryResultPhoto.h +++ b/include/tgbot/types/InlineQueryResultPhoto.h @@ -19,40 +19,40 @@ namespace TgBot { */ class InlineQueryResultPhoto : public InlineQueryResult { public: - static const std::string TYPE; - - typedef std::shared_ptr<InlineQueryResultPhoto> Ptr; - - InlineQueryResultPhoto() { - this->type = TYPE; - this->photoWidth = 0; - this->photoHeight = 0; - } - - /** - * @brief A valid URL of the photo. - */ - std::string photoUrl; - - /** - * @brief URL of the thumbnail for the photo - */ - std::string thumbUrl; - - /** - * @brief Optional. Width of the photo. - */ - int32_t photoWidth; - - /** - * @brief Optional. Height of the photo. - */ - int32_t photoHeight; - - /** - * @brief Optional. Short description of the result. - */ - std::string description; + static const std::string TYPE; + + typedef std::shared_ptr<InlineQueryResultPhoto> Ptr; + + InlineQueryResultPhoto() { + this->type = TYPE; + this->photoWidth = 0; + this->photoHeight = 0; + } + + /** + * @brief A valid URL of the photo. + */ + std::string photoUrl; + + /** + * @brief URL of the thumbnail for the photo + */ + std::string thumbUrl; + + /** + * @brief Optional. Width of the photo. + */ + int32_t photoWidth; + + /** + * @brief Optional. Height of the photo. + */ + int32_t photoHeight; + + /** + * @brief Optional. Short description of the result. + */ + std::string description; }; } diff --git a/include/tgbot/types/InlineQueryResultVenue.h b/include/tgbot/types/InlineQueryResultVenue.h index 7f00dd0..d012463 100644 --- a/include/tgbot/types/InlineQueryResultVenue.h +++ b/include/tgbot/types/InlineQueryResultVenue.h @@ -19,50 +19,50 @@ namespace TgBot { */ class InlineQueryResultVenue : public InlineQueryResult { public: - static const std::string TYPE; + static const std::string TYPE; - typedef std::shared_ptr<InlineQueryResultVenue> Ptr; + typedef std::shared_ptr<InlineQueryResultVenue> Ptr; - InlineQueryResultVenue() { - this->type = TYPE; - this->thumbHeight = 0; - this->thumbWidth = 0; - } + InlineQueryResultVenue() { + this->type = TYPE; + this->thumbHeight = 0; + this->thumbWidth = 0; + } - /** - * @brief Latitude of the venue location in degrees - */ - float latitude; + /** + * @brief Latitude of the venue location in degrees + */ + float latitude; - /** - * @brief Longitude of the venue location in degrees - */ - float longitude; + /** + * @brief Longitude of the venue location in degrees + */ + float longitude; - /** - * @brief Address of the venue - */ - std::string address; + /** + * @brief Address of the venue + */ + std::string address; - /** - * @brief Optional. Foursquare identifier of the venue if known - */ - std::string foursquareId; + /** + * @brief Optional. Foursquare identifier of the venue if known + */ + std::string foursquareId; - /** - * @brief Optional. Url of the thumbnail for the result - */ - std::string thumbUrl; + /** + * @brief Optional. Url of the thumbnail for the result + */ + std::string thumbUrl; - /** - * @brief Optional. Thumbnail width. - */ - int32_t thumbWidth; + /** + * @brief Optional. Thumbnail width. + */ + int32_t thumbWidth; - /** - * @brief Optinal. Thumbnail height - */ - int32_t thumbHeight; + /** + * @brief Optinal. Thumbnail height + */ + int32_t thumbHeight; }; } diff --git a/include/tgbot/types/InlineQueryResultVideo.h b/include/tgbot/types/InlineQueryResultVideo.h index 563fa9a..270867d 100644 --- a/include/tgbot/types/InlineQueryResultVideo.h +++ b/include/tgbot/types/InlineQueryResultVideo.h @@ -14,51 +14,51 @@ namespace TgBot { */ class InlineQueryResultVideo : public InlineQueryResult { public: - static const std::string TYPE; + static const std::string TYPE; - typedef std::shared_ptr<InlineQueryResultVideo> Ptr; + typedef std::shared_ptr<InlineQueryResultVideo> Ptr; - InlineQueryResultVideo() { - this->type = TYPE; - this->videoWidth = 0; - this->videoHeight = 0; - this->videoDuration = 0; - }; + InlineQueryResultVideo() { + this->type = TYPE; + this->videoWidth = 0; + this->videoHeight = 0; + this->videoDuration = 0; + }; - /** - * @brief A valid URL for the embedded video player or video file. - */ - std::string videoUrl; + /** + * @brief A valid URL for the embedded video player or video file. + */ + std::string videoUrl; - /** - * @brief Mime type of the content of video url, "text/html" or "video/mp4". - */ - std::string mimeType; + /** + * @brief Mime type of the content of video url, "text/html" or "video/mp4". + */ + std::string mimeType; - /** - * @brief URL of the thumbnail (jpeg only) for the video - */ - std::string thumbUrl; + /** + * @brief URL of the thumbnail (jpeg only) for the video + */ + std::string thumbUrl; - /** - * @brief Optional. Video width. - */ - int32_t videoWidth; + /** + * @brief Optional. Video width. + */ + int32_t videoWidth; - /** - * @brief Optional. Video height. - */ - int32_t videoHeight; + /** + * @brief Optional. Video height. + */ + int32_t videoHeight; - /** - * @brief Optional. Video duration. - */ - int32_t videoDuration; + /** + * @brief Optional. Video duration. + */ + int32_t videoDuration; - /** - * @brief Optional. Short description of the result. - */ - std::string description; + /** + * @brief Optional. Short description of the result. + */ + std::string description; }; } diff --git a/include/tgbot/types/InlineQueryResultVoice.h b/include/tgbot/types/InlineQueryResultVoice.h index 49710ea..ee14fef 100644 --- a/include/tgbot/types/InlineQueryResultVoice.h +++ b/include/tgbot/types/InlineQueryResultVoice.h @@ -14,24 +14,24 @@ namespace TgBot { */ class InlineQueryResultVoice : public InlineQueryResult { public: - static const std::string TYPE; + static const std::string TYPE; - typedef std::shared_ptr<InlineQueryResultVoice> Ptr; + typedef std::shared_ptr<InlineQueryResultVoice> Ptr; - InlineQueryResultVoice() { - this->type = TYPE; - this->voiceDuration = 0; - }; + InlineQueryResultVoice() { + this->type = TYPE; + this->voiceDuration = 0; + }; - /** - * @brief A valid URL for the voice recording - */ - std::string voiceUrl; + /** + * @brief A valid URL for the voice recording + */ + std::string voiceUrl; - /** - * @brief Optional. Recording duration in seconds - */ - int32_t voiceDuration; + /** + * @brief Optional. Recording duration in seconds + */ + int32_t voiceDuration; }; } diff --git a/include/tgbot/types/InputContactMessageContent.h b/include/tgbot/types/InputContactMessageContent.h index 4f5cf42..865dbba 100644 --- a/include/tgbot/types/InputContactMessageContent.h +++ b/include/tgbot/types/InputContactMessageContent.h @@ -17,28 +17,28 @@ namespace TgBot { */ class InputContactMessageContent : public InputMessageContent { public: - typedef std::shared_ptr<InputContactMessageContent> Ptr; + typedef std::shared_ptr<InputContactMessageContent> Ptr; - InputContactMessageContent() : - InputMessageContent("InputContactMessageContent") - {} + InputContactMessageContent() : + InputMessageContent("InputContactMessageContent") + {} - /** - * @brief Contact's phone number - */ - std::string phoneNumber; + /** + * @brief Contact's phone number + */ + std::string phoneNumber; - /** - * @brief Contact's first name - */ - std::string firstName; + /** + * @brief Contact's first name + */ + std::string firstName; - /** - * @brief Optional. Contact's last name - */ - std::string lastName; + /** + * @brief Optional. Contact's last name + */ + std::string lastName; - virtual ~InputContactMessageContent() { } + virtual ~InputContactMessageContent() { } }; } diff --git a/include/tgbot/types/InputFile.h b/include/tgbot/types/InputFile.h index 9c483d3..3161a84 100644 --- a/include/tgbot/types/InputFile.h +++ b/include/tgbot/types/InputFile.h @@ -37,27 +37,27 @@ namespace TgBot { class InputFile { public: - typedef std::shared_ptr<InputFile> Ptr; + typedef std::shared_ptr<InputFile> Ptr; - /** - * @brief Contents of a file. - */ - std::string data; + /** + * @brief Contents of a file. + */ + std::string data; - /** - * @brief Mime type of a file. - */ - std::string mimeType; + /** + * @brief Mime type of a file. + */ + std::string mimeType; - /** - * @brief File name. - */ - std::string fileName; + /** + * @brief File name. + */ + std::string fileName; - /** - * @brief Creates new InputFile::Ptr from an existing file. - */ - static InputFile::Ptr fromFile(const std::string& filePath, const std::string& mimeType); + /** + * @brief Creates new InputFile::Ptr from an existing file. + */ + static InputFile::Ptr fromFile(const std::string& filePath, const std::string& mimeType); }; } diff --git a/include/tgbot/types/InputLocationMessageContent.h b/include/tgbot/types/InputLocationMessageContent.h index 871ad4c..4a5f781 100644 --- a/include/tgbot/types/InputLocationMessageContent.h +++ b/include/tgbot/types/InputLocationMessageContent.h @@ -16,23 +16,23 @@ namespace TgBot { */ class InputLocationMessageContent : public InputMessageContent { public: - typedef std::shared_ptr<InputLocationMessageContent> Ptr; + typedef std::shared_ptr<InputLocationMessageContent> Ptr; - InputLocationMessageContent() : - InputMessageContent("InputLocationMessageContent") - {} + InputLocationMessageContent() : + InputMessageContent("InputLocationMessageContent") + {} - /** - * @brief Latitude of the location in degrees - */ - float latitude; + /** + * @brief Latitude of the location in degrees + */ + float latitude; - /** - * @brief Longitude of the location in degrees - */ - float longitude; + /** + * @brief Longitude of the location in degrees + */ + float longitude; - virtual ~InputLocationMessageContent() { } + virtual ~InputLocationMessageContent() { } }; } diff --git a/include/tgbot/types/InputMedia.h b/include/tgbot/types/InputMedia.h index c59df20..a4610ad 100644 --- a/include/tgbot/types/InputMedia.h +++ b/include/tgbot/types/InputMedia.h @@ -37,7 +37,7 @@ namespace TgBot { */ class InputMedia { public: - typedef std::shared_ptr<InputMedia> Ptr; + typedef std::shared_ptr<InputMedia> Ptr; enum class TYPE : uint8_t { PHOTO, diff --git a/include/tgbot/types/InputMediaPhoto.h b/include/tgbot/types/InputMediaPhoto.h index 4c6cc64..da9fdcc 100644 --- a/include/tgbot/types/InputMediaPhoto.h +++ b/include/tgbot/types/InputMediaPhoto.h @@ -38,11 +38,11 @@ namespace TgBot { */ class InputMediaPhoto : public InputMedia { public: - typedef std::shared_ptr<InputMediaPhoto> Ptr; + typedef std::shared_ptr<InputMediaPhoto> Ptr; - InputMediaPhoto() { - this->type = TYPE::PHOTO; - } + InputMediaPhoto() { + this->type = TYPE::PHOTO; + } }; } diff --git a/include/tgbot/types/InputMediaVideo.h b/include/tgbot/types/InputMediaVideo.h index 3a2d17a..4e10885 100644 --- a/include/tgbot/types/InputMediaVideo.h +++ b/include/tgbot/types/InputMediaVideo.h @@ -38,11 +38,11 @@ namespace TgBot { */ class InputMediaVideo : public InputMedia { public: - typedef std::shared_ptr<InputMediaVideo> Ptr; + typedef std::shared_ptr<InputMediaVideo> Ptr; - InputMediaVideo() { - this->type = TYPE::VIDEO; - } + InputMediaVideo() { + this->type = TYPE::VIDEO; + } }; } diff --git a/include/tgbot/types/InputMessageContent.h b/include/tgbot/types/InputMessageContent.h index 7e2845e..0dfb1a6 100644 --- a/include/tgbot/types/InputMessageContent.h +++ b/include/tgbot/types/InputMessageContent.h @@ -16,22 +16,22 @@ namespace TgBot { */ class InputMessageContent { public: - typedef std::shared_ptr<InputMessageContent> Ptr; - - InputMessageContent(const std::string &tType): - type(tType) - {} - - /** - * May be - * InputTextMessageContent - * InputLocationMessageContent - * InputVenueMessageContent - * InputContactMessageContent - */ - std::string type; - - virtual ~InputMessageContent() { } + typedef std::shared_ptr<InputMessageContent> Ptr; + + InputMessageContent(const std::string &tType): + type(tType) + {} + + /** + * May be + * InputTextMessageContent + * InputLocationMessageContent + * InputVenueMessageContent + * InputContactMessageContent + */ + std::string type; + + virtual ~InputMessageContent() { } }; } diff --git a/include/tgbot/types/InputTextMessageContent.h b/include/tgbot/types/InputTextMessageContent.h index 64d0f02..990128a 100644 --- a/include/tgbot/types/InputTextMessageContent.h +++ b/include/tgbot/types/InputTextMessageContent.h @@ -17,28 +17,28 @@ namespace TgBot { */ class InputTextMessageContent : public InputMessageContent { public: - typedef std::shared_ptr<InputTextMessageContent> Ptr; + typedef std::shared_ptr<InputTextMessageContent> Ptr; - InputTextMessageContent(): - InputMessageContent("InputTextMessageContent") - {} + InputTextMessageContent(): + InputMessageContent("InputTextMessageContent") + {} - /** - * @brief Text of the message to be sent, 1-4096 characters - */ - std::string messageText; + /** + * @brief Text of the message to be sent, 1-4096 characters + */ + std::string messageText; - /** - * @brief Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. - */ - std::string parseMode; + /** + * @brief Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. + */ + std::string parseMode; - /** - * @brief Optional. Disables link previews for links in the sent message - */ - bool disableWebPagePreview; + /** + * @brief Optional. Disables link previews for links in the sent message + */ + bool disableWebPagePreview; - virtual ~InputTextMessageContent() { } + virtual ~InputTextMessageContent() { } }; } diff --git a/include/tgbot/types/InputVenueMessageContent.h b/include/tgbot/types/InputVenueMessageContent.h index 21df481..115e7d0 100644 --- a/include/tgbot/types/InputVenueMessageContent.h +++ b/include/tgbot/types/InputVenueMessageContent.h @@ -18,38 +18,38 @@ namespace TgBot { */ class InputVenueMessageContent : public InputMessageContent { public: - typedef std::shared_ptr<InputVenueMessageContent> Ptr; - - InputVenueMessageContent() : - InputMessageContent("InputVenueMessageContent") - {} - - /** - * @brief Latitude of the location in degrees - */ - float latitude; - - /** - * @brief Longitude of the location in degrees - */ - float longitude; - - /** - * @brief Name of the venue - */ - std::string title; - - /** - * @brief Address of the venue - */ - std::string address; - - /** - * @brief Optional. Foursquare identifier of the venue, if known - */ - std::string foursquareId; - - virtual ~InputVenueMessageContent() { } + typedef std::shared_ptr<InputVenueMessageContent> Ptr; + + InputVenueMessageContent() : + InputMessageContent("InputVenueMessageContent") + {} + + /** + * @brief Latitude of the location in degrees + */ + float latitude; + + /** + * @brief Longitude of the location in degrees + */ + float longitude; + + /** + * @brief Name of the venue + */ + std::string title; + + /** + * @brief Address of the venue + */ + std::string address; + + /** + * @brief Optional. Foursquare identifier of the venue, if known + */ + std::string foursquareId; + + virtual ~InputVenueMessageContent() { } }; } diff --git a/include/tgbot/types/Invoice.h b/include/tgbot/types/Invoice.h index 7836e14..a279986 100644 --- a/include/tgbot/types/Invoice.h +++ b/include/tgbot/types/Invoice.h @@ -38,40 +38,40 @@ namespace TgBot { */ class Invoice { public: - typedef std::shared_ptr<Invoice> Ptr; + typedef std::shared_ptr<Invoice> Ptr; - /** - * @brief Product name. - */ - std::string title; + /** + * @brief Product name. + */ + std::string title; - /** - * @brief Product description. - */ - std::string description; + /** + * @brief Product description. + */ + std::string description; - /** - * @brief Unique bot deep-linking parameter that can be used to generate this invoice. - */ - std::string startParameter; + /** + * @brief Unique bot deep-linking parameter that can be used to generate this invoice. + */ + std::string startParameter; - /** - * @brief Three-letter ISO 4217 currency code. - */ - std::string currency; + /** + * @brief Three-letter ISO 4217 currency code. + */ + std::string currency; - /** - * @brief Total price in the smallest units of the currency (integer, - * not float/double). - * - * For example, for a price of US$ 1.45 pass - * amount = 145. See the exp parameter in currencies.json, it shows - * the number of digits past the decimal point for each currency (2 - * for the majority of currencies). - * - * https://core.telegram.org/bots/payments/currencies.json - */ - int32_t totalAmount; + /** + * @brief Total price in the smallest units of the currency (integer, + * not float/double). + * + * For example, for a price of US$ 1.45 pass + * amount = 145. See the exp parameter in currencies.json, it shows + * the number of digits past the decimal point for each currency (2 + * for the majority of currencies). + * + * https://core.telegram.org/bots/payments/currencies.json + */ + int32_t totalAmount; }; } diff --git a/include/tgbot/types/KeyboardButton.h b/include/tgbot/types/KeyboardButton.h index 4fa0fd4..668cbaa 100644 --- a/include/tgbot/types/KeyboardButton.h +++ b/include/tgbot/types/KeyboardButton.h @@ -21,24 +21,24 @@ namespace TgBot { class KeyboardButton { public: - typedef std::shared_ptr<KeyboardButton> Ptr; + typedef std::shared_ptr<KeyboardButton> Ptr; /** * @brief Text of the button. If none of the optional fields are used, - * it will be sent to the bot as a message when the button is pressed + * it will be sent to the bot as a message when the button is pressed */ - std::string text; + std::string text; /** * @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 + * when the button is pressed. Available in private chats only */ - bool requestContact = false; + 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. */ - bool requestLocation = false; + bool requestLocation = false; }; } diff --git a/include/tgbot/types/LabeledPrice.h b/include/tgbot/types/LabeledPrice.h index 64b9aeb..bf9fb28 100644 --- a/include/tgbot/types/LabeledPrice.h +++ b/include/tgbot/types/LabeledPrice.h @@ -18,24 +18,24 @@ namespace TgBot { */ class LabeledPrice { public: - typedef std::shared_ptr<LabeledPrice> Ptr; + typedef std::shared_ptr<LabeledPrice> Ptr; - /** - * @brief Portion label. - */ - std::string label; + /** + * @brief Portion label. + */ + std::string label; - /** - * @brief Price of the product in the smallest units of the currency (integer, - * not float/double). - * - * For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter - * in currencies.json, it shows the number of digits past the decimal point - * for each currency (2 for the majority of currencies). - * - * https://core.telegram.org/bots/payments/currencies.json - */ - int32_t amount; + /** + * @brief Price of the product in the smallest units of the currency (integer, + * not float/double). + * + * For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter + * in currencies.json, it shows the number of digits past the decimal point + * for each currency (2 for the majority of currencies). + * + * https://core.telegram.org/bots/payments/currencies.json + */ + int32_t amount; }; } diff --git a/include/tgbot/types/Location.h b/include/tgbot/types/Location.h index 2144b8c..7d0f369 100644 --- a/include/tgbot/types/Location.h +++ b/include/tgbot/types/Location.h @@ -35,17 +35,17 @@ namespace TgBot { class Location { public: - typedef std::shared_ptr<Location> Ptr; + typedef std::shared_ptr<Location> Ptr; - /** - * @brief Longitude as defined by sender. - */ - float longitude; + /** + * @brief Longitude as defined by sender. + */ + float longitude; - /** - * @brief Latitude as defined by sender. - */ - float latitude; + /** + * @brief Latitude as defined by sender. + */ + float latitude; }; } diff --git a/include/tgbot/types/MaskPosition.h b/include/tgbot/types/MaskPosition.h index 67dd6d3..6898d76 100644 --- a/include/tgbot/types/MaskPosition.h +++ b/include/tgbot/types/MaskPosition.h @@ -36,27 +36,27 @@ namespace TgBot { */ class MaskPosition { public: - typedef std::shared_ptr<MaskPosition> Ptr; + typedef std::shared_ptr<MaskPosition> Ptr; - /** - * @brief The part of the face relative to which the mask should be placed. One of “forehead”, “eyes”, “mouth”, or “chin”. - */ - std::string point; + /** + * @brief The part of the face relative to which the mask should be placed. One of “forehead”, “eyes”, “mouth”, or “chin”. + */ + std::string point; - /** - * @brief Shift by X-axis measured in widths of the mask scaled to the face size, from left to right. For example, choosing -1.0 will place mask just to the left of the default mask position. - */ - float xShift; + /** + * @brief Shift by X-axis measured in widths of the mask scaled to the face size, from left to right. For example, choosing -1.0 will place mask just to the left of the default mask position. + */ + float xShift; /** - * @brief Shift by Y-axis measured in heights of the mask scaled to the face size, from top to bottom. For example, 1.0 will place the mask just below the default mask position. - */ - float yShift; + * @brief Shift by Y-axis measured in heights of the mask scaled to the face size, from top to bottom. For example, 1.0 will place the mask just below the default mask position. + */ + float yShift; /** - * @brief Mask scaling coefficient. For example, 2.0 means double size. - */ - float scale; + * @brief Mask scaling coefficient. For example, 2.0 means double size. + */ + float scale; }; } diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h index db330a4..1f5c75a 100644 --- a/include/tgbot/types/Message.h +++ b/include/tgbot/types/Message.h @@ -53,212 +53,212 @@ namespace TgBot { */ class Message { public: - typedef std::shared_ptr<Message> Ptr; - - /** - * @brief Unique message identifier. - */ - int32_t messageId; - - /** - * @brief Optional. Sender, can be empty for messages sent to channels. - */ - User::Ptr from; - - /** - * @brief Date the message was sent in Unix time. - */ - int32_t date; - - /** - * @brief Conversation the message belongs to. - */ - Chat::Ptr chat; - - /** - * @brief Optional. For forwarded messages, sender of the original message. - */ - User::Ptr forwardFrom; - - /** - * @brief Optional. For messages forwarded from a channel, information about the original channel - */ - Chat::Ptr forwardFromChat; - - /** - * @brief Optional. For forwarded channel posts, identifier of the original message in the channel - */ - int32_t forwardFromMessageId; - - /** - * @brief Optional. For messages forwarded from channels, signature of the post author if present. - */ - std::string forwardSignature; - - /** - * @brief Optional. For forwarded messages, date the original message was sent in Unix time. - */ - int32_t forwardDate; - - /** - * @brief Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. - */ - Message::Ptr replyToMessage; - - /** - * @brief Optional. Date the message was last edited in Unix time. - */ - int32_t editDate; - - /** - * @brief Optional. Signature of the post author for messages in channels. - */ - std::string authorSignature; - - /** - * @brief Optional. For text messages, the actual UTF-8 text of the message. - */ - std::string text; - - /** - * @brief Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text. - */ - std::vector<MessageEntity::Ptr> entities; - - /** - * @brief Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption - */ - std::vector<MessageEntity::Ptr> captionEntities; - - /** - * @brief Optional. Message is an audio file, information about the file. - */ - Audio::Ptr audio; - - /** - * @brief Optional. Message is a general file, information about the file. - */ - Document::Ptr document; - - /** - * @brief Optional. Message is a game, information about the game. - */ - Game::Ptr game; - - /** - * @brief Optional. Message is a photo, available sizes of the photo. - */ - std::vector<PhotoSize::Ptr> photo; - - /** - * @brief Optional. Message is a sticker, information about the sticker. - */ - Sticker::Ptr sticker; - - /** - * @brief Optional. Message is a video, information about the video. - */ - Video::Ptr video; - - /** - * @brief Optional. Message is a voice message, information about the file. - */ - Voice::Ptr voice; - - /** - * @brief Optional. Caption for the document, photo or video, 0-200 characters. - */ - std::string caption; - - /** - * @brief Optional. Message is a shared contact, information about the contact. - */ - Contact::Ptr contact; - - /** - * @brief Optional. Message is a shared location, information about the location. - */ - Location::Ptr location; - - /** - * @brief Optional. Message is a venue, information about the venue. - */ - Venue::Ptr venue; - - /** - * @brief Optional. A new member was added to the group, information about them (this member may be bot itself). - */ - User::Ptr newChatMember; - - /** - * @brief Optional. New members that were added to the group or supergroup and information about them (the bot itself may be one of these members) - */ - std::vector<User::Ptr> newChatMembers; - - /** - * @brief Optional. A member was removed from the group, information about them (this member may be bot itself). - */ - User::Ptr leftChatMember; - - /** - * @brief Optional. A group title was changed to this value. - */ - std::string newChatTitle; - - /** - * @brief Optional. A group photo was change to this value. - */ - std::vector<PhotoSize::Ptr> newChatPhoto; - - /** - * @brief Optional. Informs that the group photo was deleted. - */ - bool deleteChatPhoto = false; - - /** - * @brief Optional. Informs that the group has been created. - */ - bool groupChatCreated = false; - - /** - * @brief Optional. Service message: the supergroup has been created. - */ - bool supergroupChatCreated = false; - - /** - * @brief Optional. Service message: the channel has been created. - */ - bool channelChatCreated = false; - - /** - * @brief Optional. The group has been migrated to a supergroup with the specified identifier, not exceeding 1e13 by absolute value. - */ - int64_t migrateToChatId = 0; - - /** - * @brief Optional. The supergroup has been migrated from a group with the specified identifier, not exceeding 1e13 by absolute value - */ - int64_t migrateFromChatId = 0; - - /** - * @brief Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply. - */ - Message::Ptr pinnedMessage; - - /** - * @brief Optional. Message is an invoice for a payment, information about the invoice. - */ - Invoice::Ptr invoice; - - /** - * @brief Optional. Message is a service message about a successful payment, information about the payment. - */ - SuccessfulPayment::Ptr successfulPayment; - - /** - * @brief Optional. The domain name of the website on which the user has logged in. - */ - std::string connectedWebsite; + typedef std::shared_ptr<Message> Ptr; + + /** + * @brief Unique message identifier. + */ + int32_t messageId; + + /** + * @brief Optional. Sender, can be empty for messages sent to channels. + */ + User::Ptr from; + + /** + * @brief Date the message was sent in Unix time. + */ + int32_t date; + + /** + * @brief Conversation the message belongs to. + */ + Chat::Ptr chat; + + /** + * @brief Optional. For forwarded messages, sender of the original message. + */ + User::Ptr forwardFrom; + + /** + * @brief Optional. For messages forwarded from a channel, information about the original channel + */ + Chat::Ptr forwardFromChat; + + /** + * @brief Optional. For forwarded channel posts, identifier of the original message in the channel + */ + int32_t forwardFromMessageId; + + /** + * @brief Optional. For messages forwarded from channels, signature of the post author if present. + */ + std::string forwardSignature; + + /** + * @brief Optional. For forwarded messages, date the original message was sent in Unix time. + */ + int32_t forwardDate; + + /** + * @brief Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. + */ + Message::Ptr replyToMessage; + + /** + * @brief Optional. Date the message was last edited in Unix time. + */ + int32_t editDate; + + /** + * @brief Optional. Signature of the post author for messages in channels. + */ + std::string authorSignature; + + /** + * @brief Optional. For text messages, the actual UTF-8 text of the message. + */ + std::string text; + + /** + * @brief Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text. + */ + std::vector<MessageEntity::Ptr> entities; + + /** + * @brief Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption + */ + std::vector<MessageEntity::Ptr> captionEntities; + + /** + * @brief Optional. Message is an audio file, information about the file. + */ + Audio::Ptr audio; + + /** + * @brief Optional. Message is a general file, information about the file. + */ + Document::Ptr document; + + /** + * @brief Optional. Message is a game, information about the game. + */ + Game::Ptr game; + + /** + * @brief Optional. Message is a photo, available sizes of the photo. + */ + std::vector<PhotoSize::Ptr> photo; + + /** + * @brief Optional. Message is a sticker, information about the sticker. + */ + Sticker::Ptr sticker; + + /** + * @brief Optional. Message is a video, information about the video. + */ + Video::Ptr video; + + /** + * @brief Optional. Message is a voice message, information about the file. + */ + Voice::Ptr voice; + + /** + * @brief Optional. Caption for the document, photo or video, 0-200 characters. + */ + std::string caption; + + /** + * @brief Optional. Message is a shared contact, information about the contact. + */ + Contact::Ptr contact; + + /** + * @brief Optional. Message is a shared location, information about the location. + */ + Location::Ptr location; + + /** + * @brief Optional. Message is a venue, information about the venue. + */ + Venue::Ptr venue; + + /** + * @brief Optional. A new member was added to the group, information about them (this member may be bot itself). + */ + User::Ptr newChatMember; + + /** + * @brief Optional. New members that were added to the group or supergroup and information about them (the bot itself may be one of these members) + */ + std::vector<User::Ptr> newChatMembers; + + /** + * @brief Optional. A member was removed from the group, information about them (this member may be bot itself). + */ + User::Ptr leftChatMember; + + /** + * @brief Optional. A group title was changed to this value. + */ + std::string newChatTitle; + + /** + * @brief Optional. A group photo was change to this value. + */ + std::vector<PhotoSize::Ptr> newChatPhoto; + + /** + * @brief Optional. Informs that the group photo was deleted. + */ + bool deleteChatPhoto = false; + + /** + * @brief Optional. Informs that the group has been created. + */ + bool groupChatCreated = false; + + /** + * @brief Optional. Service message: the supergroup has been created. + */ + bool supergroupChatCreated = false; + + /** + * @brief Optional. Service message: the channel has been created. + */ + bool channelChatCreated = false; + + /** + * @brief Optional. The group has been migrated to a supergroup with the specified identifier, not exceeding 1e13 by absolute value. + */ + int64_t migrateToChatId = 0; + + /** + * @brief Optional. The supergroup has been migrated from a group with the specified identifier, not exceeding 1e13 by absolute value + */ + int64_t migrateFromChatId = 0; + + /** + * @brief Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply. + */ + Message::Ptr pinnedMessage; + + /** + * @brief Optional. Message is an invoice for a payment, information about the invoice. + */ + Invoice::Ptr invoice; + + /** + * @brief Optional. Message is a service message about a successful payment, information about the payment. + */ + SuccessfulPayment::Ptr successfulPayment; + + /** + * @brief Optional. The domain name of the website on which the user has logged in. + */ + std::string connectedWebsite; }; } diff --git a/include/tgbot/types/MessageEntity.h b/include/tgbot/types/MessageEntity.h index e551d6e..ca495ee 100644 --- a/include/tgbot/types/MessageEntity.h +++ b/include/tgbot/types/MessageEntity.h @@ -18,32 +18,32 @@ namespace TgBot { */ class MessageEntity { public: - typedef std::shared_ptr<MessageEntity> Ptr; - - /** - * @brief Type of the entity. One of mention (@username), hashtag, bot_command, url, email, bold (bold text), italic (italic text), code (monowidth string), pre (monowidth block), text_link (for clickable text URLs). - */ - std::string type; - - /** - * @brief Offset in UTF-16 code units to the start of the entity. - */ - int32_t offset; - - /** - * @brief Length of the entity in UTF-16 code units - */ - int32_t length; - - /** - * @brief Optional. For “text_link” only, url that will be opened after user taps on the text - */ - std::string url; - - /** - * @brief Optional. For “text_mention” only, the mentioned user - */ - User::Ptr user; + typedef std::shared_ptr<MessageEntity> Ptr; + + /** + * @brief Type of the entity. One of mention (@username), hashtag, bot_command, url, email, bold (bold text), italic (italic text), code (monowidth string), pre (monowidth block), text_link (for clickable text URLs). + */ + std::string type; + + /** + * @brief Offset in UTF-16 code units to the start of the entity. + */ + int32_t offset; + + /** + * @brief Length of the entity in UTF-16 code units + */ + int32_t length; + + /** + * @brief Optional. For “text_link” only, url that will be opened after user taps on the text + */ + std::string url; + + /** + * @brief Optional. For “text_mention” only, the mentioned user + */ + User::Ptr user; }; } diff --git a/include/tgbot/types/PhotoSize.h b/include/tgbot/types/PhotoSize.h index 8e87469..7a3cb80 100644 --- a/include/tgbot/types/PhotoSize.h +++ b/include/tgbot/types/PhotoSize.h @@ -36,27 +36,27 @@ namespace TgBot { class PhotoSize { public: - typedef std::shared_ptr<PhotoSize> Ptr; + typedef std::shared_ptr<PhotoSize> Ptr; - /** - * @brief Unique identifier for this file. - */ - std::string fileId; + /** + * @brief Unique identifier for this file. + */ + std::string fileId; - /** - * @brief Photo width. - */ - int32_t width; + /** + * @brief Photo width. + */ + int32_t width; - /** - * @brief Photo height. - */ - int32_t height; + /** + * @brief Photo height. + */ + int32_t height; - /** - * @brief Optional. File size. - */ - int32_t fileSize; + /** + * @brief Optional. File size. + */ + int32_t fileSize; }; } diff --git a/include/tgbot/types/ReplyKeyboardMarkup.h b/include/tgbot/types/ReplyKeyboardMarkup.h index 84d4a60..f857003 100644 --- a/include/tgbot/types/ReplyKeyboardMarkup.h +++ b/include/tgbot/types/ReplyKeyboardMarkup.h @@ -40,29 +40,29 @@ namespace TgBot { class ReplyKeyboardMarkup : public GenericReply { public: - typedef std::shared_ptr<ReplyKeyboardMarkup> Ptr; + typedef std::shared_ptr<ReplyKeyboardMarkup> Ptr; - /** - * @brief Array of button rows, each represented by an Array of KeyboardButton. - */ - std::vector<std::vector<KeyboardButton::Ptr>> keyboard; + /** + * @brief Array of button rows, each represented by an Array of KeyboardButton. + */ + std::vector<std::vector<KeyboardButton::Ptr>> keyboard; - /** - * @brief Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard. - */ - bool resizeKeyboard = false; + /** + * @brief Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard. + */ + bool resizeKeyboard = false; - /** - * @brief Optional. Requests clients to hide the keyboard as soon as it's been used. Defaults to false. - */ - bool oneTimeKeyboard = false; + /** + * @brief Optional. Requests clients to hide the keyboard as soon as it's been used. Defaults to false. + */ + bool oneTimeKeyboard = false; - /** - * @brief Optional. Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. - * - * Example: A user requests to change the bot‘s language, bot replies to the request with a keyboard to select the new language. Other users in the group don’t see the keyboard. - */ - bool selective = false; + /** + * @brief Optional. Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. + * + * Example: A user requests to change the bot‘s language, bot replies to the request with a keyboard to select the new language. Other users in the group don’t see the keyboard. + */ + bool selective = false; }; } diff --git a/include/tgbot/types/ReplyKeyboardRemove.h b/include/tgbot/types/ReplyKeyboardRemove.h index dbe6f2b..6b75b60 100644 --- a/include/tgbot/types/ReplyKeyboardRemove.h +++ b/include/tgbot/types/ReplyKeyboardRemove.h @@ -22,21 +22,21 @@ namespace TgBot { class ReplyKeyboardRemove : public GenericReply { public: - typedef std::shared_ptr<ReplyKeyboardRemove> Ptr; - - /** - * @brief Requests clients to remove the custom keyboard (user will not be able to summon this keyboard; - * - * if you want to hide the keyboard from sight but keep it accessible, use one_time_keyboard in ReplyKeyboardMarkup) - */ - const bool removeKeyboard = true; - - /** - * @brief Optional. Use this parameter if you want to remove the keyboard for specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. - * - * Example: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet. - */ - bool selective = false; + typedef std::shared_ptr<ReplyKeyboardRemove> Ptr; + + /** + * @brief Requests clients to remove the custom keyboard (user will not be able to summon this keyboard; + * + * if you want to hide the keyboard from sight but keep it accessible, use one_time_keyboard in ReplyKeyboardMarkup) + */ + const bool removeKeyboard = true; + + /** + * @brief Optional. Use this parameter if you want to remove the keyboard for specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. + * + * Example: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet. + */ + bool selective = false; }; } diff --git a/include/tgbot/types/ResponseParameters.h b/include/tgbot/types/ResponseParameters.h index c55a15f..a9b73b7 100644 --- a/include/tgbot/types/ResponseParameters.h +++ b/include/tgbot/types/ResponseParameters.h @@ -16,21 +16,21 @@ namespace TgBot { */ class ResponseParameters { public: - typedef std::shared_ptr<ResponseParameters> Ptr; + typedef std::shared_ptr<ResponseParameters> Ptr; - /** - * @brief Optional. The group has been migrated to a supergroup with the specified identifier. - * - * This number 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. - */ - int32_t migrateToChatId; + /** + * @brief Optional. The group has been migrated to a supergroup with the specified identifier. + * + * This number 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. + */ + int32_t migrateToChatId; - /** - * @brief Optional. In case of exceeding flood control, the number of seconds left to wait before the request can be repeated - */ - int32_t retryAfter; + /** + * @brief Optional. In case of exceeding flood control, the number of seconds left to wait before the request can be repeated + */ + int32_t retryAfter; }; } diff --git a/include/tgbot/types/Sticker.h b/include/tgbot/types/Sticker.h index 46ef41d..9fd200a 100644 --- a/include/tgbot/types/Sticker.h +++ b/include/tgbot/types/Sticker.h @@ -39,47 +39,47 @@ namespace TgBot { class Sticker { public: - typedef std::shared_ptr<Sticker> Ptr; - - /** - * @brief Unique file identifier. - */ - std::string fileId; - - /** - * @brief Optional. Sticker width. - */ - int32_t width; - - /** - * @brief Optional. Sticker height. - */ - int32_t height; - - /** - * @brief Optional. Optional. Sticker thumbnail in .webp or .jpg format. - */ - PhotoSize::Ptr thumb; - - /** - * @brief Optional. Emoji associated with the sticker - */ - std::string emoji; - - /** - * @brief Optional. Name of the sticker set to which the sticker belongs. - */ - std::string setName; - - /** - * @brief Optional. For mask stickers, the position where the mask should be placed. - */ - MaskPosition::Ptr maskPosition; - - /** - * @brief Optional. File size. - */ - int32_t fileSize; + typedef std::shared_ptr<Sticker> Ptr; + + /** + * @brief Unique file identifier. + */ + std::string fileId; + + /** + * @brief Optional. Sticker width. + */ + int32_t width; + + /** + * @brief Optional. Sticker height. + */ + int32_t height; + + /** + * @brief Optional. Optional. Sticker thumbnail in .webp or .jpg format. + */ + PhotoSize::Ptr thumb; + + /** + * @brief Optional. Emoji associated with the sticker + */ + std::string emoji; + + /** + * @brief Optional. Name of the sticker set to which the sticker belongs. + */ + std::string setName; + + /** + * @brief Optional. For mask stickers, the position where the mask should be placed. + */ + MaskPosition::Ptr maskPosition; + + /** + * @brief Optional. File size. + */ + int32_t fileSize; }; } diff --git a/include/tgbot/types/StickerSet.h b/include/tgbot/types/StickerSet.h index aaa9496..d08fd4a 100644 --- a/include/tgbot/types/StickerSet.h +++ b/include/tgbot/types/StickerSet.h @@ -39,27 +39,27 @@ namespace TgBot { */ class StickerSet { public: - typedef std::shared_ptr<StickerSet> Ptr; + typedef std::shared_ptr<StickerSet> Ptr; - /** - * @brief Sticker set name. - */ - std::string name; + /** + * @brief Sticker set name. + */ + std::string name; /** - * @brief Sticker set title. - */ - std::string title; + * @brief Sticker set title. + */ + std::string title; /** * @brief True, if the sticker set contains masks. */ bool containsMasks = false; - /** - * @brief List of all set stickers. - */ - std::vector<Sticker::Ptr> stickers; + /** + * @brief List of all set stickers. + */ + std::vector<Sticker::Ptr> stickers; }; } diff --git a/include/tgbot/types/Update.h b/include/tgbot/types/Update.h index 1dcac76..0c0eb0e 100644 --- a/include/tgbot/types/Update.h +++ b/include/tgbot/types/Update.h @@ -42,61 +42,61 @@ namespace TgBot { class Update { public: - typedef std::shared_ptr<Update> Ptr; - - /** - * @brief The update‘s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. - */ - int32_t updateId; - - /** - * @brief Optional. New incoming message of any kind — text, photo, sticker, etc. - */ - Message::Ptr message; - - /** - * @brief Optional. New version of a message that is known to the bot and was edited - */ - Message::Ptr editedMessage; - - /** - * @brief Optional. New incoming channel post of any kind — text, photo, sticker, etc. - */ - Message::Ptr channelPost; - - /** - * @brief Optional. New version of a channel post that is known to the bot and was edited - */ - Message::Ptr editedChannelPost; - - /** - * @brief Optional. New incoming inline query - */ - InlineQuery::Ptr inlineQuery; - - /** - * @brief Optional. The result of an inline query that was chosen by a user and sent to their chat partner. - */ - ChosenInlineResult::Ptr chosenInlineResult; - - /** - * @brief Optional. New incoming callback query. - */ - CallbackQuery::Ptr callbackQuery; - - /** - * @brief Optional. New incoming shipping query. - * - * Only for invoices with flexible price - */ - ShippingQuery::Ptr shippingQuery; - - /** - * @brief Optional. New incoming pre-checkout query. - * - * Contains full information about checkout - */ - PreCheckoutQuery::Ptr preCheckoutQuery; + typedef std::shared_ptr<Update> Ptr; + + /** + * @brief The update‘s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. + */ + int32_t updateId; + + /** + * @brief Optional. New incoming message of any kind — text, photo, sticker, etc. + */ + Message::Ptr message; + + /** + * @brief Optional. New version of a message that is known to the bot and was edited + */ + Message::Ptr editedMessage; + + /** + * @brief Optional. New incoming channel post of any kind — text, photo, sticker, etc. + */ + Message::Ptr channelPost; + + /** + * @brief Optional. New version of a channel post that is known to the bot and was edited + */ + Message::Ptr editedChannelPost; + + /** + * @brief Optional. New incoming inline query + */ + InlineQuery::Ptr inlineQuery; + + /** + * @brief Optional. The result of an inline query that was chosen by a user and sent to their chat partner. + */ + ChosenInlineResult::Ptr chosenInlineResult; + + /** + * @brief Optional. New incoming callback query. + */ + CallbackQuery::Ptr callbackQuery; + + /** + * @brief Optional. New incoming shipping query. + * + * Only for invoices with flexible price + */ + ShippingQuery::Ptr shippingQuery; + + /** + * @brief Optional. New incoming pre-checkout query. + * + * Contains full information about checkout + */ + PreCheckoutQuery::Ptr preCheckoutQuery; }; } diff --git a/include/tgbot/types/User.h b/include/tgbot/types/User.h index 10a80dd..0b1dc5b 100644 --- a/include/tgbot/types/User.h +++ b/include/tgbot/types/User.h @@ -36,37 +36,37 @@ namespace TgBot { class User { public: - typedef std::shared_ptr<User> Ptr; + typedef std::shared_ptr<User> Ptr; - /** - * @brief Unique identifier for this user or bot. - */ - int32_t id; + /** + * @brief Unique identifier for this user or bot. + */ + int32_t id; - /** - * @brief True, if this user is a bot - */ - bool isBot = false; + /** + * @brief True, if this user is a bot + */ + bool isBot = false; - /** - * @brief User‘s or bot’s first name. - */ - std::string firstName; + /** + * @brief User‘s or bot’s first name. + */ + std::string firstName; - /** - * @brief Optional. User‘s or bot’s last name. - */ - std::string lastName; + /** + * @brief Optional. User‘s or bot’s last name. + */ + std::string lastName; - /** - * @brief Optional. User‘s or bot’s username. - */ - std::string username; + /** + * @brief Optional. User‘s or bot’s username. + */ + std::string username; - /** - * @brief Optional. IETF language tag of the user's language. - */ - std::string languageCode; + /** + * @brief Optional. IETF language tag of the user's language. + */ + std::string languageCode; }; } diff --git a/include/tgbot/types/UserProfilePhotos.h b/include/tgbot/types/UserProfilePhotos.h index 25cacd9..0c21a15 100644 --- a/include/tgbot/types/UserProfilePhotos.h +++ b/include/tgbot/types/UserProfilePhotos.h @@ -38,17 +38,17 @@ namespace TgBot { class UserProfilePhotos { public: - typedef std::shared_ptr<UserProfilePhotos> Ptr; + typedef std::shared_ptr<UserProfilePhotos> Ptr; - /** - * @brief Total number of profile pictures the target user has. - */ - int32_t totalCount; + /** + * @brief Total number of profile pictures the target user has. + */ + int32_t totalCount; - /** - * @brief Requested profile pictures (in up to 4 sizes each). - */ - std::vector<std::vector<PhotoSize::Ptr>> photos; + /** + * @brief Requested profile pictures (in up to 4 sizes each). + */ + std::vector<std::vector<PhotoSize::Ptr>> photos; }; } diff --git a/include/tgbot/types/Venue.h b/include/tgbot/types/Venue.h index 7e8ada6..657d951 100644 --- a/include/tgbot/types/Venue.h +++ b/include/tgbot/types/Venue.h @@ -19,27 +19,27 @@ namespace TgBot { */ class Venue { public: - typedef std::shared_ptr<Venue> Ptr; - - /** - * @brief Venue location. - */ - Location::Ptr location; - - /** - * @brief Name of the venue. - */ - std::string title; - - /** - * @brief Address of the venue. - */ - std::string address; - - /** - * @brief Optional. Foursquare identifier of the venue. - */ - std::string foursquare_id; + typedef std::shared_ptr<Venue> Ptr; + + /** + * @brief Venue location. + */ + Location::Ptr location; + + /** + * @brief Name of the venue. + */ + std::string title; + + /** + * @brief Address of the venue. + */ + std::string address; + + /** + * @brief Optional. Foursquare identifier of the venue. + */ + std::string foursquare_id; }; } diff --git a/include/tgbot/types/Video.h b/include/tgbot/types/Video.h index e491aac..21c9c35 100644 --- a/include/tgbot/types/Video.h +++ b/include/tgbot/types/Video.h @@ -38,42 +38,42 @@ namespace TgBot { class Video { public: - typedef std::shared_ptr<Video> Ptr; + typedef std::shared_ptr<Video> Ptr; - /** - * @brief Unique identifier for this file. - */ - std::string fileId; + /** + * @brief Unique identifier for this file. + */ + std::string fileId; - /** - * @brief Video width as defined by sender. - */ - int32_t width; + /** + * @brief Video width as defined by sender. + */ + int32_t width; - /** - * @brief Video height as defined by sender. - */ - int32_t height; + /** + * @brief Video height as defined by sender. + */ + int32_t height; - /** - * @brief Duration of the video in seconds as defined by sender. - */ - int32_t duration; + /** + * @brief Duration of the video in seconds as defined by sender. + */ + int32_t duration; - /** - * @brief Optional. Video thumbnail. - */ - PhotoSize::Ptr thumb; + /** + * @brief Optional. Video thumbnail. + */ + PhotoSize::Ptr thumb; - /** - * @brief Optional. Mime type of a file as defined by sender - */ - std::string mimeType; + /** + * @brief Optional. Mime type of a file as defined by sender + */ + std::string mimeType; - /** - * @brief Optional. File size. - */ - int32_t fileSize; + /** + * @brief Optional. File size. + */ + int32_t fileSize; }; } diff --git a/include/tgbot/types/VideoNote.h b/include/tgbot/types/VideoNote.h index 0e879ad..0499051 100644 --- a/include/tgbot/types/VideoNote.h +++ b/include/tgbot/types/VideoNote.h @@ -40,30 +40,30 @@ class VideoNote { public: typedef std::shared_ptr<VideoNote> Ptr; - /** - * @brief Unique identifier for this file. - */ - std::string fileId; + /** + * @brief Unique identifier for this file. + */ + std::string fileId; - /** - * @brief Video width and height as defined by sender. - */ - int32_t length; + /** + * @brief Video width and height as defined by sender. + */ + int32_t length; - /** - * @brief Duration of the video in seconds as defined by sender. - */ - int32_t duration; + /** + * @brief Duration of the video in seconds as defined by sender. + */ + int32_t duration; - /** - * @brief Optional. Video thumbnail. - */ - PhotoSize::Ptr thumb; + /** + * @brief Optional. Video thumbnail. + */ + PhotoSize::Ptr thumb; - /** - * @brief Optional. File size. - */ - int32_t fileSize; + /** + * @brief Optional. File size. + */ + int32_t fileSize; }; } diff --git a/include/tgbot/types/Voice.h b/include/tgbot/types/Voice.h index 397f5b0..0957349 100644 --- a/include/tgbot/types/Voice.h +++ b/include/tgbot/types/Voice.h @@ -17,27 +17,27 @@ namespace TgBot { */ class Voice { public: - typedef std::shared_ptr<Voice> Ptr; - - /** - * @brief Unique identifier for this file. - */ - std::string file_id; - - /** - * @brief Duration of the audio in seconds as defined by sender. - */ - int32_t duration; - - /** - * @brief Optional. MIME type of the file as defined by sender; - */ - std::string mime_type; - - /** - * @brief Optional. File size. - */ - int32_t file_size; + typedef std::shared_ptr<Voice> Ptr; + + /** + * @brief Unique identifier for this file. + */ + std::string file_id; + + /** + * @brief Duration of the audio in seconds as defined by sender. + */ + int32_t duration; + + /** + * @brief Optional. MIME type of the file as defined by sender; + */ + std::string mime_type; + + /** + * @brief Optional. File size. + */ + int32_t file_size; }; } diff --git a/include/tgbot/types/WebhookInfo.h b/include/tgbot/types/WebhookInfo.h index 9bea884..00aae2e 100644 --- a/include/tgbot/types/WebhookInfo.h +++ b/include/tgbot/types/WebhookInfo.h @@ -18,42 +18,42 @@ namespace TgBot { */ class WebhookInfo { public: - typedef std::shared_ptr<WebhookInfo> Ptr; - - /** - * @brief Webhook URL, may be empty if webhook is not set up. - */ - std::string url; - - /** - * @brief True, if a custom certificate was provided for webhook certificate checks - */ - bool hasCustomCertificate; - - /** - * @brief Number of updates awaiting delivery - */ - int32_t pendingUpdateCount; - - /** - * @brief Optional. Unix time for the most recent error that happened when trying to deliver an update via webhook - */ - int32_t lastErrorDate; - - /** - * @brief Optional. Error message in human - readable format for the most recent error that happened when trying to deliver an update via webhook - */ - std::string lastErrorMessage; - - /** - * @brief Optional. Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery - */ - int32_t maxConnections; - - /** - * @brief Optional. A list of update types the bot is subscribed to. Defaults to all update types - */ - std::vector<std::string> allowedUpdates; + typedef std::shared_ptr<WebhookInfo> Ptr; + + /** + * @brief Webhook URL, may be empty if webhook is not set up. + */ + std::string url; + + /** + * @brief True, if a custom certificate was provided for webhook certificate checks + */ + bool hasCustomCertificate; + + /** + * @brief Number of updates awaiting delivery + */ + int32_t pendingUpdateCount; + + /** + * @brief Optional. Unix time for the most recent error that happened when trying to deliver an update via webhook + */ + int32_t lastErrorDate; + + /** + * @brief Optional. Error message in human - readable format for the most recent error that happened when trying to deliver an update via webhook + */ + std::string lastErrorMessage; + + /** + * @brief Optional. Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery + */ + int32_t maxConnections; + + /** + * @brief Optional. A list of update types the bot is subscribed to. Defaults to all update types + */ + std::vector<std::string> allowedUpdates; }; } |