diff options
author | Oleg Morozenkov <m@oleg.rocks> | 2022-08-30 02:04:15 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-30 02:04:15 +0300 |
commit | 8651e22a472a1b740aee5fd6c8b243425c9498c8 (patch) | |
tree | fb14421e54a844bb9b698b5049339323085de343 /include/tgbot/Api.h | |
parent | 336a7c5c4243128afd54133b5e0dfeb9661fb7c2 (diff) | |
parent | 76a362631705d9adcc2709e6d8f9b327112ae306 (diff) |
Merge pull request #220 from llnulldisk/master
Update to API 4.6
Diffstat (limited to 'include/tgbot/Api.h')
-rw-r--r-- | include/tgbot/Api.h | 102 |
1 files changed, 70 insertions, 32 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index cc18807..18165d1 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -67,7 +67,7 @@ public: */ Message::Ptr sendMessage(std::int64_t chatId, const std::string& text, bool disableWebPagePreview = false, std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; - + Message::Ptr sendMessage(const std::string& chatId, const std::string& text, bool disableWebPagePreview = false, std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const; @@ -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. @@ -682,11 +695,20 @@ public: bool canEditMessages = false, bool canDeleteMessages = false, bool canInviteUsers = false, bool canPinMessages = false, bool canPromoteMembers = false) const; /** - * @brief Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members admin rights. Returns True on success. - * @param chatId Unique identifier for the target chat of the target supergroup. - * @param permissions New default chat permissions. - * @return True on success - */ + * @brief Use this method to set a custom title for an administrator in a supergroup promoted by the bot. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param userId Unique identifier of the target user + * @param customTitle New custom title for the administrator; 0-16 characters, emoji are not allowed + * @return True on success + */ + bool setChatAdministratorCustomTitle(std::int64_t chatId, std::int64_t userId, const std::string& customTitle) const; + + /** + * @brief Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members admin rights. Returns True on success. + * @param chatId Unique identifier for the target chat of the target supergroup. + * @param permissions New default chat permissions. + * @return True on success + */ bool setChatPermissions(std::int64_t chatId, ChatPermissions::Ptr permissions) const; /** @@ -792,17 +814,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 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>(), bool isAnonymous = true, const std::string& type = "", bool allowsMultipleAnswers = false, + 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 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 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. |