summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorllnulldisk <48621230+llnulldisk@users.noreply.github.com>2022-08-30 00:25:15 +0200
committerllnulldisk <48621230+llnulldisk@users.noreply.github.com>2022-08-30 00:25:15 +0200
commit76a362631705d9adcc2709e6d8f9b327112ae306 (patch)
treefb14421e54a844bb9b698b5049339323085de343 /include
parented5065b35911a6d7d3dff30bd80600cc593901a3 (diff)
Update to API 4.7
Diffstat (limited to 'include')
-rw-r--r--include/tgbot/Api.h57
-rw-r--r--include/tgbot/TgTypeParser.h7
-rw-r--r--include/tgbot/types/Chat.h2
-rw-r--r--include/tgbot/types/Dice.h25
-rw-r--r--include/tgbot/types/Message.h121
-rw-r--r--include/tgbot/types/StickerSet.h18
-rw-r--r--include/tgbot/types/Venue.h8
7 files changed, 166 insertions, 72 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index 517c8fe..18165d1 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -218,30 +218,34 @@ public:
File::Ptr uploadStickerFile(std::int64_t userId, InputFile::Ptr pngSticker) const;
/**
- * @brief 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.
+ * @brief Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. You must use exactly one of the fields pngSticker or tgsSticker.
+ * @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.
+ * @param title Sticker set title, 1-64 characters
+ * @param emojis One or more emoji corresponding to the sticker
+ * @param pngSticker Optional. 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, or upload a new one using multipart/form-data.
+ * @param tgsSticker Optional. TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
+ * @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(std::int64_t userId, const std::string& name, const std::string& title,
- boost::variant<InputFile::Ptr, std::string> pngSticker, const std::string& emojis, bool containsMasks = false, MaskPosition::Ptr maskPosition = nullptr) const;
+ bool createNewStickerSet(std::int64_t userId, const std::string& name, const std::string& title, const std::string& emojis,
+ boost::variant<InputFile::Ptr, std::string> pngSticker = "", boost::variant<InputFile::Ptr, std::string> tgsSticker = "",
+ bool containsMasks = false, MaskPosition::Ptr maskPosition = nullptr) const;
/**
- * @brief 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 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.
+ * @brief Use this method to add a new sticker to a set created by the bot. You must use exactly one of the fields png_sticker or tgs_sticker. Animated stickers can be added to animated sticker sets and only to them. Animated sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers.
+ * @param userId User identifier of sticker set owner
+ * @param name Sticker set name
+ * @param emojis One or more emoji corresponding to the sticker
+ * @param pngSticker Optional. 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, or upload a new one using multipart/form-data.
+ * @param tgsSticker Optional. TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
+ * @param maskPosition Optional. A JSON-serialized object for position where the mask should be placed on faces
* @return Returns True on success.
*/
- bool addStickerToSet(std::int64_t userId, const std::string& name,
- boost::variant<InputFile::Ptr, std::string> pngSticker, const std::string& emojis, MaskPosition::Ptr maskPosition = nullptr) const;
+ bool addStickerToSet(std::int64_t userId, const std::string& name, const std::string& emojis,
+ boost::variant<InputFile::Ptr, std::string> pngSticker = "", boost::variant<InputFile::Ptr, std::string> tgsSticker = "",
+ MaskPosition::Ptr maskPosition = nullptr) const;
/**
* @brief Use this method to move a sticker in a set created by the bot to a specific position.
@@ -259,6 +263,15 @@ public:
bool deleteStickerFromSet(const std::string& sticker) const;
/**
+ * @brief Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only.
+ * @param name Sticker set name
+ * @param userId User identifier of the sticker set owner
+ * @param thumb Optional. A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/animated_stickers#technical-requirements for animated sticker technical requirements. 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, or upload a new one using multipart/form-data. Animated sticker set thumbnail can't be uploaded via HTTP URL.
+ * @return Returns True on success.
+ */
+ bool setStickerSetThumb(const std::string& name, std::int64_t userId, boost::variant<InputFile::Ptr, std::string> thumb = "") const;
+
+ /**
* @brief 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.
@@ -820,6 +833,16 @@ public:
std::int32_t correctOptionId = 0, bool isClosed = false) const;
/**
+ * @brief Use this method to send a dice, which will have a random value from 1 to 6.
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @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.
+ * @return On success, the sent message is returned.
+ */
+ Message::Ptr sendDice(std::int64_t chatId, bool disableNotification = false, std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
+
+ /**
* @brief Use this method to stop a poll which was sent by the bot.
* @param chatId Unique identifier for the target chat or username of the target channel.
* @param messageId Identifier of the original message with the poll.
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index 1c43297..a5f1511 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/Dice.h"
#include "tgbot/types/PollAnswer.h"
#include "tgbot/types/PollOption.h"
#include "tgbot/types/ChatPermissions.h"
@@ -137,6 +138,9 @@ public:
Poll::Ptr parseJsonAndGetPoll(const boost::property_tree::ptree& data) const;
std::string parsePoll(const Poll::Ptr& object) const;
+ Dice::Ptr parseJsonAndGetDice(const boost::property_tree::ptree& data) const;
+ std::string parseDice(const Dice::Ptr& object) const;
+
PollAnswer::Ptr parseJsonAndGetPollAnswer(const boost::property_tree::ptree& data) const;
std::string parsePollAnswer(const PollAnswer::Ptr& object) const;
@@ -170,6 +174,9 @@ public:
Location::Ptr parseJsonAndGetLocation(const boost::property_tree::ptree& data) const;
std::string parseLocation(const Location::Ptr& object) const;
+ Venue::Ptr parseJsonAndGetVenue(const boost::property_tree::ptree& data) const;
+ std::string parseVenue(const Venue::Ptr& object) const;
+
Update::Ptr parseJsonAndGetUpdate(const boost::property_tree::ptree& data) const;
std::string parseUpdate(const Update::Ptr& object) const;
diff --git a/include/tgbot/types/Chat.h b/include/tgbot/types/Chat.h
index 4074643..d70aa4b 100644
--- a/include/tgbot/types/Chat.h
+++ b/include/tgbot/types/Chat.h
@@ -62,7 +62,7 @@ public:
std::string lastName;
/**
- * @brief Deprecated since API 4.4. New bots should use the permissions field instead.
+ * @brief Deprecated since Bot API 4.4. New bots should use the permissions field instead.
*
* Optional. True if a group has ‘All Members Are Admins’ enabled.
*/
diff --git a/include/tgbot/types/Dice.h b/include/tgbot/types/Dice.h
new file mode 100644
index 0000000..ec874e0
--- /dev/null
+++ b/include/tgbot/types/Dice.h
@@ -0,0 +1,25 @@
+#ifndef TGBOT_CPP_DICE_H
+#define TGBOT_CPP_DICE_H
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents a dice with random value from 1 to 6.
+ *
+ * @ingroup types
+ */
+class Dice {
+
+public:
+ typedef std::shared_ptr<Dice> Ptr;
+
+ /**
+ * @brief Value of the dice, 1-6
+ */
+ std::int8_t value;
+};
+}
+
+#endif //TGBOT_CPP_DICE_H
diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h
index 700f5d1..d34fa0d 100644
--- a/include/tgbot/types/Message.h
+++ b/include/tgbot/types/Message.h
@@ -9,6 +9,7 @@
#include "tgbot/types/Animation.h"
#include "tgbot/types/Sticker.h"
#include "tgbot/types/Poll.h"
+#include "tgbot/types/Dice.h"
#include "tgbot/types/Video.h"
#include "tgbot/types/Contact.h"
#include "tgbot/types/Location.h"
@@ -17,6 +18,7 @@
#include "tgbot/types/MessageEntity.h"
#include "tgbot/types/Venue.h"
#include "tgbot/types/Voice.h"
+#include "tgbot/types/VideoNote.h"
#include "tgbot/types/Invoice.h"
#include "tgbot/types/SuccessfulPayment.h"
#include "tgbot/types/InlineKeyboardMarkup.h"
@@ -38,77 +40,84 @@ public:
typedef std::shared_ptr<Message> Ptr;
/**
- * @brief Unique message identifier.
+ * @brief Unique message identifier inside this chat
*/
std::int32_t messageId;
/**
- * @brief Optional. Sender, can be empty for messages sent to channels.
+ * @brief Optional. Sender, empty for messages sent to channels
*/
User::Ptr from;
/**
- * @brief Date the message was sent in Unix time.
+ * @brief Date the message was sent in Unix time
*/
std::int32_t date;
/**
- * @brief Conversation the message belongs to.
+ * @brief Conversation the message belongs to
*/
Chat::Ptr chat;
/**
- * @brief Optional. For forwarded messages, sender of the original message.
+ * @brief Optional. For forwarded messages, sender of the original message
*/
User::Ptr forwardFrom;
/**
- * @brief Optional. For messages forwarded from a channel, information about the original channel
+ * @brief Optional. For messages forwarded from channels, information about the original channel
*/
Chat::Ptr forwardFromChat;
/**
- * @brief Optional. For forwarded channel posts, identifier of the original message in the channel
+ * @brief Optional. For messages forwarded from channels, identifier of the original message in the channel
*/
std::int32_t forwardFromMessageId;
/**
- * @brief Optional. For messages forwarded from channels, signature of the post author if present.
+ * @brief Optional. For messages forwarded from channels, signature of the post author if present
*/
std::string forwardSignature;
/**
- * @brief Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages.
+ * @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.
+ * @brief Optional. For forwarded messages, date the original message was sent in Unix time
*/
std::int32_t forwardDate;
/**
- * @brief Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.
+ * @brief Optional. For replies, the original message.
+ *
+ * Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.
*/
Message::Ptr replyToMessage;
/**
- * @brief Optional. Date the message was last edited in Unix time.
+ * @brief Optional. Date the message was last edited in Unix time
*/
std::int32_t editDate;
/**
- * @brief Optional. Signature of the post author for messages in channels.
+ * @brief Optional. The unique identifier of a media message group this message belongs to
+ */
+ std::string mediaGroupId;
+
+ /**
+ * @brief Optional. Signature of the post author for messages in channels
*/
std::string authorSignature;
/**
- * @brief Optional. For text messages, the actual UTF-8 text of the message.
+ * @brief Optional. For text messages, the actual UTF-8 text of the message, 0-4096 characters
*/
std::string text;
/**
- * @brief Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text.
+ * @brief Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text
*/
std::vector<MessageEntity::Ptr> entities;
@@ -118,74 +127,86 @@ public:
std::vector<MessageEntity::Ptr> captionEntities;
/**
- * @brief Optional. Message is an audio file, information about the file.
+ * @brief Optional. Message is an audio file, information about the file
*/
Audio::Ptr audio;
/**
- * @brief Optional. Message is a general file, information about the file.
+ * @brief Optional. Message is a general file, information about the file
*/
Document::Ptr document;
/**
* @brief Optional. Message is an animation, information about the animation.
*
- * For backward compatibility, when this field is set, the document field will also be set.
+ * For backward compatibility, when this field is set, the document field will also be set
*/
Animation::Ptr animation;
/**
- * @brief Optional. Message is a game, information about the game.
+ * @brief Optional. Message is a game, information about the game
*/
Game::Ptr game;
/**
- * @brief Optional. Message is a photo, available sizes of the photo.
+ * @brief Optional. Message is a photo, available sizes of the photo
*/
std::vector<PhotoSize::Ptr> photo;
/**
- * @brief Optional. Message is a sticker, information about the sticker.
+ * @brief Optional. Message is a sticker, information about the sticker
*/
Sticker::Ptr sticker;
/**
- * @brief Optional. Message is a video, information about the video.
+ * @brief Optional. Message is a video, information about the video
*/
Video::Ptr video;
/**
- * @brief Optional. Message is a voice message, information about the file.
+ * @brief Optional. Message is a voice message, information about the file
*/
Voice::Ptr voice;
/**
- * @brief Optional. Caption for the document, photo or video, 0-200 characters.
+ * @brief Optional. Message is a video note, information about the video message
+ */
+ VideoNote::Ptr videoNote;
+
+ /**
+ * @brief Optional. Caption for the animation, audio, document, photo, video or voice, 0-1024 characters
*/
std::string caption;
/**
- * @brief Optional. Message is a shared contact, information about the contact.
+ * @brief Optional. Message is a shared contact, information about the contact
*/
Contact::Ptr contact;
/**
- * @brief Optional. Message is a shared location, information about the location.
+ * @brief Optional. Message is a shared location, information about the location
*/
Location::Ptr location;
/**
- * @brief Optional. Message is a venue, information about the venue.
+ * @brief Optional. Message is a venue, information about the venue
*/
Venue::Ptr venue;
/**
- * @brief Optional. Message is a poll, information about the poll.
+ * @brief Optional. Message is a native 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).
+ * @brief Optional. Message is a dice with random value from 1 to 6
+ */
+ Dice::Ptr dice;
+
+ /**
+ * @brief Deprecated since Bot API 3.0. The field is replaced with newChatMembers.
+ *
+ * Optional. A new member was added to the group, information about them (this member may be the bot itself)
*/
User::Ptr newChatMember;
@@ -195,81 +216,93 @@ public:
std::vector<User::Ptr> newChatMembers;
/**
- * @brief Optional. A member was removed from the group, information about them (this member may be bot itself).
+ * @brief Optional. A member was removed from the group, information about them (this member may be the bot itself)
*/
User::Ptr leftChatMember;
/**
- * @brief Optional. A group title was changed to this value.
+ * @brief Optional. A chat title was changed to this value
*/
std::string newChatTitle;
/**
- * @brief Optional. A group photo was change to this value.
+ * @brief Optional. A chat photo was change to this value
*/
std::vector<PhotoSize::Ptr> newChatPhoto;
/**
- * @brief Optional. Informs that the group photo was deleted.
+ * @brief Optional. Service message: the chat photo was deleted
*/
bool deleteChatPhoto = false;
/**
- * @brief Optional. Informs that the group has been created.
+ * @brief Optional. Service message: the group has been created
*/
bool groupChatCreated = false;
/**
- * @brief Optional. Service message: the supergroup has been created.
+ * @brief Optional. Service message: the supergroup has been created
*/
bool supergroupChatCreated = false;
/**
- * @brief Optional. Service message: the channel has been created.
+ * @brief Optional. Service message: the channel has been created
*/
bool channelChatCreated = false;
/**
- * @brief Optional. The group has been migrated to a supergroup with the specified identifier, not exceeding 1e13 by absolute value.
+ * @brief Optional. The group has been migrated to a supergroup with the specified identifier.
+ *
+ * This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
*/
std::int64_t migrateToChatId = 0;
/**
- * @brief Optional. The supergroup has been migrated from a group with the specified identifier, not exceeding 1e13 by absolute value
+ * @brief Optional. The supergroup has been migrated from a group with the specified identifier.
+ *
+ * This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
*/
std::int64_t migrateFromChatId = 0;
/**
- * @brief Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply.
+ * @brief Optional. Specified message was pinned.
+ *
+ * Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply.
*/
Message::Ptr pinnedMessage;
/**
- * @brief Optional. Message is an invoice for a payment, information about the invoice.
+ * @brief Optional. Message is an invoice for a payment, information about the invoice
*/
Invoice::Ptr invoice;
/**
- * @brief Optional. Message is a service message about a successful payment, information about the payment.
+ * @brief Optional. Message is a service message about a successful payment, information about the payment
*/
SuccessfulPayment::Ptr successfulPayment;
/**
- * @brief Optional. The domain name of the website on which the user has logged in.
+ * @brief Optional. The domain name of the website on which the user has logged in
*/
std::string connectedWebsite;
/**
+ * @brief Optional. Telegram Passport data
+ */
+ // TODO PassportData::Ptr passportData;
+
+ /**
* @brief Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons.
*/
InlineKeyboardMarkup::Ptr replyMarkup;
/**
- * @brief Optional. Message is automatically forwarded from bounded channel.
+ * @brief Optional. True, if the message is a channel post that was automatically forwarded to the connected discussion group
+ *
+ * Note: Added with Bot API 5.5
*/
bool automaticForward = false;
};
-
}
#endif //TGBOT_CPP_MESSAGE_H
diff --git a/include/tgbot/types/StickerSet.h b/include/tgbot/types/StickerSet.h
index a5c6c53..4b11cf3 100644
--- a/include/tgbot/types/StickerSet.h
+++ b/include/tgbot/types/StickerSet.h
@@ -2,6 +2,7 @@
#define TGBOT_STICKERSET_H
#include "tgbot/types/Sticker.h"
+#include "tgbot/types/PhotoSize.h"
#include <memory>
#include <string>
@@ -19,29 +20,34 @@ public:
typedef std::shared_ptr<StickerSet> Ptr;
/**
- * @brief Sticker set name.
+ * @brief Sticker set name
*/
std::string name;
/**
- * @brief Sticker set title.
+ * @brief Sticker set title
*/
std::string title;
/**
- * @brief True, if the sticker set contains animated stickers.
- */
+ * @brief True, if the sticker set contains animated stickers
+ */
bool isAnimated = false;
/**
- * @brief True, if the sticker set contains masks.
+ * @brief True, if the sticker set contains masks
*/
bool containsMasks = false;
/**
- * @brief List of all set stickers.
+ * @brief List of all set stickers
*/
std::vector<Sticker::Ptr> stickers;
+
+ /**
+ * @brief Optional. Sticker set thumbnail in the .WEBP or .TGS format
+ */
+ PhotoSize::Ptr thumb;
};
}
diff --git a/include/tgbot/types/Venue.h b/include/tgbot/types/Venue.h
index 9e1ff81..589b5cf 100644
--- a/include/tgbot/types/Venue.h
+++ b/include/tgbot/types/Venue.h
@@ -18,22 +18,22 @@ public:
typedef std::shared_ptr<Venue> Ptr;
/**
- * @brief Venue location.
+ * @brief Venue location
*/
Location::Ptr location;
/**
- * @brief Name of the venue.
+ * @brief Name of the venue
*/
std::string title;
/**
- * @brief Address of the venue.
+ * @brief Address of the venue
*/
std::string address;
/**
- * @brief Optional. Foursquare identifier of the venue.
+ * @brief Optional. Foursquare identifier of the venue
*/
std::string foursquareId;