From 66cbca3b206567ce62af42cab950696ef6f80adb Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Sun, 27 May 2018 02:27:44 +0900 Subject: Bot API 3.0 (Maks Mazurov (fox.cpp)) --- include/tgbot/Api.h | 29 ++++++++ include/tgbot/TgTypeParser.h | 35 ++++++++++ include/tgbot/tgbot.h | 1 + include/tgbot/types/InlineQueryResultGif.h | 5 ++ include/tgbot/types/InlineQueryResultMpeg4Gif.h | 5 ++ include/tgbot/types/Invoice.h | 78 +++++++++++++++++++++ include/tgbot/types/LabeledPrice.h | 42 ++++++++++++ include/tgbot/types/Message.h | 5 ++ include/tgbot/types/OrderInfo.h | 66 ++++++++++++++++++ include/tgbot/types/PreCheckoutQuery.h | 91 +++++++++++++++++++++++++ include/tgbot/types/ShippingAddress.h | 75 ++++++++++++++++++++ include/tgbot/types/ShippingOption.h | 43 ++++++++++++ include/tgbot/types/ShippingQuery.h | 68 ++++++++++++++++++ include/tgbot/types/SuccessfulPayment.h | 90 ++++++++++++++++++++++++ include/tgbot/types/User.h | 5 ++ include/tgbot/types/VideoNote.h | 70 +++++++++++++++++++ 16 files changed, 708 insertions(+) create mode 100644 include/tgbot/types/Invoice.h create mode 100644 include/tgbot/types/LabeledPrice.h create mode 100644 include/tgbot/types/OrderInfo.h create mode 100644 include/tgbot/types/PreCheckoutQuery.h create mode 100644 include/tgbot/types/ShippingAddress.h create mode 100644 include/tgbot/types/ShippingOption.h create mode 100644 include/tgbot/types/ShippingQuery.h create mode 100644 include/tgbot/types/SuccessfulPayment.h create mode 100644 include/tgbot/types/VideoNote.h (limited to 'include/tgbot') diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index 4eb63c7..10cc91e 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -229,6 +229,35 @@ public: Message::Ptr sendVideo(int64_t chatId, const std::string& videoId, 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(), bool disableNotification = false) const; + /** + * 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. + * @param replyToMessageId If the message is a reply, ID of the original message. + * @param disableNotification Sends the message silently. Users will receive a notification with no sound. + * @param duration Duration of sent video in seconds. + * @param length Video width and height. + * @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()); + + /** + * Use this method to send video messages. On success, the sent Message is returned. + * @param chatId Unique identifier for the target chat. + * @param videoNote Id of the video note that exists on the Telegram servers. + * @param replyToMessageId If the message is a reply, ID of the original message. + * @param disableNotification Sends the message silently. Users will receive a notification with no sound. + * @param duration Duration of sent video in seconds. + * @param length Video width and height. + * @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 std::string &videoNote, int64_t replyToMessageId = 0, bool disableNotification = false, + int32_t duration = 0, int32_t length = 0, const GenericReply::Ptr replyMarkup = GenericReply::Ptr()); + + /** * 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. diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h index 2faaf45..bfae9aa 100644 --- a/include/tgbot/TgTypeParser.h +++ b/include/tgbot/TgTypeParser.h @@ -36,6 +36,7 @@ #include "tgbot/types/Document.h" #include "tgbot/types/Sticker.h" #include "tgbot/types/Video.h" +#include "tgbot/types/VideoNote.h" #include "tgbot/types/Contact.h" #include "tgbot/types/Location.h" #include "tgbot/types/Update.h" @@ -80,6 +81,14 @@ #include "tgbot/types/InputLocationMessageContent.h" #include "tgbot/types/InputVenueMessageContent.h" #include "tgbot/types/InputContactMessageContent.h" +#include "tgbot/types/Invoice.h" +#include "tgbot/types/OrderInfo.h" +#include "tgbot/types/PreCheckoutQuery.h" +#include "tgbot/types/ShippingAddress.h" +#include "tgbot/types/ShippingQuery.h" +#include "tgbot/types/ShippingOption.h" +#include "tgbot/types/SuccessfulPayment.h" +#include "tgbot/types/LabeledPrice.h" namespace TgBot { @@ -111,6 +120,8 @@ public: std::string parseSticker(const Sticker::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; 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; @@ -234,6 +245,30 @@ public: 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 parseJsonAndGetSucessfulPayment(const boost::property_tree::ptree& data) const; + std::string parseSucessfulPayment(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); diff --git a/include/tgbot/tgbot.h b/include/tgbot/tgbot.h index 39de85e..687783b 100644 --- a/include/tgbot/tgbot.h +++ b/include/tgbot/tgbot.h @@ -45,6 +45,7 @@ #include "tgbot/types/User.h" #include "tgbot/types/UserProfilePhotos.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" diff --git a/include/tgbot/types/InlineQueryResultGif.h b/include/tgbot/types/InlineQueryResultGif.h index 6159886..1b6f9a3 100644 --- a/include/tgbot/types/InlineQueryResultGif.h +++ b/include/tgbot/types/InlineQueryResultGif.h @@ -43,6 +43,11 @@ public: */ int32_t gifHeight; + /** + * Optional. Duration of the GIF + */ + int32_t gifDuration; + /** * URL of the static thumbnail for the result (jpeg or gif) */ diff --git a/include/tgbot/types/InlineQueryResultMpeg4Gif.h b/include/tgbot/types/InlineQueryResultMpeg4Gif.h index c1dbb9e..9727281 100644 --- a/include/tgbot/types/InlineQueryResultMpeg4Gif.h +++ b/include/tgbot/types/InlineQueryResultMpeg4Gif.h @@ -38,6 +38,11 @@ public: */ int32_t mpeg4Height; + /** + * Optional. Video duration. + */ + int32_t mpeg4Duration; + /** * URL of the static thumbnail (jpeg or gif) for the result */ diff --git a/include/tgbot/types/Invoice.h b/include/tgbot/types/Invoice.h new file mode 100644 index 0000000..7836e14 --- /dev/null +++ b/include/tgbot/types/Invoice.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2015 Oleg Morozenkov + * Copyright (c) 2017 Maks Mazurov (fox.cpp) + * + * 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_INVOICE_H +#define TGBOT_INVOICE_H + +#include +#include + +namespace TgBot { + +/** + * @brief This object contains basic information about an invoice. + * + * https://core.telegram.org/bots/api#invoice + * + * @ingroup types + */ +class Invoice { +public: + typedef std::shared_ptr Ptr; + + /** + * @brief Product name. + */ + std::string title; + + /** + * @brief Product description. + */ + std::string description; + + /** + * @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 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; +}; +} + +#endif //TGBOT_INVOICE_H diff --git a/include/tgbot/types/LabeledPrice.h b/include/tgbot/types/LabeledPrice.h new file mode 100644 index 0000000..64b9aeb --- /dev/null +++ b/include/tgbot/types/LabeledPrice.h @@ -0,0 +1,42 @@ +// +// Created by Maks Mazurov (fox.cpp) on 21.05.17. +// + +#ifndef TGBOT_LABELEDPRICE_H +#define TGBOT_LABELEDPRICE_H + +#include +#include + +namespace TgBot { + +/** + * @brief This object represents a portion of the price for goods or services. + * + * https://core.telegram.org/bots/api#labeledprice + * @ingroup types + */ +class LabeledPrice { +public: + typedef std::shared_ptr Ptr; + + /** + * @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; +}; +} + +#endif //TGBOT_LABELEDPRICE_H diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h index 415f616..ee293b9 100644 --- a/include/tgbot/types/Message.h +++ b/include/tgbot/types/Message.h @@ -175,6 +175,11 @@ public: */ User::Ptr newChatMember; + /** + * 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 newChatMembers; + /** * Optional. A member was removed from the group, information about them (this member may be bot itself). */ diff --git a/include/tgbot/types/OrderInfo.h b/include/tgbot/types/OrderInfo.h new file mode 100644 index 0000000..45c3d75 --- /dev/null +++ b/include/tgbot/types/OrderInfo.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2015 Oleg Morozenkov + * Copyright (c) 2017 Maks Mazurov (fox.cpp) + * + * 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_ORDERINFO_H +#define TGBOT_ORDERINFO_H + +#include +#include +#include "tgbot/types/ShippingAddress.h" + +namespace TgBot { + +/** + * @brief This object represents information about an order. + * + * https://core.telegram.org/bots/api#orderinfo + * + * @ingroup types + */ +class OrderInfo { +public: + typedef std::shared_ptr Ptr; + + /** + * @brief Optional. User name. + */ + std::string name; + + /** + * @brief Optional. User's phone number. + */ + std::string phoneNumber; + + /** + * @brief Optional. User email. + */ + std::string email; + + /** + * @brief Optional. User shipping address. + */ + ShippingAddress::Ptr shippingAddress; +}; +} + +#endif //TGBOT_ORDERINFO_H diff --git a/include/tgbot/types/PreCheckoutQuery.h b/include/tgbot/types/PreCheckoutQuery.h new file mode 100644 index 0000000..7282b3b --- /dev/null +++ b/include/tgbot/types/PreCheckoutQuery.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2015 Oleg Morozenkov + * Copyright (c) 2017 Maks Mazurov (fox.cpp) + * + * 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_PRECHECKOUTQUERY_H +#define TGBOT_PRECHECKOUTQUERY_H + +#include +#include +#include +#include "tgbot/types/User.h" +#include "tgbot/types/OrderInfo.h" + +namespace TgBot { + +/** + * @brief This object contains information about an incoming pre-checkout query. + * + * https://core.telegram.org/bots/api#precheckoutquery + * + * @ingroup types + */ +class PreCheckoutQuery { +public: + typedef std::shared_ptr Ptr; + + /** + * @brief Unique query identifier. + */ + std::string id; + + /** + * @brief User who sent the query. + */ + User::Ptr from; + + /** + * @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 Bot specified invoice payload. + */ + std::string invoicePayload; + + /** + * @brief Optional. Identifier of the shipping option chosen by the user. + */ + std::string shippingOptionId; + + /** + * @brief Optional. Order info provided by the user. + */ + OrderInfo::Ptr orderInfo; +}; +} + +#endif //TGBOT_PRECHECKOUTQUERY_H diff --git a/include/tgbot/types/ShippingAddress.h b/include/tgbot/types/ShippingAddress.h new file mode 100644 index 0000000..97ac33f --- /dev/null +++ b/include/tgbot/types/ShippingAddress.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2015 Oleg Morozenkov + * Copyright (c) 2017 Maks Mazurov (fox.cpp) + * + * 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_SHIPPINGADDRESS_H +#define TGBOT_SHIPPINGADDRESS_H + +#include +#include + +namespace TgBot { + +/** + * @brief This object represents a shipping address. + * + * https://core.telegram.org/bots/api#shippingaddress + * + * @ingroup types + */ +class ShippingAddress { +public: + typedef std::shared_ptr Ptr; + + /** + * @brief ISO 3166-1 alpha-2 country code. + */ + std::string countryCode; + + /** + * @brief State, if applicable. + */ + std::string state; + + /** + * @brief City. + */ + std::string city; + + /** + * @brief First line for the address. + */ + std::string streetLine1; + + /** + * @brief Second line for the address. + */ + std::string streetLine2; + + /** + * Address post code. + */ + std::string postCode; +}; +} + +#endif //TGBOT_SHIPPINGADDRESS_H diff --git a/include/tgbot/types/ShippingOption.h b/include/tgbot/types/ShippingOption.h new file mode 100644 index 0000000..a946681 --- /dev/null +++ b/include/tgbot/types/ShippingOption.h @@ -0,0 +1,43 @@ +// +// Created by Maks Mazurov (fox.cpp) on 21.05.17. +// + +#ifndef TGBOT_SHIPPINGOPTION_H +#define TGBOT_SHIPPINGOPTION_H + +#include +#include +#include +#include "tgbot/types/LabeledPrice.h" + +namespace TgBot { + +/** + * @brief This object represents one shipping option. + * + * https://core.telegram.org/bots/api#shippingoption + * + * @ingroup types + */ +class ShippingOption { +public: + typedef std::shared_ptr Ptr; + + /** + * @brief Shipping option identifier. + */ + std::string id; + + /** + * @brief Option title. + */ + std::string title; + + /** + * @brief List of price options. + */ + std::vector prices; +}; +} + +#endif //TGBOT_SHIPPINGOPTION_H diff --git a/include/tgbot/types/ShippingQuery.h b/include/tgbot/types/ShippingQuery.h new file mode 100644 index 0000000..47c20d8 --- /dev/null +++ b/include/tgbot/types/ShippingQuery.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2015 Oleg Morozenkov + * Copyright (c) 2017 Maks Mazurov (fox.cpp) + * + * 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_SHIPPINGQUERY_H +#define TGBOT_SHIPPINGQUERY_H + +#include +#include +#include +#include "tgbot/types/User.h" +#include "tgbot/types/ShippingAddress.h" + +namespace TgBot { + +/** + * @brief This object contains information about an incoming shipping query. + * + * https://core.telegram.org/bots/api#shippingquery + * + * @ingroup types + */ +class ShippingQuery { +public: + typedef std::shared_ptr Ptr; + + /** + * @brief Unique query identifier. + */ + std::string id; + + /** + * @brief User who sent the query. + */ + User::Ptr from; + + /** + * @brief Bot specified invoice payload. + */ + std::string invoicePayload; + + /** + * @brief User specified shipping address. + */ + ShippingAddress::Ptr shippingAddress; +}; +} + +#endif //TGBOT_SHIPPINGQUERY_H diff --git a/include/tgbot/types/SuccessfulPayment.h b/include/tgbot/types/SuccessfulPayment.h new file mode 100644 index 0000000..ed96e8b --- /dev/null +++ b/include/tgbot/types/SuccessfulPayment.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2015 Oleg Morozenkov + * Copyright (c) 2017 Maks Mazurov (fox.cpp) + * + * 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_SUCCESSFULPAYMENT_H +#define TGBOT_SUCCESSFULPAYMENT_H + +#include +#include +#include +#include "tgbot/types/OrderInfo.h" + +namespace TgBot { + +/** + * @brief This object contains basic information about a successful payment. + * + * https://core.telegram.org/bots/api#successfulpayment + * + * @ingroup types + */ +class SuccessfulPayment { +public: + typedef std::shared_ptr Ptr; + + /** + * @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 Bot specified invoice payload. + */ + std::string invoicePayload; + + /** + * @brief Optional. Identifier of the shipping option chosen by the user. + */ + std::string shippingOptionId; + + /** + * @brief Optional. Order info provided by the user. + */ + OrderInfo::Ptr orderInfo; + + /** + * @brief Telegram payment identifier. + */ + std::string telegramPaymentChargeId; + + /** + * @brief Provider payment identifier. + */ + std::string providerPaymentChargeId; +}; +} + +#endif //TGBOT_SUCCESSFULPAYMENT_H diff --git a/include/tgbot/types/User.h b/include/tgbot/types/User.h index 420d355..f3a6960 100644 --- a/include/tgbot/types/User.h +++ b/include/tgbot/types/User.h @@ -56,6 +56,11 @@ public: * Optional. User‘s or bot’s username. */ std::string username; + + /** + * Optional. IETF language tag of the user's language. + */ + std::string languageCode; }; } diff --git a/include/tgbot/types/VideoNote.h b/include/tgbot/types/VideoNote.h new file mode 100644 index 0000000..bff452e --- /dev/null +++ b/include/tgbot/types/VideoNote.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2015 Oleg Morozenkov + * + * 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_CPP_VIDEONOTE_H +#define TGBOT_CPP_VIDEONOTE_H + +#include +#include + +#include "tgbot/types/PhotoSize.h" + +namespace TgBot { + +/** + * This object represents a video message (available in Telegram apps as of v.4.0). + * @ingroup types + */ +class VideoNote { + +public: + typedef std::shared_ptr Ptr; + + /** + * Unique identifier for this file. + */ + std::string fileId; + + /** + * Video width and height as defined by sender. + */ + int32_t length; + + /** + * Duration of the video in seconds as defined by sender. + */ + int32_t duration; + + /** + * Optional. Video thumbnail. + */ + PhotoSize::Ptr thumb; + + /** + * Optional. File size. + */ + int32_t fileSize; +}; + +} + +#endif //TGBOT_CPP_VIDEONOTE_H -- cgit v1.2.3 From 1deb50e9db6e1b668af8c993b449d59f001c8977 Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Sun, 27 May 2018 16:35:52 +0900 Subject: Bot API 3.1 update --- include/tgbot/Api.h | 94 +++++++++++++++++++++++++++++++++++++++- include/tgbot/TgTypeParser.h | 3 ++ include/tgbot/types/Chat.h | 41 +++++++++++++++++- include/tgbot/types/ChatMember.h | 73 ++++++++++++++++++++++++++++++- include/tgbot/types/ChatPhoto.h | 52 ++++++++++++++++++++++ 5 files changed, 259 insertions(+), 4 deletions(-) create mode 100644 include/tgbot/types/ChatPhoto.h (limited to 'include/tgbot') diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index 10cc91e..5750a83 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -493,15 +493,16 @@ public: * @return True on success */ bool answerInlineQuery(const std::string& inlineQueryId, const std::vector& results, - int32_t cacheTime=300, bool isPersonal=false, const std::string& nextOffset="", const std::string& switchPmText="", const std::string& switchPmParameter="") const; + int32_t cacheTime = 300, bool isPersonal = false, const std::string& nextOffset = "", const std::string& switchPmText = "", const std::string& switchPmParameter = "") const; /** * 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) const; + bool kickChatMember(int64_t chatId, int32_t userId, uint64_t untilDate = 0) const; /** * Use this method to unban a previously kicked user in a supergroup. @@ -511,6 +512,95 @@ public: */ bool unbanChatMember(int64_t chatId, int32_t userId) const; + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * 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, std::string title) const; + + /** + * 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, std::string description) const; + + /** + * 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; + + /** + * 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; + + /** * Downloads file from Telegram and saves it in memory. * @param filePath Telegram file path. diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h index bfae9aa..0aea80b 100644 --- a/include/tgbot/TgTypeParser.h +++ b/include/tgbot/TgTypeParser.h @@ -47,6 +47,7 @@ #include "tgbot/types/ReplyKeyboardRemove.h" #include "tgbot/types/ForceReply.h" #include "tgbot/types/ChatMember.h" +#include "tgbot/types/ChatPhoto.h" #include "tgbot/types/ResponseParameters.h" #include "tgbot/types/GenericReply.h" #include "tgbot/types/InlineQuery.h" @@ -149,6 +150,8 @@ public: 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; // returned only in getChat + ResponseParameters::Ptr parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const; std::string parseResponseParameters(const ResponseParameters::Ptr& object) const; diff --git a/include/tgbot/types/Chat.h b/include/tgbot/types/Chat.h index 698b95f..d286a63 100644 --- a/include/tgbot/types/Chat.h +++ b/include/tgbot/types/Chat.h @@ -26,6 +26,9 @@ #include #include +#include "tgbot/types/ChatPhoto.h" +#include "tgbot/types/Message.h" + namespace TgBot { /** @@ -79,9 +82,45 @@ public: /** * Optional. True if a group - * has �All Members Are Admins� enabled. + * has ‘All Members Are Admins’ enabled. */ bool allMembersAreAdministrators; + + /** + * Optional. Chat photo. + * Returned only in getChat. + */ + ChatPhoto::Ptr photo; + + /** + * Optional. Description, for supergroups and channel chats. + * Returned only in getChat. + */ + std::string description; + + /** + * Optional. Chat invite link, for supergroups and channel chats. + * Returned only in getChat. + */ + std::string inviteLink; + + /** + * Optional. Pinned message, for supergroups and channel chats. + * Returned only in getChat. + */ + Message::Ptr pinnedMessage; + + /** + * Optional. For supergroups, name of group sticker set. + * Returned only in getChat. + */ + std::string stickerSetName; + + /** + * 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 7f4b139..a77e23a 100644 --- a/include/tgbot/types/ChatMember.h +++ b/include/tgbot/types/ChatMember.h @@ -1,5 +1,6 @@ // // Created by Konstantin Kukin on 26/12/16. +// Edit by JellyBrick on 27/05/18. // #ifndef TGBOT_CHATMEMBER_H @@ -26,9 +27,79 @@ public: User::Ptr user; /** - * The member's status in the chat. Can be creator, administrator, member, left or kicked + * The member's status in the chat. Can be “creator”, “administrator”, “member”, “restricted”, “left” or “kicked” */ std::string status; + + /** + * Optional. Restricted and kicked only. Date when restrictions will be lifted for this user, unix time. + */ + uint64_t untilDate; + + /** + * Optional. Administrators only. True, if the bot is allowed to edit administrator privileges of that user. + */ + bool canBeEdited = false; + + /** + * Optional. Administrators only. True, if the administrator can change the chat title, photo and other settings. + */ + bool canChangeInfo = false; + + /** + * Optional. Administrators only. True, if the administrator can post in the channel, channels only. + */ + bool canPostMessages = false; + + /** + * Optional. Administrators only. True, if the administrator can edit messages of other users and can pin messages, channels only. + */ + bool canEditMessages = false; + + /** + * Optional. Administrators only. True, if the administrator can delete messages of other users. + */ + bool canDeleteMessages = false; + + /** + * Optional. Administrators only. True, if the administrator can invite new users to the chat. + */ + bool canInviteUsers = false; + + /** + * Optional. Administrators only. True, if the administrator can restrict, ban or unban chat members. + */ + bool canRestrictMembers = false; + + /** + * Optional. Administrators only. True, if the administrator can pin messages, supergroups only. + */ + bool canPinMessages = false; + + /** + * 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; + + /** + * Optional. Restricted only. True, if the user can send text messages, contacts, locations and venues. + */ + bool canSendMessages = false; + + /** + * 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; + + /** + * Optional. Restricted only. True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages. + */ + bool canSendOtherMessages = false; + + /** + * 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 new file mode 100644 index 0000000..9469d2e --- /dev/null +++ b/include/tgbot/types/ChatPhoto.h @@ -0,0 +1,52 @@ +/* + * 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_CHATPHOTO_H +#define TGBOT_CHATPHOTO_H + +#include +#include + +namespace TgBot { + +/** + * This object represents a chat photo. + * @ingroup types + */ +class ChatPhoto { +public: + typedef std::shared_ptr Ptr; + + /** + * Unique file identifier of small (160x160) chat photo. This file_id can be used only for photo download. + */ + std::string smallFileId; + + /** + * Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download. + */ + std::string bigFileId; +}; +} + +#endif //TGBOT_CHATPHOTO_H \ No newline at end of file -- cgit v1.2.3 From 8206df62f7f9540a2f13ce31c85f8a1f2054bd56 Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Sun, 27 May 2018 17:30:39 +0900 Subject: Fix build error (cross-reference) --- include/tgbot/types/Chat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/tgbot') diff --git a/include/tgbot/types/Chat.h b/include/tgbot/types/Chat.h index d286a63..c5c397f 100644 --- a/include/tgbot/types/Chat.h +++ b/include/tgbot/types/Chat.h @@ -27,10 +27,10 @@ #include #include "tgbot/types/ChatPhoto.h" -#include "tgbot/types/Message.h" namespace TgBot { +class Message; /** * This object represents a Telegram Chat * @ingroup types -- cgit v1.2.3 From c81f7d9d7a4fe9dc3b48b92fad633bd5c44b8e74 Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Sun, 27 May 2018 17:50:32 +0900 Subject: Bot API 3.3 update --- include/tgbot/types/Chat.h | 2 +- include/tgbot/types/Message.h | 12 +++++++++++- include/tgbot/types/User.h | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) (limited to 'include/tgbot') diff --git a/include/tgbot/types/Chat.h b/include/tgbot/types/Chat.h index c5c397f..978d2c4 100644 --- a/include/tgbot/types/Chat.h +++ b/include/tgbot/types/Chat.h @@ -108,7 +108,7 @@ public: * Optional. Pinned message, for supergroups and channel chats. * Returned only in getChat. */ - Message::Ptr pinnedMessage; + std::shared_ptr pinnedMessage; /** * Optional. For supergroups, name of group sticker set. diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h index ee293b9..b988c08 100644 --- a/include/tgbot/types/Message.h +++ b/include/tgbot/types/Message.h @@ -95,6 +95,11 @@ public: */ int32_t forwardFromMessageId; + /** + * Optional. For messages forwarded from channels, signature of the post author if present. + */ + std::string forwardSignature; + /** * Optional. For forwarded messages, date the original message was sent in Unix time. */ @@ -106,10 +111,15 @@ public: Message::Ptr replyToMessage; /** - * Optional. Date the message was last edited in Unix time + * Optional. Date the message was last edited in Unix time. */ int32_t editDate; + /** + * Optional. Signature of the post author for messages in channels. + */ + std::string authorSignature; + /** * Optional. For text messages, the actual UTF-8 text of the message. */ diff --git a/include/tgbot/types/User.h b/include/tgbot/types/User.h index f3a6960..7ee7da6 100644 --- a/include/tgbot/types/User.h +++ b/include/tgbot/types/User.h @@ -42,6 +42,11 @@ public: */ int32_t id; + /** + * True, if this user is a bot + */ + bool isBot = false; + /** * User‘s or bot’s first name. */ -- cgit v1.2.3 From 94f8360629909e93e82417085db8381791c95c7b Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Sun, 27 May 2018 22:12:56 +0900 Subject: Bot API 3.2 update --- include/tgbot/Api.h | 107 +++++++++++++++++++++++++++++++++---- include/tgbot/TgTypeParser.h | 9 +++- include/tgbot/types/MaskPosition.h | 62 +++++++++++++++++++++ include/tgbot/types/Sticker.h | 11 ++++ include/tgbot/types/StickerSet.h | 65 ++++++++++++++++++++++ 5 files changed, 242 insertions(+), 12 deletions(-) create mode 100644 include/tgbot/types/MaskPosition.h create mode 100644 include/tgbot/types/StickerSet.h (limited to 'include/tgbot') diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index 5750a83..dd1805d 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -39,6 +39,7 @@ #include "tgbot/types/Venue.h" #include "tgbot/types/WebhookInfo.h" #include "tgbot/types/ChatMember.h" +#include "tgbot/types/StickerSet.h" #include "tgbot/types/File.h" namespace TgBot { @@ -188,7 +189,7 @@ public: /** * Use this method to send .webp stickers. * @param chatId Unique identifier for the target chat. - * @param sticker Id of the sticker that is already on the Telegram servers. + * @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. @@ -197,6 +198,90 @@ public: Message::Ptr sendSticker(int64_t chatId, const std::string& stickerId, int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared(), bool disableNotification = false) const; + /** + * 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; + + /** + * 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; + + /** + * 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_”. 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; + + /** + * 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_”. 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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + /** * 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. @@ -210,7 +295,7 @@ public: * @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, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const std::string &caption = "", + Message::Ptr sendVideo(int64_t chatId, const InputFile::Ptr video, 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(), bool disableNotification = false) const; /** @@ -226,7 +311,7 @@ public: * @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, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const std::string &caption = "", + Message::Ptr sendVideo(int64_t chatId, const std::string& videoId, 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(), bool disableNotification = false) const; /** @@ -254,7 +339,7 @@ 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 std::string &videoNote, int64_t replyToMessageId = 0, bool disableNotification = false, + 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()); @@ -269,7 +354,7 @@ public: * @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, + 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(), bool disableNotification = false) const; /** @@ -283,7 +368,7 @@ public: * @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, + 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(), bool disableNotification = false) const; /** @@ -312,7 +397,7 @@ public: * @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, std::string title, std::string address, std::string foursquareId = "", + 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()) const; /** @@ -326,7 +411,7 @@ public: * @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, std::string phoneNumber, std::string firstName, std::string lastName = "", bool disableNotification = false, + 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()) const; /** @@ -557,7 +642,7 @@ public: * @param photo New chat photo. * @return True on success */ - bool setChatPhoto(int64_t chatId, InputFile::Ptr photo) const; + bool setChatPhoto(int64_t chatId, const InputFile::Ptr photo) const; /** * Use this method to delete a chat photo. @@ -574,7 +659,7 @@ public: * @param title New chat title, 1-255 characters. * @return True on success */ - bool setChatTitle(int64_t chatId, std::string title) const; + bool setChatTitle(int64_t chatId, const std::string& title) const; /** * Use this method to change the description of a supergroup or a channel. @@ -582,7 +667,7 @@ public: * @param description New chat description, 1-255 characters. * @return True on success */ - bool setChatDescription(int64_t chatId, std::string description) const; + bool setChatDescription(int64_t chatId, const std::string& description) const; /** * Use this method to pin a message in a supergroup or a channel. diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h index 0aea80b..b7121df 100644 --- a/include/tgbot/TgTypeParser.h +++ b/include/tgbot/TgTypeParser.h @@ -35,6 +35,8 @@ #include "tgbot/types/Audio.h" #include "tgbot/types/Document.h" #include "tgbot/types/Sticker.h" +#include "tgbot/types/StickerSet.h" +#include "tgbot/types/MaskPosition.h" #include "tgbot/types/Video.h" #include "tgbot/types/VideoNote.h" #include "tgbot/types/Contact.h" @@ -119,6 +121,10 @@ public: 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; @@ -150,7 +156,8 @@ public: 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; // returned only in getChat + 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; diff --git a/include/tgbot/types/MaskPosition.h b/include/tgbot/types/MaskPosition.h new file mode 100644 index 0000000..edd5d5e --- /dev/null +++ b/include/tgbot/types/MaskPosition.h @@ -0,0 +1,62 @@ +/* + * 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_MARKPOSITION_H +#define TGBOT_MARKPOSITION_H + +#include +#include + +namespace TgBot { + +/** + * This object describes the position on faces where a mask should be placed by default. + * @ingroup types + */ +class MaskPosition { +public: + typedef std::shared_ptr Ptr; + + /** + * The part of the face relative to which the mask should be placed. One of “forehead”, “eyes”, “mouth”, or “chin”. + */ + std::string point; + + /** + * 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; + + /** + * 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; + + /** + * Mask scaling coefficient. For example, 2.0 means double size. + */ + float scale; +}; +} + +#endif //TGBOT_MARKPOSITION_H \ No newline at end of file diff --git a/include/tgbot/types/Sticker.h b/include/tgbot/types/Sticker.h index 94140c1..b7c746b 100644 --- a/include/tgbot/types/Sticker.h +++ b/include/tgbot/types/Sticker.h @@ -27,6 +27,7 @@ #include #include "tgbot/types/PhotoSize.h" +#include "tgbot/types/MaskPosition.h" namespace TgBot { @@ -64,6 +65,16 @@ public: */ std::string emoji; + /** + * Optional. Name of the sticker set to which the sticker belongs. + */ + std::string setName; + + /** + * Optional. For mask stickers, the position where the mask should be placed. + */ + MaskPosition::Ptr maskPosition; + /** * Optional. File size. */ diff --git a/include/tgbot/types/StickerSet.h b/include/tgbot/types/StickerSet.h new file mode 100644 index 0000000..d36c6f1 --- /dev/null +++ b/include/tgbot/types/StickerSet.h @@ -0,0 +1,65 @@ +/* + * 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_STICKERSET_H +#define TGBOT_STICKERSET_H + +#include +#include +#include + +#include "tgbot/types/Sticker.h" + +namespace TgBot { + +/** + * This object represents a sticker set. + * @ingroup types + */ +class StickerSet { +public: + typedef std::shared_ptr Ptr; + + /** + * Sticker set name. + */ + std::string name; + + /** + * Sticker set title. + */ + std::string title; + + /** + * True, if the sticker set contains masks. + */ + bool containsMasks = false; + + /** + * List of all set stickers. + */ + std::vector stickers; +}; +} + +#endif //TGBOT_STICKERSET_H \ No newline at end of file -- cgit v1.2.3 From 6d365b8b555e7d1f6b32ba8b87bea8a593021cc2 Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Sun, 27 May 2018 22:23:14 +0900 Subject: Fix build error (no matching function) --- include/tgbot/Api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/tgbot') diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index dd1805d..7a82072 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -239,7 +239,7 @@ public: * @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; + const std::string& pngSticker, const std::string& emojis, bool containsMasks = false, MaskPosition::Ptr maskPosition = nullptr) const; /** * Use this method to add a new sticker to a set created by the bot. -- cgit v1.2.3 From b0134ff90ccd4203721fd8d32c1d1bacaea8b47f Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Mon, 28 May 2018 02:27:25 +0900 Subject: Bot API 3.4 update --- include/tgbot/Api.h | 46 +++++++++++++++++++++++++++++++++++++++++-- include/tgbot/types/Message.h | 5 +++++ 2 files changed, 49 insertions(+), 2 deletions(-) (limited to 'include/tgbot') diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index 7a82072..6e48207 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -376,13 +376,39 @@ public: * @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, int32_t replyToMessageId = 0, - const GenericReply::Ptr replyMarkup = std::make_shared(), bool disableNotification = false) const; + 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(), bool disableNotification = false) const; + + /** + * 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 (in the format @channelusername). + * @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()) const; + + /** + * 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 (in the format @channelusername). + * @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()) const; + /** * Use this method to send information about a venue. On success, the sent Message is returned. @@ -475,6 +501,22 @@ public: */ ChatMember::Ptr getChatMember(int64_t chatId, int32_t userId) const; + /** + * 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 or username of the target supergroup or channel (in the format @channelusername) + * @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; + + /** + * 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 or username of the target supergroup or channel (in the format @channelusername) + * @return Returns True on success. + */ + bool deleteChatStickerSet(int64_t chatId) const; + + /** * 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 diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h index b988c08..fbfbf15 100644 --- a/include/tgbot/types/Message.h +++ b/include/tgbot/types/Message.h @@ -130,6 +130,11 @@ public: */ std::vector entities; + /** + * Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption + */ + std::vector captionEntities; + /** * Optional. Message is an audio file, information about the file. */ -- cgit v1.2.3 From 981737b20b0db4914c667195b6584d14e9473e3d Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Mon, 28 May 2018 03:45:31 +0900 Subject: Bot API 3.5 update --- include/tgbot/Api.h | 34 +++++++----- include/tgbot/TgTypeParser.h | 5 ++ include/tgbot/types/InputMedia.h | 88 +++++++++++++++++++++++++++++++ include/tgbot/types/InputMediaPhoto.h | 49 +++++++++++++++++ include/tgbot/types/InputMediaVideo.h | 49 +++++++++++++++++ include/tgbot/types/InputMessageContent.h | 1 + 6 files changed, 214 insertions(+), 12 deletions(-) create mode 100644 include/tgbot/types/InputMedia.h create mode 100644 include/tgbot/types/InputMediaPhoto.h create mode 100644 include/tgbot/types/InputMediaVideo.h (limited to 'include/tgbot') diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index 6e48207..6d03000 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -342,6 +342,16 @@ public: 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()); + /** + * 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 sendMediaGroup(int64_t chatId, const std::vector& media, + bool disableNotification = false, int32_t replyToMessageId = 0) const; /** * Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. @@ -389,7 +399,7 @@ public: * 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 (in the format @channelusername). + * @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. @@ -400,7 +410,7 @@ public: /** * 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 (in the format @channelusername). + * @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. @@ -467,35 +477,35 @@ public: /** * Use this method for your bot to leave a group, supergroup or channel. - * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) + * @param chatId Unique identifier for the target chat of the target supergroup or channel. * @return True on success */ bool leaveChat(int64_t chatId) const; /** * 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 or username of the target supergroup or channel (in the format @channelusername) + * @param chatId Unique identifier for the target chat of the target supergroup or channel. * @return Chat object. */ Chat::Ptr getChat(int64_t chatId) const; /** * 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 or username of the target supergroup or channel (in the format @channelusername) + * @param chatId Unique identifier for the target chat of the target supergroup or channel. * @return ChatMember object. */ std::vector getChatAdministrators(int64_t chatId) const; /** * Use this method to get the number of members in a chat. Returns Int on success. - * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) + * @param chatId Unique identifier for the target chat of the target supergroup or channel. * @return Int. */ int32_t getChatMembersCount(int64_t chatId) const; /** * 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 or username of the target supergroup or channel (in the format @channelusername) + * @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. */ @@ -503,7 +513,7 @@ public: /** * 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 or username of the target supergroup or channel (in the format @channelusername) + * @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. */ @@ -511,7 +521,7 @@ public: /** * 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 or username of the target supergroup or channel (in the format @channelusername) + * @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; @@ -531,7 +541,7 @@ public: /** * 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 or username of the target channel (in the format @channelusername) + * @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. @@ -544,7 +554,7 @@ public: /** * 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 or username of the target channel (in the format @channelusername) + * @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 @@ -556,7 +566,7 @@ public: /** * 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 or username of the target channel (in the format @channelusername) + * @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. diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h index b7121df..b5e51ed 100644 --- a/include/tgbot/TgTypeParser.h +++ b/include/tgbot/TgTypeParser.h @@ -92,6 +92,9 @@ #include "tgbot/types/ShippingOption.h" #include "tgbot/types/SuccessfulPayment.h" #include "tgbot/types/LabeledPrice.h" +#include "tgbot/types/InputMedia.h" +#include "tgbot/types/InputMediaPhoto.h" +#include "tgbot/types/InputMediaVideo.h" namespace TgBot { @@ -137,6 +140,8 @@ public: 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; diff --git a/include/tgbot/types/InputMedia.h b/include/tgbot/types/InputMedia.h new file mode 100644 index 0000000..d7c3ace --- /dev/null +++ b/include/tgbot/types/InputMedia.h @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2015 Oleg Morozenkov + * Copyright (c) 2016 Konstantin Kukin + * 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_INPUTMEDIA_H +#define TGBOT_INPUTMEDIA_H + +#include +#include + +namespace TgBot { + +/** +* This object represents the content of a media message to be sent. +* @ingroup types +*/ +class InputMedia { +public: + typedef std::shared_ptr Ptr; + + enum class TYPE : uint8_t { + PHOTO, + VIDEO + }; + + /** + * Type of the result, It should be one of TYPE::PHOTO/TYPE::VIDEO + */ + TYPE type; + + /** + * File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. + */ + std::string media; + + /** + * Optional. Caption of the photo to be sent, 0-200 characters + */ + std::string caption; + + /** + * Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + */ + std::string parseMode; + + /** + * Optional. Video width + */ + int32_t width = 0; + + /** + * Optional. Video height + */ + int32_t height = 0; + + /** + * Optional. Video duration + */ + int32_t duration = 0; + + /** + * Optional. Pass True, if the uploaded video is suitable for streaming + */ + bool supportsStreaming = false; +}; +} + +#endif //TGBOT_INPUTMEDIA_H diff --git a/include/tgbot/types/InputMediaPhoto.h b/include/tgbot/types/InputMediaPhoto.h new file mode 100644 index 0000000..6d8af86 --- /dev/null +++ b/include/tgbot/types/InputMediaPhoto.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015 Oleg Morozenkov + * Copyright (c) 2016 Konstantin Kukin + * 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_INPUTMEDIAPHOTO_H +#define TGBOT_INPUTMEDIAPHOTO_H + +#include +#include + +#include "tgbot/types/InputMedia.h" + +namespace TgBot { + +/** +* Represents a photo to be sent. +* @ingroup types +*/ +class InputMediaPhoto : public InputMedia { +public: + typedef std::shared_ptr Ptr; + + InputMediaPhoto() { + this->type = TYPE::PHOTO; + } +}; +} + +#endif //TGBOT_INPUTMEDIAPHOTO_H diff --git a/include/tgbot/types/InputMediaVideo.h b/include/tgbot/types/InputMediaVideo.h new file mode 100644 index 0000000..a49c80a --- /dev/null +++ b/include/tgbot/types/InputMediaVideo.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015 Oleg Morozenkov + * Copyright (c) 2016 Konstantin Kukin + * 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_INPUTMEDIAVIDEO_H +#define TGBOT_INPUTMEDIAVIDEO_H + +#include +#include + +#include "tgbot/types/InputMedia.h" + +namespace TgBot { + +/** +* Represents a video to be sent. +* @ingroup types +*/ +class InputMediaVideo : public InputMedia { +public: + typedef std::shared_ptr Ptr; + + InputMediaVideo() { + this->type = TYPE::VIDEO; + } +}; +} + +#endif //TGBOT_INPUTMEDIAVIDEO_H diff --git a/include/tgbot/types/InputMessageContent.h b/include/tgbot/types/InputMessageContent.h index 587dcf8..1abdec6 100644 --- a/include/tgbot/types/InputMessageContent.h +++ b/include/tgbot/types/InputMessageContent.h @@ -6,6 +6,7 @@ #define TGBOT_INPUTMESSAGECONTENT_H #include +#include namespace TgBot { -- cgit v1.2.3 From fd2a6ae6f5a101855bf2b7983472e3475278c608 Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Mon, 28 May 2018 03:50:19 +0900 Subject: Fix build error (could not convert) --- include/tgbot/Api.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/tgbot') diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index 6d03000..685f19e 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -41,6 +41,7 @@ #include "tgbot/types/ChatMember.h" #include "tgbot/types/StickerSet.h" #include "tgbot/types/File.h" +#include "tgbot/types/InputMedia.h" namespace TgBot { -- cgit v1.2.3