summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authornitanmarcel <nitan.marcel@protonmail.com>2019-11-19 21:31:44 +0200
committernitanmarcel <nitan.marcel@protonmail.com>2019-11-19 21:34:53 +0200
commit23553bc251ca673137b684082a6f84062f053bd2 (patch)
tree6ba5dccf2cb58e64a595399ee7da626ae7a285dd /include
parent70fdce95df4998ae4e54df4006859a3770a59478 (diff)
API 4.2
Diffstat (limited to 'include')
-rw-r--r--include/tgbot/Api.h39
-rw-r--r--include/tgbot/TgTypeParser.h8
-rw-r--r--include/tgbot/types/ChatMember.h5
-rw-r--r--include/tgbot/types/Message.h11
-rw-r--r--include/tgbot/types/Poll.h63
-rw-r--r--include/tgbot/types/PollOption.h46
6 files changed, 166 insertions, 6 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index 84a6c9b..184f3a1 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -291,6 +291,7 @@ public:
* @param disableNotification Optional. Sends the message silenty.
* @return On success, the sent message is returned.
*/
+
Message::Ptr sendVideo(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> video, bool supportsStreaming = false, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const boost::variant<InputFile::Ptr, std::string> thumb = "", const std::string& caption = "",
int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
@@ -585,7 +586,7 @@ public:
/**
* @brief Use this method to delete messages sent by bot (or by other users if bot is admin).
- * @param chatId Unique identifier for the target chat.
+ * @param chatId Unique identifier for the target chat or username of the target channel.
* @param messageId Unique identifier for the target message.
*/
void deleteMessage(int64_t chatId, int32_t messageId) const;
@@ -746,8 +747,8 @@ public:
bool setChatDescription(int64_t chatId, const std::string& description) const;
/**
- * @brief Use this method to pin a message in a supergroup or a channel.
- * @param chatId Unique identifier for the target chat.
+ * @brief Use this method to pin a message in a group, a supergroup, or a channel.
+ * @param chatId Unique identifier for the target chat or username of the target channel.
* @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
@@ -755,8 +756,8 @@ public:
bool pinChatMessage(int64_t chatId, int32_t messageId, bool disableNotification = false) const;
/**
- * @brief Use this method to unpin a message in a supergroup or a channel.
- * @param chatId Unique identifier for the target chat.
+ * @brief Use this method to unpin a message in a group, a supergroup, or a channel.
+ * @param chatId Unique identifier for the target chat or username of the target channel.
* @return True on success
*/
bool unpinChatMessage(int64_t chatId) const;
@@ -792,7 +793,6 @@ public:
std::vector<GameHighScore::Ptr> getGameHighScores(int32_t userId, int32_t score, bool force = false,
bool disableEditMessage = false, int64_t chatId = 0, int32_t messageId = 0, const std::string& inlineMessageId = "") const;
-
/**
* @brief Downloads file from Telegram and saves it in memory.
* @param filePath Telegram file path.
@@ -801,6 +801,33 @@ public:
*/
std::string downloadFile(const std::string& filePath, const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>()) const;
+ /**
+ * @brief Use this method to send a poll.
+ * @param chatId Unique identifier for the target chat or username of the target channel.
+ * @param question Poll question, 1-255 characters.
+ * @param options List of answer options, 2-10 strings 1-100 characters each.
+ * @param disable_notification Optional. Sends the message silenty.
+ * @param reply_to_message_id Optional. If the message is a reply, ID of the original message.
+ * @param reply_markup Optional. Additional interface options. An 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 sendPoll(int64_t chatId, std::string question, std::vector<std::string> options, bool disable_notification=false, int32_t reply_to_message_id=0,GenericReply::Ptr reply_markup = std::make_shared<GenericReply>()) const;
+
+ /**
+ * @brief Use this method to stop a poll which was sent by the bot. On success, the stopped Poll with the final results is returned..
+ * @param chatId Unique identifier for the target chat or username of the target channel.
+ * @param question Poll question, 1-255 characters.
+ * @param options List of answer options, 2-10 strings 1-100 characters each.
+ * @param disable_notification Optional. Sends the message silenty.
+ * @param reply_to_message_id Optional. If the message is a reply, ID of the original message.
+ * @param reply_markup Optional. Additional interface options. An 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.
+ */
+
+ Poll::Ptr stopPoll(int64_t chatId, int64_t messageId, InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>()) const;
+
private:
boost::property_tree::ptree sendRequest(const std::string& method, const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>()) const;
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index eeda4cd..a2cb660 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -36,6 +36,8 @@
#include "tgbot/types/Document.h"
#include "tgbot/types/Sticker.h"
#include "tgbot/types/StickerSet.h"
+#include "tgbot/types/Poll.h"
+#include "tgbot/types/PollOption.h"
#include "tgbot/types/MaskPosition.h"
#include "tgbot/types/Video.h"
#include "tgbot/types/Voice.h"
@@ -145,6 +147,12 @@ namespace TgBot {
MaskPosition::Ptr parseJsonAndGetMaskPosition(const boost::property_tree::ptree& data) const;
std::string parseMaskPosition(const MaskPosition::Ptr& object) const;
+ Poll::Ptr parseJsonAndGetPoll(const boost::property_tree::ptree& data) const;
+ std::string parsePoll(const Poll::Ptr& object) const;
+
+ PollOption::Ptr parseJsonAndGetPollOption(const boost::property_tree::ptree& data) const;
+ std::string parsePollOption(const PollOption::Ptr& object) const;
+
Video::Ptr parseJsonAndGetVideo(const boost::property_tree::ptree& data) const;
std::string parseVideo(const Video::Ptr& object) const;
diff --git a/include/tgbot/types/ChatMember.h b/include/tgbot/types/ChatMember.h
index facfec2..79fff0e 100644
--- a/include/tgbot/types/ChatMember.h
+++ b/include/tgbot/types/ChatMember.h
@@ -77,6 +77,11 @@ public:
bool canPinMessages = false;
/**
+ * @brief Optional. Restricted only. True, if the user is a member of the chat at the moment of the request.
+ */
+ bool isMember = false;
+
+ /**
* @brief Optional. Administrators only. True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user).
*/
bool canPromoteMembers = false;
diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h
index f92eeaf..4b7ce59 100644
--- a/include/tgbot/types/Message.h
+++ b/include/tgbot/types/Message.h
@@ -34,6 +34,7 @@
#include "tgbot/types/Document.h"
#include "tgbot/types/Animation.h"
#include "tgbot/types/Sticker.h"
+#include "tgbot/types/Poll.h"
#include "tgbot/types/Video.h"
#include "tgbot/types/Contact.h"
#include "tgbot/types/Location.h"
@@ -97,6 +98,11 @@ public:
std::string forwardSignature;
/**
+ * @brief Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages.
+ */
+ std::string forwardSenderName;
+
+ /**
* @brief Optional. For forwarded messages, date the original message was sent in Unix time.
*/
int32_t forwardDate;
@@ -194,6 +200,11 @@ public:
Venue::Ptr venue;
/**
+ * @brief Optional. Message is a poll, information about the poll.
+ */
+ Poll::Ptr poll;
+
+ /**
* @brief Optional. A new member was added to the group, information about them (this member may be bot itself).
*/
User::Ptr newChatMember;
diff --git a/include/tgbot/types/Poll.h b/include/tgbot/types/Poll.h
new file mode 100644
index 0000000..11c3c07
--- /dev/null
+++ b/include/tgbot/types/Poll.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2019 Nitan Alexandru Marcel
+ *
+ * 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_POLL_H
+#define TGBOT_POLL_H
+
+#include <memory>
+#include <string>
+#include <vector>
+#include "tgbot/types/PollOption.h"
+
+namespace TgBot{
+ /**
+ * @brief This object represents a Poll.
+ *
+ * @ingroup types
+ */
+ class Poll{
+ public:
+ typedef std::shared_ptr<Poll> Ptr;
+
+ /**
+ * @brief Unique poll identifier.
+ */
+ int64_t id;
+
+ /**
+ * @brief Poll question, 1-255 characters.
+ */
+ std::string question;
+
+ /**
+ * @brief List of poll options.
+ */
+ PollOption::Ptr options;
+
+ /**
+ * @brief True, if the poll is closed.
+ */
+ bool is_closed;
+ };
+}
+
+#endif //TGBOT_POLL_H
diff --git a/include/tgbot/types/PollOption.h b/include/tgbot/types/PollOption.h
new file mode 100644
index 0000000..52099f9
--- /dev/null
+++ b/include/tgbot/types/PollOption.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2019 Nitan Alexandru Marcel
+ *
+ * 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.
+ */
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#ifndef TGBOT_POLLOPTION_H
+#define TGBOT_POLLOPTION_H
+
+class PollOption {
+
+public:
+ typedef std::shared_ptr<PollOption> Ptr;
+
+ /**
+ * @brief Option text, 1-100 characters.
+ */
+ std::string text;
+
+ /**
+ * @brief Number of users that voted for this option.
+ */
+ int64_t voter_count;
+};
+
+#endif //TGBOT_POLLOPTION_H