summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tgbot/Api.h295
-rw-r--r--include/tgbot/TgTypeParser.h50
-rw-r--r--include/tgbot/tgbot.h1
-rw-r--r--include/tgbot/types/Chat.h41
-rw-r--r--include/tgbot/types/ChatMember.h73
-rw-r--r--include/tgbot/types/ChatPhoto.h52
-rw-r--r--include/tgbot/types/InlineQueryResultGif.h5
-rw-r--r--include/tgbot/types/InlineQueryResultMpeg4Gif.h5
-rw-r--r--include/tgbot/types/InputMedia.h88
-rw-r--r--include/tgbot/types/InputMediaPhoto.h49
-rw-r--r--include/tgbot/types/InputMediaVideo.h49
-rw-r--r--include/tgbot/types/InputMessageContent.h1
-rw-r--r--include/tgbot/types/Invoice.h78
-rw-r--r--include/tgbot/types/LabeledPrice.h42
-rw-r--r--include/tgbot/types/MaskPosition.h62
-rw-r--r--include/tgbot/types/Message.h22
-rw-r--r--include/tgbot/types/OrderInfo.h66
-rw-r--r--include/tgbot/types/PreCheckoutQuery.h91
-rw-r--r--include/tgbot/types/ShippingAddress.h75
-rw-r--r--include/tgbot/types/ShippingOption.h43
-rw-r--r--include/tgbot/types/ShippingQuery.h68
-rw-r--r--include/tgbot/types/Sticker.h11
-rw-r--r--include/tgbot/types/StickerSet.h65
-rw-r--r--include/tgbot/types/SuccessfulPayment.h90
-rw-r--r--include/tgbot/types/User.h10
-rw-r--r--include/tgbot/types/VideoNote.h70
-rw-r--r--src/Api.cpp344
-rw-r--r--src/EventHandler.cpp6
-rw-r--r--src/TgTypeParser.cpp398
29 files changed, 2188 insertions, 62 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index 4eb63c7..685f19e 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -39,7 +39,9 @@
#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"
+#include "tgbot/types/InputMedia.h"
namespace TgBot {
@@ -188,7 +190,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.
@@ -198,6 +200,90 @@ public:
const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), 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_<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;
+
+ /**
+ * 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;
+
+ /**
+ * 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.
* @param video Video to send.
@@ -210,7 +296,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<GenericReply>(), bool disableNotification = false) const;
/**
@@ -226,10 +312,49 @@ 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<GenericReply>(), 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 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;
+
+ /**
* 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.
@@ -240,7 +365,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<GenericReply>(), bool disableNotification = false) const;
/**
@@ -254,7 +379,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<GenericReply>(), bool disableNotification = false) const;
/**
@@ -262,13 +387,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<GenericReply>(), 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<GenericReply>(), 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.
+ * @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;
+
+ /**
+ * 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;
+
/**
* Use this method to send information about a venue. On success, the sent Message is returned.
@@ -283,7 +434,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<GenericReply>()) const;
/**
@@ -297,7 +448,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<GenericReply>()) const;
/**
@@ -327,41 +478,57 @@ 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<ChatMember::Ptr> 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.
*/
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 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;
+
+ /**
+ * 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;
+
+
+ /**
* 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
@@ -375,7 +542,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.
@@ -388,7 +555,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
@@ -400,7 +567,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.
@@ -464,15 +631,16 @@ public:
* @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;
+ 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.
@@ -483,6 +651,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, const 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, const 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, const 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.
* @param args Additional api parameters.
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index 2faaf45..b5e51ed 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -35,7 +35,10 @@
#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"
#include "tgbot/types/Location.h"
#include "tgbot/types/Update.h"
@@ -46,6 +49,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"
@@ -80,6 +84,17 @@
#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"
+#include "tgbot/types/InputMedia.h"
+#include "tgbot/types/InputMediaPhoto.h"
+#include "tgbot/types/InputMediaVideo.h"
namespace TgBot {
@@ -109,8 +124,14 @@ 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;
+ 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;
@@ -119,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;
@@ -138,6 +161,9 @@ 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;
+ 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;
@@ -234,6 +260,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/Chat.h b/include/tgbot/types/Chat.h
index 698b95f..978d2c4 100644
--- a/include/tgbot/types/Chat.h
+++ b/include/tgbot/types/Chat.h
@@ -26,8 +26,11 @@
#include <string>
#include <memory>
+#include "tgbot/types/ChatPhoto.h"
+
namespace TgBot {
+class Message;
/**
* This object represents a Telegram Chat
* @ingroup types
@@ -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.
+ */
+ std::shared_ptr<Message> 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 <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * This object represents a chat photo.
+ * @ingroup types
+ */
+class ChatPhoto {
+public:
+ typedef std::shared_ptr<ChatPhoto> 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
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
@@ -44,6 +44,11 @@ public:
int32_t gifHeight;
/**
+ * Optional. Duration of the GIF
+ */
+ int32_t gifDuration;
+
+ /**
* URL of the static thumbnail for the result (jpeg or gif)
*/
std::string thumbUrl;
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
@@ -39,6 +39,11 @@ public:
int32_t mpeg4Height;
/**
+ * Optional. Video duration.
+ */
+ int32_t mpeg4Duration;
+
+ /**
* URL of the static thumbnail (jpeg or gif) for the result
*/
std::string thumbUrl;
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 <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+* This object represents the content of a media message to be sent.
+* @ingroup types
+*/
+class InputMedia {
+public:
+ typedef std::shared_ptr<InputMedia> 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://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> 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 <memory>
+#include <string>
+
+#include "tgbot/types/InputMedia.h"
+
+namespace TgBot {
+
+/**
+* Represents a photo to be sent.
+* @ingroup types
+*/
+class InputMediaPhoto : public InputMedia {
+public:
+ typedef std::shared_ptr<InputMediaPhoto> 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 <memory>
+#include <string>
+
+#include "tgbot/types/InputMedia.h"
+
+namespace TgBot {
+
+/**
+* Represents a video to be sent.
+* @ingroup types
+*/
+class InputMediaVideo : public InputMedia {
+public:
+ typedef std::shared_ptr<InputMediaVideo> 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 <memory>
+#include <string>
namespace TgBot {
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 <string>
+#include <memory>
+
+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<Invoice> 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 <string>
+#include <memory>
+
+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<LabeledPrice> 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/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 <memory>
+#include <string>
+
+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<MaskPosition> 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/Message.h b/include/tgbot/types/Message.h
index 415f616..fbfbf15 100644
--- a/include/tgbot/types/Message.h
+++ b/include/tgbot/types/Message.h
@@ -96,6 +96,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.
*/
int32_t forwardDate;
@@ -106,11 +111,16 @@ 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.
*/
std::string text;
@@ -121,6 +131,11 @@ public:
std::vector<MessageEntity::Ptr> entities;
/**
+ * Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption
+ */
+ std::vector<MessageEntity::Ptr> captionEntities;
+
+ /**
* Optional. Message is an audio file, information about the file.
*/
Audio::Ptr audio;
@@ -176,6 +191,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<User::Ptr> newChatMembers;
+
+ /**
* Optional. A member was removed from the group, information about them (this member may be bot itself).
*/
User::Ptr leftChatMember;
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 <string>
+#include <memory>
+#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<OrderInfo> 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 <string>
+#include <memory>
+#include <vector>
+#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<PreCheckoutQuery> 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 <string>
+#include <memory>
+
+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<ShippingAddress> 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 <string>
+#include <memory>
+#include <vector>
+#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<ShippingOption> Ptr;
+
+ /**
+ * @brief Shipping option identifier.
+ */
+ std::string id;
+
+ /**
+ * @brief Option title.
+ */
+ std::string title;
+
+ /**
+ * @brief List of price options.
+ */
+ std::vector<LabeledPrice::Ptr> 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 <string>
+#include <memory>
+#include <vector>
+#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<ShippingQuery> 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/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 <memory>
#include "tgbot/types/PhotoSize.h"
+#include "tgbot/types/MaskPosition.h"
namespace TgBot {
@@ -65,6 +66,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.
*/
int32_t fileSize;
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 <memory>
+#include <string>
+#include <vector>
+
+#include "tgbot/types/Sticker.h"
+
+namespace TgBot {
+
+/**
+ * This object represents a sticker set.
+ * @ingroup types
+ */
+class StickerSet {
+public:
+ typedef std::shared_ptr<StickerSet> 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<Sticker::Ptr> stickers;
+};
+}
+
+#endif //TGBOT_STICKERSET_H \ No newline at end of file
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 <string>
+#include <memory>
+#include <vector>
+#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<SuccessfulPayment> 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..7ee7da6 100644
--- a/include/tgbot/types/User.h
+++ b/include/tgbot/types/User.h
@@ -43,6 +43,11 @@ public:
int32_t id;
/**
+ * True, if this user is a bot
+ */
+ bool isBot = false;
+
+ /**
* User‘s or bot’s first name.
*/
std::string firstName;
@@ -56,6 +61,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 <string>
+#include <memory>
+
+#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<VideoNote> 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
diff --git a/src/Api.cpp b/src/Api.cpp
index 31e08f3..ca2f969 100644
--- a/src/Api.cpp
+++ b/src/Api.cpp
@@ -109,7 +109,7 @@ Message::Ptr Api::sendPhoto(int64_t chatId, const string& photoId, const string&
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendPhoto", args));
}
-Message::Ptr Api::sendAudio(int64_t chatId, const InputFile::Ptr audio, const std::string &caption, int32_t duration, const string& performer, const string& title, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendAudio(int64_t chatId, const InputFile::Ptr audio, const string &caption, int32_t duration, const string& performer, const string& title, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("audio", audio->data, true, audio->mimeType, audio->fileName));
@@ -137,7 +137,7 @@ Message::Ptr Api::sendAudio(int64_t chatId, const InputFile::Ptr audio, const st
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendAudio", args));
}
-Message::Ptr Api::sendAudio(int64_t chatId, const string& audioId, const std::string &caption, int32_t duration, const string& performer, const string& title, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendAudio(int64_t chatId, const string& audioId, const string &caption, int32_t duration, const string& performer, const string& title, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("audio", audioId));
@@ -165,7 +165,7 @@ Message::Ptr Api::sendAudio(int64_t chatId, const string& audioId, const std::st
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendAudio", args));
}
-Message::Ptr Api::sendDocument(int64_t chatId, const InputFile::Ptr document, const std::string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendDocument(int64_t chatId, const InputFile::Ptr document, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("document", document->data, true, document->mimeType, document->fileName));
@@ -184,7 +184,7 @@ Message::Ptr Api::sendDocument(int64_t chatId, const InputFile::Ptr document, co
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendDocument", args));
}
-Message::Ptr Api::sendDocument(int64_t chatId, const string& document, const std::string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendDocument(int64_t chatId, const string& document, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("document", document));
@@ -235,7 +235,79 @@ Message::Ptr Api::sendSticker(int64_t chatId, const string& stickerId, int32_t r
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendSticker", args));
}
-Message::Ptr Api::sendVideo(int64_t chatId, const InputFile::Ptr video, int32_t duration, int32_t width, int32_t height, const std::string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+StickerSet::Ptr Api::getStickerSet(const string& name) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("name", name));
+ return TgTypeParser::getInstance().parseJsonAndGetStickerSet(sendRequest("getStickerSet", args));
+}
+
+File::Ptr Api::uploadStickerFile(int32_t userId, const InputFile::Ptr pngSticker) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("user_id", userId));
+ args.push_back(HttpReqArg("png_sticker", pngSticker->data, true, pngSticker->mimeType, pngSticker->fileName));
+ return TgTypeParser::getInstance().parseJsonAndGetFile(sendRequest("uploadStickerFile", args));
+}
+
+bool Api::createNewStickerSet(int32_t userId, const string& name, const string& title, InputFile::Ptr pngSticker, const string& emojis, bool containsMasks, MaskPosition::Ptr maskPosition) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("user_id", userId));
+ args.push_back(HttpReqArg("name", name));
+ args.push_back(HttpReqArg("title", title));
+ args.push_back(HttpReqArg("png_sticker", pngSticker->data, true, pngSticker->mimeType, pngSticker->fileName));
+ args.push_back(HttpReqArg("emojis", emojis));
+ args.push_back(HttpReqArg("contains_mask", containsMasks));
+ args.push_back(HttpReqArg("mask_position", TgTypeParser::getInstance().parseMaskPosition(maskPosition)));
+ return sendRequest("createNewStickerSet", args).get<bool>("", false);
+}
+
+bool Api::createNewStickerSet(int32_t userId, const string& name, const string& title, const string& pngSticker, const string& emojis, bool containsMasks, MaskPosition::Ptr maskPosition) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("user_id", userId));
+ args.push_back(HttpReqArg("name", name));
+ args.push_back(HttpReqArg("title", title));
+ args.push_back(HttpReqArg("png_sticker", pngSticker));
+ args.push_back(HttpReqArg("emojis", emojis));
+ args.push_back(HttpReqArg("contains_mask", containsMasks));
+ args.push_back(HttpReqArg("mask_position", TgTypeParser::getInstance().parseMaskPosition(maskPosition)));
+ return sendRequest("createNewStickerSet", args).get<bool>("", false);
+}
+
+bool Api::addStickerToSet(int32_t userId, const string& name, const string& title, InputFile::Ptr pngSticker, const string& emojis, MaskPosition::Ptr maskPosition) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("user_id", userId));
+ args.push_back(HttpReqArg("name", name));
+ args.push_back(HttpReqArg("title", title));
+ args.push_back(HttpReqArg("png_sticker", pngSticker->data, true, pngSticker->mimeType, pngSticker->fileName));
+ args.push_back(HttpReqArg("emojis", emojis));
+ args.push_back(HttpReqArg("mask_position", TgTypeParser::getInstance().parseMaskPosition(maskPosition)));
+ return sendRequest("addStickerToSet", args).get<bool>("", false);
+}
+
+bool Api::addStickerToSet(int32_t userId, const string& name, const string& title, const string& pngSticker, const string& emojis, MaskPosition::Ptr maskPosition) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("user_id", userId));
+ args.push_back(HttpReqArg("name", name));
+ args.push_back(HttpReqArg("title", title));
+ args.push_back(HttpReqArg("png_sticker", pngSticker));
+ args.push_back(HttpReqArg("emojis", emojis));
+ args.push_back(HttpReqArg("mask_position", TgTypeParser::getInstance().parseMaskPosition(maskPosition)));
+ return sendRequest("addStickerToSet", args).get<bool>("", false);
+}
+
+bool Api::setStickerPositionInSet(const string& sticker, uint32_t position) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("sticker", sticker));
+ args.push_back(HttpReqArg("position", position));
+ return sendRequest("setStickerPositionInSet", args).get<bool>("", false);
+}
+
+bool Api::deleteStickerPositionInSet(const string& sticker) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("sticker", sticker));
+ return sendRequest("setStickerPositionInSet", args).get<bool>("", false);
+}
+
+Message::Ptr Api::sendVideo(int64_t chatId, const InputFile::Ptr video, int32_t duration, int32_t width, int32_t height, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("video", video->data, true, video->mimeType, video->fileName));
@@ -263,7 +335,7 @@ Message::Ptr Api::sendVideo(int64_t chatId, const InputFile::Ptr video, int32_t
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendVideo", args));
}
-Message::Ptr Api::sendVideo(int64_t chatId, const string& videoId, int32_t duration, int32_t width, int32_t height, const std::string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendVideo(int64_t chatId, const string& videoId, int32_t duration, int32_t width, int32_t height, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("video", videoId));
@@ -291,7 +363,61 @@ Message::Ptr Api::sendVideo(int64_t chatId, const string& videoId, int32_t durat
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendVideo", args));
}
-Message::Ptr Api::sendVoice(int64_t chatId, const InputFile::Ptr voice, const std::string &caption, int duration, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendVideoNote(int64_t chatId, const InputFile::Ptr videoNote, int64_t replyToMessageId, bool disableNotification, int32_t duration, int32_t length, const GenericReply::Ptr replyMarkup) {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ args.push_back(HttpReqArg("video_note", videoNote));
+ if (disableNotification) {
+ args.push_back(HttpReqArg("disable_notification", disableNotification));
+ }
+ if (duration) {
+ args.push_back(HttpReqArg("duration", duration));
+ }
+ if (length) {
+ args.push_back(HttpReqArg("length", length));
+ }
+ if (replyMarkup) {
+ args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseGenericReply(replyMarkup)));
+ }
+ if (replyToMessageId) {
+ args.push_back(HttpReqArg("reply_to_message_id", replyToMessageId));
+ }
+ return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendVoiceNote", args));
+}
+
+Message::Ptr Api::sendVideoNote(int64_t chatId, const string &videoNote, int64_t replyToMessageId, bool disableNotification, int32_t duration, int32_t length, const GenericReply::Ptr replyMarkup) {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ args.push_back(HttpReqArg("video_note", videoNote));
+ if (disableNotification) {
+ args.push_back(HttpReqArg("disable_notification", disableNotification));
+ }
+ if (duration) {
+ args.push_back(HttpReqArg("duration", duration));
+ }
+ if (length) {
+ args.push_back(HttpReqArg("length", length));
+ }
+ if (replyMarkup) {
+ args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseGenericReply(replyMarkup)));
+ }
+ if (replyToMessageId) {
+ args.push_back(HttpReqArg("reply_to_message_id", replyToMessageId));
+ }
+ return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendVoiceNote", args));
+}
+
+vector<Message::Ptr> Api::sendMediaGroup(int64_t chatId, const vector<InputMedia::Ptr>& media, bool disableNotification, int32_t replyToMessageId) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ string mediaJson = TgTypeParser::getInstance().parseArray<InputMedia>(&TgTypeParser::parseInputMedia, media);
+ args.push_back(HttpReqArg("media", mediaJson));
+ args.push_back(HttpReqArg("disable_notification", disableNotification));
+ args.push_back(HttpReqArg("reply_to_message_id", replyToMessageId));
+ return TgTypeParser::getInstance().parseJsonAndGetArray<Message>(&TgTypeParser::parseJsonAndGetMessage, sendRequest("sendMediaGroup", args));
+}
+
+Message::Ptr Api::sendVoice(int64_t chatId, const InputFile::Ptr voice, const string &caption, int duration, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("voice", voice->data, true, voice->mimeType, voice->fileName));
@@ -313,7 +439,7 @@ Message::Ptr Api::sendVoice(int64_t chatId, const InputFile::Ptr voice, const st
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendVoice", args));
}
-Message::Ptr Api::sendVoice(int64_t chatId, const std::string& voiceId, const std::string &caption, int duration, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendVoice(int64_t chatId, const string& voiceId, const string &caption, int duration, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("voice", voiceId));
@@ -335,11 +461,14 @@ Message::Ptr Api::sendVoice(int64_t chatId, const std::string& voiceId, const st
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendVoice", args));
}
-Message::Ptr Api::sendLocation(int64_t chatId, float latitude, float longitude, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendLocation(int64_t chatId, float latitude, float longitude, uint32_t livePeriod, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("latitude", latitude));
args.push_back(HttpReqArg("longitude", longitude));
+ if (livePeriod) {
+ args.push_back(HttpReqArg("live_period", livePeriod));
+ }
if (replyToMessageId) {
args.push_back(HttpReqArg("reply_to_message_id", replyToMessageId));
}
@@ -352,7 +481,56 @@ Message::Ptr Api::sendLocation(int64_t chatId, float latitude, float longitude,
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendLocation", args));
}
-Message::Ptr Api::sendVenue(int64_t chatId, float latitude, float longitude, std::string title, std::string address, std::string foursquareId, bool disableNotification, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const {
+Message::Ptr Api::editMessageLiveLocation(float latitude, float longitude, int64_t chatId, int32_t messageId, int32_t inlineMessageId, const InlineKeyboardMarkup::Ptr replyMarkup) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("latitude", latitude));
+ args.push_back(HttpReqArg("longitude", longitude));
+ if (chatId) {
+ args.push_back(HttpReqArg("chat_id", chatId));
+ }
+ if (messageId) {
+ args.push_back(HttpReqArg("message_id", messageId));
+ }
+ if (inlineMessageId) {
+ args.push_back(HttpReqArg("inline_message_id", inlineMessageId));
+ }
+ if (replyMarkup) {
+ args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseInlineKeyboardMarkup(replyMarkup)));
+ }
+ return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("editMessageLiveLocation", args));
+}
+
+Message::Ptr Api::stopMessageLiveLocation(int64_t chatId, int32_t messageId, int32_t inlineMessageId, const InlineKeyboardMarkup::Ptr replyMarkup) const {
+ vector<HttpReqArg> args;
+ if (chatId) {
+ args.push_back(HttpReqArg("chat_id", chatId));
+ }
+ if (messageId) {
+ args.push_back(HttpReqArg("message_id", messageId));
+ }
+ if (inlineMessageId) {
+ args.push_back(HttpReqArg("inline_message_id", inlineMessageId));
+ }
+ if (replyMarkup) {
+ args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseInlineKeyboardMarkup(replyMarkup)));
+ }
+ return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("editMessageLiveLocation", args));
+}
+
+bool Api::setChatStickerSet(int64_t chatId, const string& stickerSetName) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ args.push_back(HttpReqArg("sticker_set_name ", stickerSetName));
+ return sendRequest("setChatStickerSet", args).get<bool>("", false);
+}
+
+bool Api::deleteChatStickerSet(int64_t chatId) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ return sendRequest("deleteChatStickerSet", args).get<bool>("", false);
+}
+
+Message::Ptr Api::sendVenue(int64_t chatId, float latitude, float longitude, const string& title, const string& address, const string& foursquareId, bool disableNotification, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("latitude", latitude));
@@ -374,7 +552,7 @@ Message::Ptr Api::sendVenue(int64_t chatId, float latitude, float longitude, std
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendVenue", args));
}
-Message::Ptr Api::sendContact(int64_t chatId, std::string phoneNumber, std::string firstName, std::string lastName, bool disableNotification, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const {
+Message::Ptr Api::sendContact(int64_t chatId, const string& phoneNumber, const string& firstName, const string& lastName, bool disableNotification, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("phone_number", phoneNumber));
@@ -410,7 +588,7 @@ UserProfilePhotos::Ptr Api::getUserProfilePhotos(int32_t userId, int32_t offset,
return TgTypeParser::getInstance().parseJsonAndGetUserProfilePhotos(sendRequest("getUserProfilePhotos", args));
}
-File::Ptr Api::getFile(const std::string &fileId) const
+File::Ptr Api::getFile(const string &fileId) const
{
vector<HttpReqArg> args;
args.push_back(HttpReqArg("file_id", fileId));
@@ -431,7 +609,7 @@ Chat::Ptr Api::getChat(int64_t chatId) const
return TgTypeParser::getInstance().parseJsonAndGetChat(sendRequest("getChat", args));
}
-std::vector<ChatMember::Ptr> Api::getChatAdministrators(int64_t chatId) const
+vector<ChatMember::Ptr> Api::getChatAdministrators(int64_t chatId) const
{
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
@@ -445,7 +623,7 @@ int32_t Api::getChatMembersCount(int64_t chatId) const
return sendRequest("getChatMembersCount", args).get<int32_t>("", 0);
}
-bool Api::answerCallbackQuery(const std::string & callbackQueryId, const std::string & text, bool showAlert, const std::string &url, int32_t cacheTime) const
+bool Api::answerCallbackQuery(const string & callbackQueryId, const string & text, bool showAlert, const string &url, int32_t cacheTime) const
{
vector<HttpReqArg> args;
args.push_back(HttpReqArg("callback_query_id", callbackQueryId));
@@ -464,8 +642,8 @@ bool Api::answerCallbackQuery(const std::string & callbackQueryId, const std::st
return sendRequest("answerCallbackQuery", args).get<bool>("", false);
}
-Message::Ptr Api::editMessageText(const std::string& text, int64_t chatId, int32_t messageId, const std::string& inlineMessageId,
- const std::string& parseMode, bool disableWebPagePreview, const GenericReply::Ptr replyMarkup) const {
+Message::Ptr Api::editMessageText(const string& text, int64_t chatId, int32_t messageId, const string& inlineMessageId,
+ const string& parseMode, bool disableWebPagePreview, const GenericReply::Ptr replyMarkup) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("text", text));
@@ -495,8 +673,8 @@ Message::Ptr Api::editMessageText(const std::string& text, int64_t chatId, int32
}
}
-Message::Ptr Api::editMessageCaption(int64_t chatId, int32_t messageId, const std::string& caption,
- const std::string& inlineMessageId, const GenericReply::Ptr replyMarkup) const {
+Message::Ptr Api::editMessageCaption(int64_t chatId, int32_t messageId, const string& caption,
+ const string& inlineMessageId, const GenericReply::Ptr replyMarkup) const {
vector<HttpReqArg> args;
if (chatId) {
@@ -523,7 +701,7 @@ Message::Ptr Api::editMessageCaption(int64_t chatId, int32_t messageId, const st
}
-Message::Ptr Api::editMessageReplyMarkup(int64_t chatId, int32_t messageId, const std::string& inlineMessageId,
+Message::Ptr Api::editMessageReplyMarkup(int64_t chatId, int32_t messageId, const string& inlineMessageId,
const GenericReply::Ptr replyMarkup) const {
vector<HttpReqArg> args;
@@ -565,9 +743,9 @@ vector<Update::Ptr> Api::getUpdates(int32_t offset, int32_t limit, int32_t timeo
if (timeout) {
args.push_back(HttpReqArg("timeout", timeout));
}
- if (allowedUpdates!=nullptr) {
- string allowedUpdatesJson = TgTypeParser::getInstance().parseArray<std::string>(
- [](const std::string &s)->std::string {
+ if (allowedUpdates != nullptr) {
+ string allowedUpdatesJson = TgTypeParser::getInstance().parseArray<string>(
+ [](const string &s)->string {
return s;
}, *allowedUpdates);
args.push_back(HttpReqArg("allowed_updates", allowedUpdatesJson));
@@ -581,13 +759,13 @@ void Api::setWebhook(const string& url, const InputFile::Ptr certificate, int32_
args.push_back(HttpReqArg("url", url));
if (certificate != nullptr)
args.push_back(HttpReqArg("certificate", certificate->data, true, certificate->mimeType, certificate->fileName));
- if (maxConnection!=40)
+ if (maxConnection != 40)
args.push_back(HttpReqArg("max_connections", maxConnection));
- if (allowedUpdates!=nullptr)
+ if (allowedUpdates != nullptr)
{
- string allowedUpdatesJson = TgTypeParser::getInstance().parseArray<std::string>(
- [](const std::string &s)->std::string {
+ string allowedUpdatesJson = TgTypeParser::getInstance().parseArray<string>(
+ [](const string &s)->string {
return s;
}, *allowedUpdates);
args.push_back(HttpReqArg("allowed_updates", allowedUpdatesJson));
@@ -609,7 +787,7 @@ WebhookInfo::Ptr Api::getWebhookInfo() const
if (!p.get_child_optional("url"))
return nullptr;
- if (p.get<string>("url","")!=string(""))
+ if (p.get<string>("url","") != string(""))
{
return TgTypeParser::getInstance().parseJsonAndGetWebhookInfo(p);
}
@@ -619,8 +797,8 @@ WebhookInfo::Ptr Api::getWebhookInfo() const
}
}
-bool Api::answerInlineQuery(const std::string& inlineQueryId, const std::vector<InlineQueryResult::Ptr>& results,
- int32_t cacheTime, bool isPersonal, const std::string& nextOffset, const std::string& switchPmText, const std::string& switchPmParameter) const {
+bool Api::answerInlineQuery(const string& inlineQueryId, const std::vector<InlineQueryResult::Ptr>& results,
+ int32_t cacheTime, bool isPersonal, const string& nextOffset, const string& switchPmText, const string& switchPmParameter) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("inline_query_id", inlineQueryId));
string resultsJson = TgTypeParser::getInstance().parseArray<InlineQueryResult>(&TgTypeParser::parseInlineQueryResult, results);
@@ -643,10 +821,13 @@ bool Api::answerInlineQuery(const std::string& inlineQueryId, const std::vector<
return sendRequest("answerInlineQuery", args).get<bool>("", false);
}
-bool Api::kickChatMember(int64_t chatId, int32_t userId) const {
+bool Api::kickChatMember(int64_t chatId, int32_t userId, uint64_t untilDate) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("user_id", userId));
+ if (untilDate) {
+ args.push_back(HttpReqArg("until_date", untilDate));
+ }
return sendRequest("kickChatMember", args).get<bool>("", false);
}
@@ -657,6 +838,107 @@ bool Api::unbanChatMember(int64_t chatId, int32_t userId) const {
return sendRequest("unbanChatMember", args).get<bool>("", false);
}
+bool Api::restrictChatMember(int64_t chatId, int32_t userId, uint64_t untilDate, bool canSendMessages,
+ bool canSendMediaMessages, bool canSendOtherMessages, bool canAddWebPagePreviews) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ args.push_back(HttpReqArg("user_id", userId));
+ if (untilDate) {
+ args.push_back(HttpReqArg("until_date", untilDate));
+ }
+ if (canSendMessages) {
+ args.push_back(HttpReqArg("can_send_messages", canSendMessages));
+ }
+ if (canSendMediaMessages) {
+ args.push_back(HttpReqArg("can_send_media_messages", canSendMediaMessages));
+ }
+ if (canSendOtherMessages) {
+ args.push_back(HttpReqArg("can_send_other_messages", canSendOtherMessages));
+ }
+ if (canAddWebPagePreviews) {
+ args.push_back(HttpReqArg("can_add_web_page_previews", canAddWebPagePreviews));
+ }
+ return sendRequest("restrictChatMember", args).get<bool>("", false);
+}
+
+bool Api::promoteChatMember(int64_t chatId, int32_t userId, bool canChangeInfo, bool canPostMessages,
+ bool canEditMessages, bool canDeleteMessages, bool canInviteUsers, bool canPinMessages, bool canPromoteMembers) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ args.push_back(HttpReqArg("user_id", userId));
+ if (canChangeInfo) {
+ args.push_back(HttpReqArg("can_change_info", canChangeInfo));
+ }
+ if (canPostMessages) {
+ args.push_back(HttpReqArg("can_post_messages", canPostMessages));
+ }
+ if (canEditMessages) {
+ args.push_back(HttpReqArg("can_edit_messages", canEditMessages));
+ }
+ if (canDeleteMessages) {
+ args.push_back(HttpReqArg("can_delete_messages", canDeleteMessages));
+ }
+ if (canInviteUsers) {
+ args.push_back(HttpReqArg("can_invite_users", canInviteUsers));
+ }
+ if (canPinMessages) {
+ args.push_back(HttpReqArg("can_pin_messages", canPinMessages));
+ }
+ if (canPromoteMembers) {
+ args.push_back(HttpReqArg("can_promote_members", canPromoteMembers));
+ }
+ return sendRequest("promoteChatMember", args).get<bool>("", false);
+}
+
+string Api::exportChatInviteLink(int64_t chatId) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ return sendRequest("exportChatInviteLink", args).get("", "");
+}
+
+bool Api::setChatPhoto(int64_t chatId, const InputFile::Ptr photo) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ args.push_back(HttpReqArg("photo", photo->data, true, photo->mimeType, photo->fileName));
+ return sendRequest("setChatPhoto", args).get<bool>("", false);
+}
+
+bool Api::deleteChatPhoto(int64_t chatId) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ return sendRequest("deleteChatPhoto", args).get<bool>("", false);
+}
+
+bool Api::setChatTitle(int64_t chatId, const string& title) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ args.push_back(HttpReqArg("title", title));
+ return sendRequest("setChatTitle", args).get<bool>("", false);
+}
+
+bool Api::setChatDescription(int64_t chatId, const string& description) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ args.push_back(HttpReqArg("description", description));
+ return sendRequest("setChatDescription", args).get<bool>("", false);
+}
+
+bool Api::pinChatMessage(int64_t chatId, int32_t messageId, bool disableNotification) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ args.push_back(HttpReqArg("message_id", messageId));
+ if (disableNotification) {
+ args.push_back(HttpReqArg("disable_notification", disableNotification));
+ }
+ return sendRequest("pinChatMessage", args).get<bool>("", false);
+}
+
+bool Api::unpinChatMessage(int64_t chatId) const {
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("chat_id", chatId));
+ return sendRequest("unpinChatMessage", args).get<bool>("", false);
+}
+
void Api::deleteMessage(int64_t chatId, int32_t messageId) const {
sendRequest("deleteMessage", { HttpReqArg("chat_id", chatId), HttpReqArg("message_id", messageId) });
}
@@ -684,7 +966,7 @@ ptree Api::sendRequest(const string& method, const vector<HttpReqArg>& args) con
}
}
-std::string Api::downloadFile(const std::string& filePath, const std::vector<HttpReqArg>& args) const {
+string Api::downloadFile(const string& filePath, const std::vector<HttpReqArg>& args) const {
string url = "https://api.telegram.org/file/bot";
url += _token;
url += "/";
diff --git a/src/EventHandler.cpp b/src/EventHandler.cpp
index 32efe3e..ba0ce54 100644
--- a/src/EventHandler.cpp
+++ b/src/EventHandler.cpp
@@ -26,9 +26,9 @@ void EventHandler::handleMessage(const Message::Ptr message) const {
_broadcaster->broadcastAnyMessage(message);
if (StringTools::startsWith(message->text, "/")) {
- uint32_t splitPosition;
- uint32_t spacePosition = message->text.find(' ');
- uint32_t atSymbolPosition = message->text.find('@');
+ uint16_t splitPosition;
+ uint16_t spacePosition = message->text.find(' ');
+ uint16_t atSymbolPosition = message->text.find('@');
if (spacePosition == message->text.npos) {
if (atSymbolPosition == message->text.npos) {
splitPosition = message->text.size();
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp
index 1b80d7f..f910761 100644
--- a/src/TgTypeParser.cpp
+++ b/src/TgTypeParser.cpp
@@ -47,9 +47,15 @@ Chat::Ptr TgTypeParser::parseJsonAndGetChat(const ptree& data) const {
}
result->title = data.get("title", "");
result->username = data.get("username", "");
- result->firstName = data.get<string>("first_name", "");
+ result->firstName = data.get("first_name", "");
result->lastName = data.get("last_name", "");
result->allMembersAreAdministrators = data.get<bool>("all_members_are_administrators", false);
+ result->photo = tryParseJson<ChatPhoto>(&TgTypeParser::parseJsonAndGetChatPhoto, data, "photo");
+ result->description = data.get("description", "");
+ result->inviteLink = data.get("invite_link", "");
+ result->pinnedMessage = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "pinned_message");
+ result->stickerSetName = data.get("sticker_set_name", "");
+ result->canSetStickerSet = data.get<bool>("can_set_sticker_set", false);
return result;
}
@@ -82,9 +88,11 @@ string TgTypeParser::parseChat(const Chat::Ptr& object) const {
User::Ptr TgTypeParser::parseJsonAndGetUser(const ptree& data) const {
auto result(make_shared<User>());
result->id = data.get<int32_t>("id");
+ result->isBot = data.get<bool>("is_bot", false);
result->firstName = data.get<string>("first_name");
result->lastName = data.get("last_name", "");
result->username = data.get("username", "");
+ result->languageCode = data.get("language_code", "");
return result;
}
@@ -95,9 +103,11 @@ string TgTypeParser::parseUser(const User::Ptr& object) const {
string result;
result += '{';
appendToJson(result, "id", object->id);
+ appendToJson(result, "is_bot", object->isBot);
appendToJson(result, "first_name", object->firstName);
appendToJson(result, "last_name", object->lastName);
appendToJson(result, "username", object->username);
+ appendToJson(result, "language_code", object->languageCode);
result.erase(result.length() - 1);
result += '}';
return result;
@@ -105,10 +115,10 @@ string TgTypeParser::parseUser(const User::Ptr& object) const {
MessageEntity::Ptr TgTypeParser::parseJsonAndGetEntity(const ptree& data) const{
auto result(make_shared<MessageEntity>());
- result->type=data.get<string>("type");
- result->offset=data.get<int32_t>("offset");
- result->length=data.get<int32_t>("length");
- result->url=data.get<string>("url", "");
+ result->type = data.get<string>("type");
+ result->offset = data.get<int32_t>("offset");
+ result->length = data.get<int32_t>("length");
+ result->url = data.get<string>("url", "");
result->user = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "user");
return result;
}
@@ -122,11 +132,14 @@ Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const {
result->forwardFrom = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "forward_from");
result->forwardFromChat = tryParseJson<Chat>(&TgTypeParser::parseJsonAndGetChat, data, "forward_from_chat");
result->forwardFromMessageId = data.get<int32_t>("forward_from_message_id", 0);
+ result->forwardSignature = data.get("forward_signature", "");
result->forwardDate = data.get("forward_date", 0);
result->replyToMessage = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "reply_to_message");
result->editDate = data.get<int32_t>("edit_date", 0);
+ result->authorSignature = data.get("author_signature", "");
result->text = data.get("text", "");
result->entities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetEntity, data, "entities");
+ result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetEntity, data, "caption_entities");
result->audio = tryParseJson<Audio>(&TgTypeParser::parseJsonAndGetAudio, data, "audio");
result->document = tryParseJson<Document>(&TgTypeParser::parseJsonAndGetDocument, data, "document");
result->photo = parseJsonAndGetArray<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "photo");
@@ -135,6 +148,7 @@ Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const {
result->contact = tryParseJson<Contact>(&TgTypeParser::parseJsonAndGetContact, data, "contact");
result->location = tryParseJson<Location>(&TgTypeParser::parseJsonAndGetLocation, data, "location");
result->newChatMember = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "new_chat_participant");
+ result->newChatMembers = parseJsonAndGetArray<User>(&TgTypeParser::parseJsonAndGetUser, data, "new_chat_members");
result->leftChatMember = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "left_chat_participant");
result->newChatTitle = data.get("new_chat_title", "");
result->newChatPhoto = parseJsonAndGetArray<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "new_chat_photo");
@@ -161,9 +175,11 @@ string TgTypeParser::parseMessage(const Message::Ptr& object) const {
appendToJson(result, "forward_from", parseUser(object->forwardFrom));
appendToJson(result, "forward_from_chat", parseChat(object->forwardFromChat));
appendToJson(result, "forward_from_message_id", object->forwardFromMessageId);
+ appendToJson(result, "forward_signature", object->forwardSignature);
appendToJson(result, "forward_date", object->forwardDate);
appendToJson(result, "reply_to_message", parseMessage(object->replyToMessage));
appendToJson(result, "edit_date", object->editDate);
+ appendToJson(result, "author_signature", object->authorSignature);
appendToJson(result, "text", object->text);
appendToJson(result, "audio", parseAudio(object->audio));
appendToJson(result, "document", parseDocument(object->document));
@@ -173,6 +189,7 @@ string TgTypeParser::parseMessage(const Message::Ptr& object) const {
appendToJson(result, "contact", parseContact(object->contact));
appendToJson(result, "location", parseLocation(object->location));
appendToJson(result, "new_chat_member", parseUser(object->newChatMember));
+ appendToJson(result, "new_chat_members", parseArray(&TgTypeParser::parseUser, object->newChatMembers));
appendToJson(result, "left_chat_member", parseUser(object->leftChatMember));
appendToJson(result, "new_chat_title", object->newChatTitle);
appendToJson(result, "new_chat_photo", parseArray(&TgTypeParser::parsePhotoSize, object->newChatPhoto));
@@ -271,6 +288,8 @@ Sticker::Ptr TgTypeParser::parseJsonAndGetSticker(const ptree& data) const {
result->height = data.get<int32_t>("height");
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
result->emoji = data.get("emoji", "");
+ result->setName = data.get("set_name", "");
+ result->maskPosition = tryParseJson<MaskPosition>(&TgTypeParser::parseJsonAndGetMaskPosition, data, "mask_position");
result->fileSize = data.get("file_size", 0);
return result;
}
@@ -292,6 +311,54 @@ string TgTypeParser::parseSticker(const Sticker::Ptr& object) const {
return result;
}
+StickerSet::Ptr TgTypeParser::parseJsonAndGetStickerSet(const ptree& data) const {
+ auto result(make_shared<StickerSet>());
+ result->name = data.get("name", "");
+ result->title = data.get("title", "");
+ result->containsMasks = data.get<bool>("contains_masks", false);
+ result->stickers = parseJsonAndGetArray<Sticker>(&TgTypeParser::parseJsonAndGetSticker, data, "stickers");
+ return result;
+}
+
+string TgTypeParser::parseStickerSet(const StickerSet::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ string result;
+ result += '{';
+ appendToJson(result, "name", object->name);
+ appendToJson(result, "title", object->title);
+ appendToJson(result, "contains_masks", object->containsMasks);
+ appendToJson(result, "stickers", parseArray(&TgTypeParser::parseSticker, object->stickers));
+ result.erase(result.length() - 1);
+ result += '}';
+ return result;
+}
+
+MaskPosition::Ptr TgTypeParser::parseJsonAndGetMaskPosition(const ptree& data) const {
+ auto result(make_shared<MaskPosition>());
+ result->point = data.get("point", "");
+ result->xShift = data.get<float>("x_shift", 0);
+ result->yShift = data.get<float>("y_shift", 0);
+ result->scale = data.get<float>("scale", 0);
+ return result;
+}
+
+string TgTypeParser::parseMaskPosition(const MaskPosition::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ string result;
+ result += '{';
+ appendToJson(result, "point", object->point);
+ appendToJson(result, "x_shift", object->xShift);
+ appendToJson(result, "y_shift", object->yShift);
+ appendToJson(result, "scale", object->scale);
+ result.erase(result.length() - 1);
+ result += '}';
+ return result;
+}
+
Video::Ptr TgTypeParser::parseJsonAndGetVideo(const ptree& data) const {
auto result(make_shared<Video>());
result->fileId = data.get<string>("file_id");
@@ -322,6 +389,32 @@ string TgTypeParser::parseVideo(const Video::Ptr& object) const {
return result;
}
+VideoNote::Ptr TgTypeParser::parseJsonAndGetVideoNote(const ptree& data) const {
+ VideoNote::Ptr result(new VideoNote);
+ result->fileId = data.get<string>("file_id");
+ result->length = data.get<int32_t>("length");
+ result->duration = data.get<int32_t>("duration");
+ result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
+ result->fileSize = data.get("file_size", 0);
+ return result;
+}
+
+string TgTypeParser::parseVideoNote(const VideoNote::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ string result;
+ result += '{';
+ appendToJson(result, "file_id", object->fileId);
+ appendToJson(result, "length", object->length);
+ appendToJson(result, "duration", object->duration);
+ appendToJson(result, "thumb", parsePhotoSize(object->thumb));
+ appendToJson(result, "file_size", object->fileSize);
+ result += '}';
+ result.erase();
+ return result;
+}
+
Contact::Ptr TgTypeParser::parseJsonAndGetContact(const ptree& data) const {
auto result(make_shared<Contact>());
result->phoneNumber = data.get<string>("phone_number");
@@ -418,6 +511,63 @@ string TgTypeParser::parseUserProfilePhotos(const UserProfilePhotos::Ptr& object
return result;
}
+InputMedia::Ptr TgTypeParser::parseJsonAndGetInputMedia(const ptree& data) const {
+ string type = data.get("type", "");
+ if (type == "photo") {
+ auto result(make_shared<InputMediaPhoto>());
+ result->media = data.get("media", "");
+ result->caption = data.get("caption", "");
+ result->parseMode = data.get("parse_mode", "");
+ return result;
+ }
+ else if (type == "video") {
+ auto result(make_shared<InputMediaVideo>());
+ result->media = data.get("media", "");
+ result->caption = data.get("caption", "");
+ result->parseMode = data.get("parse_mode", "");
+ result->width = data.get<int32_t>("width", 0);
+ result->height = data.get<int32_t>("height", 0);
+ result->duration = data.get<int32_t>("duration", 0);
+ result->supportsStreaming = data.get<bool>("supports_streaming", false);
+ return result;
+ }
+ else {
+ return nullptr;
+ }
+}
+
+string TgTypeParser::parseInputMedia(const InputMedia::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ string result;
+ result += '{';
+ if (object->type == InputMedia::TYPE::PHOTO) {
+ appendToJson(result, "type", "photo");
+ }
+ else {
+ appendToJson(result, "type", "video");
+ }
+ appendToJson(result, "media", object->media);
+ appendToJson(result, "caption", object->caption);
+ appendToJson(result, "parse_mode", object->parseMode);
+ if (object->width) {
+ appendToJson(result, "width", object->width);
+ }
+ if (object->height) {
+ appendToJson(result, "height", object->height);
+ }
+ if (object->duration) {
+ appendToJson(result, "duration", object->duration);
+ }
+ if (object->supportsStreaming) {
+ appendToJson(result, "supports_streaming", object->supportsStreaming);
+ }
+ result.erase(result.length() - 1);
+ result += '}';
+ return result;
+}
+
File::Ptr TgTypeParser::parseJsonAndGetFile(const boost::property_tree::ptree& data) const {
auto result(make_shared<File>());
result->fileId = data.get<string>("file_id");
@@ -541,7 +691,21 @@ std::string TgTypeParser::parseForceReply(const ForceReply::Ptr& object) const {
ChatMember::Ptr TgTypeParser::parseJsonAndGetChatMember(const boost::property_tree::ptree& data) const {
auto result(make_shared<ChatMember>());
result->user = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "user");
- result->status = data.get<string>("status");
+ result->status = data.get("status", "");
+ result->untilDate = data.get<uint64_t>("until_date", 0);
+ result->canBeEdited = data.get<bool>("can_be_edited", false);
+ result->canChangeInfo = data.get<bool>("can_change_info", false);
+ result->canPostMessages = data.get<bool>("can_post_messages", false);
+ result->canEditMessages = data.get<bool>("can_edit_messages", false);
+ result->canDeleteMessages = data.get<bool>("can_delete_messages", false);
+ result->canInviteUsers = data.get<bool>("can_invite_users", false);
+ result->canRestrictMembers = data.get<bool>("can_restrict_members", false);
+ result->canPinMessages = data.get<bool>("can_pin_messages", false);
+ result->canPromoteMembers = data.get<bool>("can_promote_messages", false);
+ result->canSendMessages = data.get<bool>("can_send_messages", false);
+ result->canSendMediaMessages = data.get<bool>("can_send_media_messages", false);
+ result->canSendOtherMessages = data.get<bool>("can_send_other_messages", false);
+ result->canAddWebPagePreviews = data.get<bool>("can_add_web_page_previews", false);
return result;
}
@@ -558,6 +722,26 @@ std::string TgTypeParser::parseChatMember(const ChatMember::Ptr& object) const {
return result;
}
+ChatPhoto::Ptr TgTypeParser::parseJsonAndGetChatPhoto(const boost::property_tree::ptree& data) const {
+ auto result(make_shared<ChatPhoto>());
+ result->smallFileId = data.get("small_file_id", "");
+ result->bigFileId = data.get("big_file_id", "");
+ return result;
+}
+
+std::string TgTypeParser::parseChatPhoto(const ChatPhoto::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ string result;
+ result += '{';
+ appendToJson(result, "small_file_id", object->smallFileId);
+ appendToJson(result, "big_file_id", object->bigFileId);
+ result.erase(result.length() - 1);
+ result += '}';
+ return result;
+}
+
ResponseParameters::Ptr TgTypeParser::parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const {
auto result(make_shared<ResponseParameters>());
result->migrateToChatId = data.get<int32_t>("migrate_to_chat_id", 0);
@@ -1178,6 +1362,7 @@ InlineQueryResultGif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultGif(cons
result->gifUrl = data.get<string>("gif_url", "");
result->gifWidth = data.get("gif_width", 0);
result->gifHeight = data.get("gif_height", 0);
+ result->gifDuration = data.get("gif_duration", 0);
result->thumbUrl = data.get<string>("thumb_url");
return result;
}
@@ -1191,6 +1376,7 @@ std::string TgTypeParser::parseInlineQueryResultGif(const InlineQueryResultGif::
appendToJson(result, "gif_url", object->gifUrl);
appendToJson(result, "gif_width", object->gifWidth);
appendToJson(result, "gif_height", object->gifHeight);
+ appendToJson(result, "gif_duration", object->gifDuration);
appendToJson(result, "thumb_url", object->thumbUrl);
// The last comma will be erased by parseInlineQueryResult().
return result;
@@ -1202,6 +1388,7 @@ InlineQueryResultMpeg4Gif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultMpe
result->mpeg4Url = data.get<string>("mpeg4_url");
result->mpeg4Width = data.get("mpeg4_width", 0);
result->mpeg4Height = data.get("mpeg4_height", 0);
+ result->mpeg4Duration = data.get("mpeg4_duration", 0);
result->thumbUrl = data.get<string>("thumb_url");
return result;
}
@@ -1216,6 +1403,7 @@ std::string TgTypeParser::parseInlineQueryResultMpeg4Gif(const InlineQueryResult
appendToJson(result, "mpeg4_url", object->mpeg4Url);
appendToJson(result, "mpeg4_width", object->mpeg4Width);
appendToJson(result, "mpeg4_height", object->mpeg4Height);
+ appendToJson(result, "mpeg4_duration", object->mpeg4Duration);
appendToJson(result, "thumb_url", object->thumbUrl);
// The last comma will be erased by parseInlineQueryResult().
return result;
@@ -1539,6 +1727,204 @@ std::string TgTypeParser::parseInputContactMessageContent(const InputContactMess
return result;
}
+Invoice::Ptr TgTypeParser::parseJsonAndGetInvoice(const boost::property_tree::ptree& data) const {
+ auto result(make_shared<Invoice>());
+ result->title = data.get<string>("title");
+ result->description = data.get<string>("description");
+ result->startParameter = data.get<string>("start_parameter");
+ result->currency = data.get<string>("currency");
+ result->totalAmount = data.get<int32_t>("total_amount");
+ return result;
+}
+
+std::string TgTypeParser::parseInvoice(const Invoice::Ptr& object) const {
+ if (!object) {
+ return " ";
+ }
+ string result;
+ result += '{';
+ appendToJson(result, "title", object->title);
+ appendToJson(result, "description", object->description);
+ appendToJson(result, "start_parameter", object->startParameter);
+ appendToJson(result, "currency", object->currency);
+ appendToJson(result, "total_amount", object->totalAmount);
+ result.erase(result.length() - 1);
+ result += '}';
+ return result;
+}
+
+LabeledPrice::Ptr TgTypeParser::parseJsonAndGetLabeledPrice(const boost::property_tree::ptree& data) const {
+ auto result(make_shared<LabeledPrice>());
+ result->label = data.get<string>("label");
+ result->amount = data.get<int32_t>("amount");
+ return result;
+}
+
+string TgTypeParser::parseLabeledPrice(const LabeledPrice::Ptr& object) const {
+ std::string result;
+ result += '{';
+ appendToJson(result, "label", object->label);
+ appendToJson(result, "amount", object->amount);
+ result.erase(result.length() - 1);
+ result += '}';
+ return result;
+}
+
+OrderInfo::Ptr TgTypeParser::parseJsonAndGetOrderInfo(const boost::property_tree::ptree& data) const {
+ auto result(make_shared<OrderInfo>());
+ result->name = data.get<string>("name", "");
+ result->phoneNumber = data.get<string>("phone_number", "");
+ result->email = data.get<string>("email", "");
+ result->shippingAddress = tryParseJson(&TgTypeParser::parseJsonAndGetShippingAddress, data, "shipping_address");
+ return result;
+}
+
+string TgTypeParser::parseOrderInfo(const OrderInfo::Ptr& object) const {
+ if (!object) {
+ return " ";
+ }
+ std::string result;
+ result += '{';
+ if (!object->name.empty()) {
+ appendToJson(result, "name", object->name);
+ }
+ if (!object->phoneNumber.empty()) {
+ appendToJson(result, "phone_number", object->phoneNumber);
+ }
+ if (!object->email.empty()) {
+ appendToJson(result, "email", object->email);
+ }
+ if (!object->shippingAddress) {
+ result += R"("shipping_address":)";
+ result += parseShippingAddress(object->shippingAddress);
+ result += ",";
+ }
+ result.erase(result.length() - 1);
+ result += '}';
+ return result;
+}
+
+PreCheckoutQuery::Ptr TgTypeParser::parseJsonAndGetPreCheckoutQuery(const boost::property_tree::ptree& data) const {
+ auto result(make_shared<PreCheckoutQuery>());
+ result->id = data.get<string>("id");
+ result->from = tryParseJson(&TgTypeParser::parseJsonAndGetUser, data, "user");
+ result->currency = data.get<string>("currency");
+ result->totalAmount = data.get<int32_t>("total_amount");
+ return result;
+}
+
+string TgTypeParser::parsePreCheckoutQuery(const PreCheckoutQuery::Ptr& object) const {
+ std::string result;
+ result += '{';
+ appendToJson(result, "id", object->id);
+ result += R"("user":)";
+ result += parseUser(object->from);
+ result += ",";
+ appendToJson(result, "currency", object->currency);
+ appendToJson(result, "total_amount", object->totalAmount);
+ result.erase(result.length() - 1);
+ result += '}';
+ return result;
+}
+
+ShippingAddress::Ptr TgTypeParser::parseJsonAndGetShippingAddress(const boost::property_tree::ptree& data) const {
+ ShippingAddress::Ptr result;
+ result->countryCode = data.get<string>("country_code");
+ result->state = data.get<string>("state", "");
+ result->city = data.get<string>("city");
+ result->streetLine1 = data.get<string>("street_line1");
+ result->streetLine2 = data.get<string>("street_line2");
+ result->postCode = data.get<string>("post_code");
+ return result;
+}
+
+string TgTypeParser::parseShippingAddress(const ShippingAddress::Ptr& object) const {
+ std::string result;
+ result += '{';
+ appendToJson(result, "country_code", object->countryCode);
+ if (!object->state.empty()) {
+ appendToJson(result, "state", object->state);
+ }
+ appendToJson(result, "city", object->city);
+ appendToJson(result, "street_line1", object->streetLine1);
+ appendToJson(result, "street_line2", object->streetLine2);
+ appendToJson(result, "post_code", object->postCode);
+ result.erase(result.length() - 1);
+ result += '}';
+ return result;
+}
+
+ShippingOption::Ptr TgTypeParser::parseJsonAndGetShippingOption(const boost::property_tree::ptree& data) const {
+ auto result(make_shared<ShippingOption>());
+ result->id = data.get<string>("id");
+ result->title = data.get<string>("title");
+ result->prices = parseJsonAndGetArray<LabeledPrice>(&TgTypeParser::parseJsonAndGetLabeledPrice, data, "prices");
+ return result;
+}
+
+string TgTypeParser::parseShippingOption(const ShippingOption::Ptr& object) const {
+ std::string result;
+ result += '{';
+ appendToJson(result, "id", object->id);
+ appendToJson(result, "title", object->title);
+ result.erase(result.length() - 1);
+ result += R"("prices":)";
+ result += parseArray(&TgTypeParser::parseLabeledPrice, object->prices);
+ result += '}';
+ return result;
+}
+
+ShippingQuery::Ptr TgTypeParser::parseJsonAndGetShippingQuery(const boost::property_tree::ptree& data) const {
+ auto result(make_shared<ShippingQuery>());
+ result->id = data.get<string>("id");
+ result->from = tryParseJson(&TgTypeParser::parseJsonAndGetUser, data, "from");
+ result->invoicePayload = data.get<string>("invoice_payload");
+ result->shippingAddress = tryParseJson(&TgTypeParser::parseJsonAndGetShippingAddress, data, "shipping_address");
+ return result;
+}
+
+string TgTypeParser::parseShippingQuery(const ShippingQuery::Ptr& object) const {
+ string result;
+ result += '{';
+ appendToJson(result, "id", object->id);
+ result += R"("from":)";
+ result += parseUser(object->from);
+ result += ",";
+ appendToJson(result, "invoice_payload", object->invoicePayload);
+ result += R"("shipping_address":)";
+ result += parseShippingAddress(object->shippingAddress);
+ result += ",";
+ result.erase(result.length() - 1);
+ result += '}';
+ return result;
+}
+
+SuccessfulPayment::Ptr TgTypeParser::parseJsonAndGetSucessfulPayment(const boost::property_tree::ptree& data) const {
+ auto result(make_shared<SuccessfulPayment>());
+ result->currency = data.get<string>("currency");
+ result->totalAmount = data.get<int32_t>("total_amount");
+ result->invoicePayload = data.get<string>("invoice_payload");
+ result->shippingOptionId = data.get<string>("shipping_option_id");
+ result->orderInfo = tryParseJson(&TgTypeParser::parseJsonAndGetOrderInfo, data, "order_info");
+ return result;
+}
+
+std::string TgTypeParser::parseSucessfulPayment(const SuccessfulPayment::Ptr& object) const {
+ string result;
+ result += '{';
+ appendToJson(result, "currency", object->currency);
+ appendToJson(result, "total_amount", object->totalAmount);
+ appendToJson(result, "invoice_payload", object->invoicePayload);
+ appendToJson(result, "shipping_option_id", object->shippingOptionId);
+ result += R"("order_info":)";
+ result += parseOrderInfo(object->orderInfo);
+ result += ",";
+ result.erase(result.length() - 1);
+ result += '}';
+ return result;
+}
+
+
void TgTypeParser::appendToJson(string& json, const string& varName, const string& value) const {
if (value.empty()) {
return;