summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJellyBrick <shlee1503@naver.com>2018-05-27 22:12:56 +0900
committerJellyBrick <shlee1503@naver.com>2018-05-27 22:12:56 +0900
commit94f8360629909e93e82417085db8381791c95c7b (patch)
tree8816bd39559e498bd147ec1ce24bba186c70a8ba /include
parentc81f7d9d7a4fe9dc3b48b92fad633bd5c44b8e74 (diff)
Bot API 3.2 update
Diffstat (limited to 'include')
-rw-r--r--include/tgbot/Api.h107
-rw-r--r--include/tgbot/TgTypeParser.h9
-rw-r--r--include/tgbot/types/MaskPosition.h62
-rw-r--r--include/tgbot/types/Sticker.h11
-rw-r--r--include/tgbot/types/StickerSet.h65
5 files changed, 242 insertions, 12 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index 5750a83..dd1805d 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -39,6 +39,7 @@
#include "tgbot/types/Venue.h"
#include "tgbot/types/WebhookInfo.h"
#include "tgbot/types/ChatMember.h"
+#include "tgbot/types/StickerSet.h"
#include "tgbot/types/File.h"
namespace TgBot {
@@ -188,7 +189,7 @@ public:
/**
* Use this method to send .webp stickers.
* @param chatId Unique identifier for the target chat.
- * @param sticker Id of the sticker that is already on the Telegram servers.
+ * @param stickerId Id of the sticker that is already on the Telegram servers.
* @param replyToMessageId Optional. If the message is a reply, ID of the original message.
* @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
* @param disableNotification Optional. Sends the message silenty.
@@ -198,6 +199,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 +295,7 @@ public:
* @param disableNotification Optional. Sends the message silenty.
* @return On success, the sent message is returned.
*/
- Message::Ptr sendVideo(int64_t chatId, const InputFile::Ptr video, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const std::string &caption = "",
+ Message::Ptr sendVideo(int64_t chatId, const InputFile::Ptr video, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const std::string& caption = "",
int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const;
/**
@@ -226,7 +311,7 @@ public:
* @param disableNotification Optional. Sends the message silenty.
* @return On success, the sent message is returned.
*/
- Message::Ptr sendVideo(int64_t chatId, const std::string& videoId, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const std::string &caption = "",
+ Message::Ptr sendVideo(int64_t chatId, const std::string& videoId, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const std::string& caption = "",
int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const;
/**
@@ -254,7 +339,7 @@ public:
* @param replyMarkup Additional interface options. A object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
* @return On success, the sent Message is returned.
*/
- Message::Ptr sendVideoNote(int64_t chatId, const std::string &videoNote, int64_t replyToMessageId = 0, bool disableNotification = false,
+ Message::Ptr sendVideoNote(int64_t chatId, const std::string& videoNote, int64_t replyToMessageId = 0, bool disableNotification = false,
int32_t duration = 0, int32_t length = 0, const GenericReply::Ptr replyMarkup = GenericReply::Ptr());
@@ -269,7 +354,7 @@ public:
* @param disableNotification Optional. Sends the message silenty.
* @return On success, the sent message is returned.
*/
- Message::Ptr sendVoice(int64_t chatId, const InputFile::Ptr voice, const std::string &caption = "", int duration = 0, int32_t replyToMessageId = 0,
+ Message::Ptr sendVoice(int64_t chatId, const InputFile::Ptr voice, const std::string& caption = "", int duration = 0, int32_t replyToMessageId = 0,
const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const;
/**
@@ -283,7 +368,7 @@ public:
* @param disableNotification Optional. Sends the message silenty.
* @return On success, the sent message is returned.
*/
- Message::Ptr sendVoice(int64_t chatId, const std::string& voiceId, const std::string &caption = "", int duration = 0, int32_t replyToMessageId = 0,
+ Message::Ptr sendVoice(int64_t chatId, const std::string& voiceId, const std::string& caption = "", int duration = 0, int32_t replyToMessageId = 0,
const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const;
/**
@@ -312,7 +397,7 @@ public:
* @param disableNotification Optional. Sends the message silenty.
* @return On success, the sent message is returned.
*/
- Message::Ptr sendVenue(int64_t chatId, float latitude, float longitude, std::string title, std::string address, std::string foursquareId = "",
+ Message::Ptr sendVenue(int64_t chatId, float latitude, float longitude, const std::string& title, const std::string& address, const std::string& foursquareId = "",
bool disableNotification = false, int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
/**
@@ -326,7 +411,7 @@ public:
* @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
* @return On success, the sent message is returned.
*/
- Message::Ptr sendContact(int64_t chatId, std::string phoneNumber, std::string firstName, std::string lastName = "", bool disableNotification = false,
+ Message::Ptr sendContact(int64_t chatId, const std::string& phoneNumber, const std::string& firstName, const std::string& lastName = "", bool disableNotification = false,
int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
/**
@@ -557,7 +642,7 @@ public:
* @param photo New chat photo.
* @return True on success
*/
- bool setChatPhoto(int64_t chatId, InputFile::Ptr photo) const;
+ bool setChatPhoto(int64_t chatId, const InputFile::Ptr photo) const;
/**
* Use this method to delete a chat photo.
@@ -574,7 +659,7 @@ public:
* @param title New chat title, 1-255 characters.
* @return True on success
*/
- bool setChatTitle(int64_t chatId, std::string title) const;
+ bool setChatTitle(int64_t chatId, const std::string& title) const;
/**
* Use this method to change the description of a supergroup or a channel.
@@ -582,7 +667,7 @@ public:
* @param description New chat description, 1-255 characters.
* @return True on success
*/
- bool setChatDescription(int64_t chatId, std::string description) const;
+ bool setChatDescription(int64_t chatId, const std::string& description) const;
/**
* Use this method to pin a message in a supergroup or a channel.
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index 0aea80b..b7121df 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -35,6 +35,8 @@
#include "tgbot/types/Audio.h"
#include "tgbot/types/Document.h"
#include "tgbot/types/Sticker.h"
+#include "tgbot/types/StickerSet.h"
+#include "tgbot/types/MaskPosition.h"
#include "tgbot/types/Video.h"
#include "tgbot/types/VideoNote.h"
#include "tgbot/types/Contact.h"
@@ -119,6 +121,10 @@ public:
std::string parseDocument(const Document::Ptr& object) const;
Sticker::Ptr parseJsonAndGetSticker(const boost::property_tree::ptree& data) const;
std::string parseSticker(const Sticker::Ptr& object) const;
+ StickerSet::Ptr parseJsonAndGetStickerSet(const boost::property_tree::ptree& data) const;
+ std::string parseStickerSet(const StickerSet::Ptr& object) const;
+ MaskPosition::Ptr parseJsonAndGetMaskPosition(const boost::property_tree::ptree& data) const;
+ std::string parseMaskPosition(const MaskPosition::Ptr& object) const;
Video::Ptr parseJsonAndGetVideo(const boost::property_tree::ptree& data) const;
std::string parseVideo(const Video::Ptr& object) const;
VideoNote::Ptr parseJsonAndGetVideoNote(const boost::property_tree::ptree& data) const;
@@ -150,7 +156,8 @@ public:
ChatMember::Ptr parseJsonAndGetChatMember(const boost::property_tree::ptree& data) const;
std::string parseChatMember(const ChatMember::Ptr& object) const;
- ChatPhoto::Ptr parseJsonAndGetChatPhoto(const boost::property_tree::ptree& data) const; // returned only in getChat
+ ChatPhoto::Ptr parseJsonAndGetChatPhoto(const boost::property_tree::ptree& data) const;
+ std::string parseChatPhoto(const ChatPhoto::Ptr& object) const;
ResponseParameters::Ptr parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const;
std::string parseResponseParameters(const ResponseParameters::Ptr& object) const;
diff --git a/include/tgbot/types/MaskPosition.h b/include/tgbot/types/MaskPosition.h
new file mode 100644
index 0000000..edd5d5e
--- /dev/null
+++ b/include/tgbot/types/MaskPosition.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2015 Oleg Morozenkov
+ * Copyright (c) 2018 JellyBrick
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef TGBOT_MARKPOSITION_H
+#define TGBOT_MARKPOSITION_H
+
+#include <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/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