summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorllnulldisk <48621230+llnulldisk@users.noreply.github.com>2022-08-29 21:30:37 +0200
committerllnulldisk <48621230+llnulldisk@users.noreply.github.com>2022-08-29 21:30:37 +0200
commited5065b35911a6d7d3dff30bd80600cc593901a3 (patch)
tree8ee6f0c0a1730dbb11ff243e16d1ed720584a308 /include
parentb729f89033dca0cd2b9606060e735abfaf41c1f4 (diff)
Update to API 4.6
Diffstat (limited to 'include')
-rw-r--r--include/tgbot/Api.h24
-rw-r--r--include/tgbot/TgTypeParser.h8
-rw-r--r--include/tgbot/types/KeyboardButton.h20
-rw-r--r--include/tgbot/types/KeyboardButtonPollType.h28
-rw-r--r--include/tgbot/types/MessageEntity.h5
-rw-r--r--include/tgbot/types/Poll.h83
-rw-r--r--include/tgbot/types/PollAnswer.h39
-rw-r--r--include/tgbot/types/Update.h9
-rw-r--r--include/tgbot/types/User.h25
9 files changed, 191 insertions, 50 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index f5b325e..517c8fe 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -801,17 +801,23 @@ 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 disableNotification Optional. Sends the message silenty.
- * @param replyToMessageId Optional. If the message is a reply, ID of the original message.
- * @param replyMarkup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
- *
+ * @brief Use this method to send a native poll.
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param question Poll question, 1-255 characters
+ * @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
+ * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound.
+ * @param replyToMessageId Optional. If the message is a reply, ID of the original message
+ * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
+ * @param isAnonymous Optional. True, if the poll needs to be anonymous, defaults to True
+ * @param type Optional. Poll type, “quiz” or “regular”, defaults to “regular”
+ * @param allowsMultipleAnswers Optional. True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False
+ * @param correctOptionId Optional. 0-based identifier of the correct answer option, required for polls in quiz mode
+ * @param isClosed Optional. Pass True, if the poll needs to be immediately closed. This can be useful for poll preview.
* @return On success, the sent message is returned.
*/
- Message::Ptr sendPoll(std::int64_t chatId, const std::string& question, const std::vector<std::string>& options, bool disableNotification = false, std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
+ Message::Ptr sendPoll(std::int64_t chatId, const std::string& question, const std::vector<std::string>& options, bool disableNotification = false, std::int32_t replyToMessageId = 0,
+ GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool isAnonymous = true, const std::string& type = "", bool allowsMultipleAnswers = false,
+ std::int32_t correctOptionId = 0, bool isClosed = false) const;
/**
* @brief Use this method to stop a poll which was sent by the bot.
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index 5961bbe..1c43297 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -11,6 +11,7 @@
#include "tgbot/types/Sticker.h"
#include "tgbot/types/StickerSet.h"
#include "tgbot/types/Poll.h"
+#include "tgbot/types/PollAnswer.h"
#include "tgbot/types/PollOption.h"
#include "tgbot/types/ChatPermissions.h"
#include "tgbot/types/MaskPosition.h"
@@ -24,6 +25,7 @@
#include "tgbot/types/File.h"
#include "tgbot/types/ReplyKeyboardMarkup.h"
#include "tgbot/types/KeyboardButton.h"
+#include "tgbot/types/KeyboardButtonPollType.h"
#include "tgbot/types/ReplyKeyboardRemove.h"
#include "tgbot/types/ForceReply.h"
#include "tgbot/types/ChatMember.h"
@@ -135,6 +137,9 @@ public:
Poll::Ptr parseJsonAndGetPoll(const boost::property_tree::ptree& data) const;
std::string parsePoll(const Poll::Ptr& object) const;
+ PollAnswer::Ptr parseJsonAndGetPollAnswer(const boost::property_tree::ptree& data) const;
+ std::string parsePollAnswer(const PollAnswer::Ptr& object) const;
+
PollOption::Ptr parseJsonAndGetPollOption(const boost::property_tree::ptree& data) const;
std::string parsePollOption(const PollOption::Ptr& object) const;
@@ -183,6 +188,9 @@ public:
KeyboardButton::Ptr parseJsonAndGetKeyboardButton(const boost::property_tree::ptree& data) const;
std::string parseKeyboardButton(const KeyboardButton::Ptr& object) const;
+ KeyboardButtonPollType::Ptr parseJsonAndGetKeyboardButtonPollType(const boost::property_tree::ptree& data) const;
+ std::string parseKeyboardButtonPollType(const KeyboardButtonPollType::Ptr& object) const;
+
ReplyKeyboardRemove::Ptr parseJsonAndGetReplyKeyboardRemove(const boost::property_tree::ptree& data) const;
std::string parseReplyKeyboardRemove(const ReplyKeyboardRemove::Ptr& object) const;
diff --git a/include/tgbot/types/KeyboardButton.h b/include/tgbot/types/KeyboardButton.h
index 867d014..f2b6791 100644
--- a/include/tgbot/types/KeyboardButton.h
+++ b/include/tgbot/types/KeyboardButton.h
@@ -1,6 +1,8 @@
#ifndef TGBOT_CPP_KEYBOARDBUTTON_H
#define TGBOT_CPP_KEYBOARDBUTTON_H
+#include "tgbot/types/KeyboardButtonPollType.h"
+
#include <string>
#include <memory>
@@ -9,8 +11,8 @@ namespace TgBot {
/**
* @brief This object represents one button of the reply keyboard.
*
- * For simple text buttons String can be used instead of this
- * object to specify text of the button. Optional fields are mutually exclusive.
+ * For simple text buttons String can be used instead of this object to specify text of the button.
+ * Optional fields request_contact, request_location, and request_poll are mutually exclusive.
*
* @ingroup types
*/
@@ -20,23 +22,25 @@ public:
typedef std::shared_ptr<KeyboardButton> Ptr;
/**
- * @brief Text of the button. If none of the optional fields are used,
- * it will be sent to the bot as a message when the button is pressed
+ * @brief Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed
*/
std::string text;
/**
- * @brief Optional. If True, the user's phone number will be sent as a contact
- * when the button is pressed. Available in private chats only
+ * @brief Optional. If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only
*/
bool requestContact = false;
/**
- * @brief Optional. If True, the user's current location will be sent when the button is pressed. Available in private chats only.
+ * @brief Optional. If True, the user's current location will be sent when the button is pressed. Available in private chats only
*/
bool requestLocation = false;
-};
+ /**
+ * @brief Optional. If specified, the user will be asked to create a poll and send it to the bot when the button is pressed. Available in private chats only
+ */
+ KeyboardButtonPollType::Ptr requestPoll;
+};
}
#endif //TGBOT_CPP_KEYBOARDBUTTON_H
diff --git a/include/tgbot/types/KeyboardButtonPollType.h b/include/tgbot/types/KeyboardButtonPollType.h
new file mode 100644
index 0000000..1bead32
--- /dev/null
+++ b/include/tgbot/types/KeyboardButtonPollType.h
@@ -0,0 +1,28 @@
+#ifndef TGBOT_CPP_KEYBOARDBUTTONPOLLTYPE_H
+#define TGBOT_CPP_KEYBOARDBUTTONPOLLTYPE_H
+
+#include <string>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed.
+ *
+ * @ingroup types
+ */
+class KeyboardButtonPollType {
+
+public:
+ typedef std::shared_ptr<KeyboardButtonPollType> Ptr;
+
+ /**
+ * @brief Optional. If quiz is passed, the user will be allowed to create only polls in the quiz mode.
+ *
+ * If regular is passed, only regular polls will be allowed. Otherwise, the user will be allowed to create a poll of any type.
+ */
+ std::string type;
+};
+}
+
+#endif //TGBOT_CPP_KEYBOARDBUTTONPOLLTYPE_H
diff --git a/include/tgbot/types/MessageEntity.h b/include/tgbot/types/MessageEntity.h
index 9aa283d..21d9b99 100644
--- a/include/tgbot/types/MessageEntity.h
+++ b/include/tgbot/types/MessageEntity.h
@@ -44,6 +44,11 @@ public:
* @brief Optional. For “text_mention” only, the mentioned user
*/
User::Ptr user;
+
+ /**
+ * @brief Optional. For “pre” only, the programming language of the entity text
+ */
+ std::string language;
};
}
diff --git a/include/tgbot/types/Poll.h b/include/tgbot/types/Poll.h
index 9f4b04d..9c81dc7 100644
--- a/include/tgbot/types/Poll.h
+++ b/include/tgbot/types/Poll.h
@@ -9,35 +9,64 @@
#include <vector>
namespace TgBot {
+
+/**
+ * @brief This object contains information about a poll.
+ *
+ * @ingroup types
+ */
+class Poll {
+
+public:
+ typedef std::shared_ptr<Poll> Ptr;
+
+ /**
+ * @brief Unique poll identifier
+ */
+ std::int64_t id;
+
+ /**
+ * @brief Poll question, 1-255 characters
+ */
+ std::string question;
+
+ /**
+ * @brief List of poll options
+ */
+ std::vector<PollOption::Ptr> options;
+
+ /**
+ * @brief Total number of users that voted in the poll
+ */
+ std::int32_t totalVoterCount;
+
+ /**
+ * @brief True, if the poll is closed
+ */
+ bool isClosed;
+
+ /**
+ * @brief True, if the poll is anonymous
+ */
+ bool isAnonymous;
+
/**
- * @brief This object represents a Poll.
+ * @brief Poll type, currently can be “regular” or “quiz”
+ */
+ std::string type;
+
+ /**
+ * @brief True, if the poll allows multiple answers
+ */
+ bool allowsMultipleAnswers;
+
+ /**
+ * @brief Optional. 0-based identifier of the correct answer option.
*
- * @ingroup types
- */
- class Poll {
- public:
- typedef std::shared_ptr<Poll> Ptr;
-
- /**
- * @brief Unique poll identifier.
- */
- std::int64_t id;
-
- /**
- * @brief Poll question, 1-255 characters.
- */
- std::string question;
-
- /**
- * @brief List of poll options.
- */
- std::vector<PollOption::Ptr> options;
-
- /**
- * @brief True, if the poll is closed.
- */
- bool isClosed;
- };
+ * Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot.
+ */
+ std::int32_t correctOptionId;
+};
}
#endif //TGBOT_POLL_H
diff --git a/include/tgbot/types/PollAnswer.h b/include/tgbot/types/PollAnswer.h
new file mode 100644
index 0000000..730248b
--- /dev/null
+++ b/include/tgbot/types/PollAnswer.h
@@ -0,0 +1,39 @@
+#ifndef TGBOT_CPP_POLLANSWER_H
+#define TGBOT_CPP_POLLANSWER_H
+
+#include "tgbot/types/User.h"
+
+#include <string>
+#include <memory>
+#include <vector>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents an answer of a user in a non-anonymous poll.
+ *
+ * @ingroup types
+ */
+class PollAnswer {
+
+public:
+ typedef std::shared_ptr<PollAnswer> Ptr;
+
+ /**
+ * @brief Unique poll identifier
+ */
+ std::string pollId;
+
+ /**
+ * @brief The user, who changed the answer to the poll
+ */
+ User::Ptr user;
+
+ /**
+ * @brief 0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote.
+ */
+ std::vector<std::int32_t> optionIds;
+};
+}
+
+#endif //TGBOT_CPP_POLLANSWER_H
diff --git a/include/tgbot/types/Update.h b/include/tgbot/types/Update.h
index 328ba2a..a80bd4e 100644
--- a/include/tgbot/types/Update.h
+++ b/include/tgbot/types/Update.h
@@ -8,6 +8,7 @@
#include "tgbot/types/ShippingQuery.h"
#include "tgbot/types/PreCheckoutQuery.h"
#include "tgbot/types/Poll.h"
+#include "tgbot/types/PollAnswer.h"
#include <cstdint>
#include <memory>
@@ -84,8 +85,14 @@ public:
* Bots receive only updates about stopped polls and polls, which are sent by the bot
*/
Poll::Ptr poll;
-};
+ /**
+ * @brief Optional. A user changed their answer in a non-anonymous poll.
+ *
+ * Bots receive new votes only in polls that were sent by the bot itself.
+ */
+ PollAnswer::Ptr pollAnswer;
+};
}
#endif //TGBOT_CPP_UPDATE_H
diff --git a/include/tgbot/types/User.h b/include/tgbot/types/User.h
index da1024d..7c7ceaf 100644
--- a/include/tgbot/types/User.h
+++ b/include/tgbot/types/User.h
@@ -18,7 +18,7 @@ public:
typedef std::shared_ptr<User> Ptr;
/**
- * @brief Unique identifier for this user or bot.
+ * @brief Unique identifier for this user or bot
*/
std::int64_t id;
@@ -28,24 +28,39 @@ public:
bool isBot = false;
/**
- * @brief User‘s or bot’s first name.
+ * @brief User‘s or bot’s first name
*/
std::string firstName;
/**
- * @brief Optional. User‘s or bot’s last name.
+ * @brief Optional. User‘s or bot’s last name
*/
std::string lastName;
/**
- * @brief Optional. User‘s or bot’s username.
+ * @brief Optional. User‘s or bot’s username
*/
std::string username;
/**
- * @brief Optional. IETF language tag of the user's language.
+ * @brief Optional. IETF language tag of the user's language
*/
std::string languageCode;
+
+ /**
+ * @brief Optional. True, if the bot can be invited to groups. Returned only in getMe.
+ */
+ bool canJoinGroups;
+
+ /**
+ * @brief Optional. True, if privacy mode is disabled for the bot. Returned only in getMe.
+ */
+ bool canReadAllGroupMessages;
+
+ /**
+ * @brief Optional. True, if the bot supports inline queries. Returned only in getMe.
+ */
+ bool supportsInlineQueries;
};
}