summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJellyBrick <shlee1503@naver.com>2018-05-28 03:45:31 +0900
committerJellyBrick <shlee1503@naver.com>2018-05-28 03:45:31 +0900
commit981737b20b0db4914c667195b6584d14e9473e3d (patch)
treeb2a3aa0642c8360e0385c69717eb8f2cb86fbf24 /include
parentb0134ff90ccd4203721fd8d32c1d1bacaea8b47f (diff)
Bot API 3.5 update
Diffstat (limited to 'include')
-rw-r--r--include/tgbot/Api.h34
-rw-r--r--include/tgbot/TgTypeParser.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
6 files changed, 214 insertions, 12 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index 6e48207..6d03000 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -342,6 +342,16 @@ public:
Message::Ptr sendVideoNote(int64_t chatId, const std::string& videoNote, int64_t replyToMessageId = 0, bool disableNotification = false,
int32_t duration = 0, int32_t length = 0, const GenericReply::Ptr replyMarkup = GenericReply::Ptr());
+ /**
+ * Use this method to send a group of photos or videos as an album.
+ * @param chatId Unique identifier for the target chat of the target channel.
+ * @param media A JSON-serialized array describing photos and videos to be sent, must include 2–10 items.
+ * @param disableNotification Optional. Sends the messages silently. Users will receive a notification with no sound.
+ * @param replyToMessageId Optional. If the messages are a reply, ID of the original message.
+ * @return On success, an array of the sent Messages is returned.
+ */
+ std::vector<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.
@@ -389,7 +399,7 @@ public:
* Use this method to edit live location messages sent by the bot or via the bot (for inline bots).
* @param latitude Latitude of new location.
* @param longitude Longitude of new location.
- * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat of the target channel (in the format @channelusername).
+ * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat of the target channel.
* @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the sent message.
* @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message.
* @param replyMarkup Optional. A JSON-serialized object for a new inline keyboard.
@@ -400,7 +410,7 @@ public:
/**
* Use this method to edit live location messages sent by the bot or via the bot (for inline bots).
- * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat of the target channel (in the format @channelusername).
+ * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat of the target channel.
* @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the sent message.
* @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message.
* @param replyMarkup Optional. A JSON-serialized object for a new inline keyboard.
@@ -467,35 +477,35 @@ public:
/**
* Use this method for your bot to leave a group, supergroup or channel.
- * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
+ * @param chatId Unique identifier for the target chat of the target supergroup or channel.
* @return True on success
*/
bool leaveChat(int64_t chatId) const;
/**
* Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success.
- * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
+ * @param chatId Unique identifier for the target chat of the target supergroup or channel.
* @return Chat object.
*/
Chat::Ptr getChat(int64_t chatId) const;
/**
* Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
- * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
+ * @param chatId Unique identifier for the target chat of the target supergroup or channel.
* @return ChatMember object.
*/
std::vector<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.
*/
@@ -503,7 +513,7 @@ public:
/**
* Use this method to get information about a member of a chat. Returns a ChatMember object on success.
- * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
+ * @param chatId Unique identifier for the target chat of the target supergroup or channel.
* @param stickerSetName Name of the sticker set to be set as the group sticker set.
* @return Returns True on success.
*/
@@ -511,7 +521,7 @@ public:
/**
* Use this method to get information about a member of a chat. Returns a ChatMember object on success.
- * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
+ * @param chatId Unique identifier for the target chat of the target supergroup or channel.
* @return Returns True on success.
*/
bool deleteChatStickerSet(int64_t chatId) const;
@@ -531,7 +541,7 @@ public:
/**
* Use this method to edit text and game messages sent by the bot or via the bot (for inline bots)
* @param text New text of the message
- * @param chatId Optional Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param chatId Optional Required if inline_message_id is not specified. Unique identifier for the target chat of the target channel.
* @param messageId Optional Required if inline_message_id is not specified. Identifier of the sent message
* @param inlineMessageId Optional Required if chat_id and message_id are not specified. Identifier of the inline message
* @param parseMode Optional Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
@@ -544,7 +554,7 @@ public:
/**
* Use this method to edit captions of messages sent by the bot or via the bot (for inline bots).
- * @param chatId Optional Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param chatId Optional Required if inline_message_id is not specified. Unique identifier for the target chat of the target channel.
* @param messageId Optional Required if inline_message_id is not specified. Identifier of the sent message
* @param caption Optional New caption of the message
* @param inlineMessageId Optional Required if chat_id and message_id are not specified. Identifier of the inline message
@@ -556,7 +566,7 @@ public:
/**
* Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
- * @param chatId Optional Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param chatId Optional Required if inline_message_id is not specified. Unique identifier for the target chat of the target channel.
* @param messageId Optional Required if inline_message_id is not specified. Identifier of the sent message
* @param inlineMessageId Optional Required if chat_id and message_id are not specified. Identifier of the inline message
* @param replyMarkup Optional A JSON-serialized object for an inline keyboard.
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index b7121df..b5e51ed 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -92,6 +92,9 @@
#include "tgbot/types/ShippingOption.h"
#include "tgbot/types/SuccessfulPayment.h"
#include "tgbot/types/LabeledPrice.h"
+#include "tgbot/types/InputMedia.h"
+#include "tgbot/types/InputMediaPhoto.h"
+#include "tgbot/types/InputMediaVideo.h"
namespace TgBot {
@@ -137,6 +140,8 @@ public:
std::string parseUpdate(const Update::Ptr& object) const;
UserProfilePhotos::Ptr parseJsonAndGetUserProfilePhotos(const boost::property_tree::ptree& data) const;
std::string parseUserProfilePhotos(const UserProfilePhotos::Ptr& object) const;
+ InputMedia::Ptr parseJsonAndGetInputMedia(const boost::property_tree::ptree& data) const;
+ std::string parseInputMedia(const InputMedia::Ptr& object) const;
File::Ptr parseJsonAndGetFile(const boost::property_tree::ptree& data) const;
std::string parseFile(const File::Ptr& object) const;
diff --git a/include/tgbot/types/InputMedia.h b/include/tgbot/types/InputMedia.h
new file mode 100644
index 0000000..d7c3ace
--- /dev/null
+++ b/include/tgbot/types/InputMedia.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2015 Oleg Morozenkov
+ * Copyright (c) 2016 Konstantin Kukin
+ * Copyright (c) 2018 JellyBrick
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef TGBOT_INPUTMEDIA_H
+#define TGBOT_INPUTMEDIA_H
+
+#include <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 {