diff options
author | nitanmarcel <nitan.marcel@protonmail.com> | 2019-11-20 21:04:11 +0200 |
---|---|---|
committer | nitanmarcel <nitan.marcel@protonmail.com> | 2019-11-20 21:04:11 +0200 |
commit | 084a6492103eff0d021562694c6869fdcce58261 (patch) | |
tree | bc02cd95b2541f969276e45adcfcb073299138b6 /include | |
parent | ae758af7e7e4257f33040fea82529aca4c92fe05 (diff) |
API 4.4
Diffstat (limited to 'include')
-rw-r--r-- | include/tgbot/Api.h | 11 | ||||
-rw-r--r-- | include/tgbot/TgTypeParser.h | 4 | ||||
-rw-r--r-- | include/tgbot/types/Chat.h | 7 | ||||
-rw-r--r-- | include/tgbot/types/ChatMember.h | 5 | ||||
-rw-r--r-- | include/tgbot/types/ChatPermissions.h | 86 | ||||
-rw-r--r-- | include/tgbot/types/Sticker.h | 5 | ||||
-rw-r--r-- | include/tgbot/types/StickerSet.h | 5 |
7 files changed, 121 insertions, 2 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index 184f3a1..4ce8dd7 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -679,8 +679,7 @@ public: * @param canAddWebPagePreviews Optional. Pass True, if the user may add web page previews to their messages, implies can_send_media_messages. * @return True on success */ - bool restrictChatMember(int64_t chatId, int32_t userId, uint64_t untilDate = 0, bool canSendMessages = false, - bool canSendMediaMessages = false, bool canSendOtherMessages = false, bool canAddWebPagePreviews = false) const; + bool restrictChatMember(int64_t chatId, int32_t userId, ChatPermissions::Ptr permissions, uint64_t untilDate = 0) const; /** * @brief Use this method to promote or demote a user in a supergroup or a channel. @@ -700,6 +699,14 @@ 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 + */ + bool setChatPermissions(int64_t chatId, ChatPermissions::Ptr permissions) const; + + /** * @brief Use this method to generate a new invite link for a chat; any previously generated link is revoked. * @param chatId Unique identifier for the target chat. * @return The new invite link as String on success. diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h index a2cb660..aa0cd10 100644 --- a/include/tgbot/TgTypeParser.h +++ b/include/tgbot/TgTypeParser.h @@ -38,6 +38,7 @@ #include "tgbot/types/StickerSet.h" #include "tgbot/types/Poll.h" #include "tgbot/types/PollOption.h" +#include "tgbot/types/ChatPermissions.h" #include "tgbot/types/MaskPosition.h" #include "tgbot/types/Video.h" #include "tgbot/types/Voice.h" @@ -153,6 +154,9 @@ namespace TgBot { PollOption::Ptr parseJsonAndGetPollOption(const boost::property_tree::ptree& data) const; std::string parsePollOption(const PollOption::Ptr& object) const; + ChatPermissions::Ptr parseJsonAndGetChatPermissions(const boost::property_tree::ptree& data) const; + std::string parseChatPermissions(const ChatPermissions::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/Chat.h b/include/tgbot/types/Chat.h index a402ebb..eb38ec7 100644 --- a/include/tgbot/types/Chat.h +++ b/include/tgbot/types/Chat.h @@ -27,6 +27,7 @@ #include <memory> #include "tgbot/types/ChatPhoto.h" +#include "tgbot/types/ChatPermissions.h" namespace TgBot { @@ -111,6 +112,12 @@ public: std::shared_ptr<Message> pinnedMessage; /** + * @brief Optional. Default chat member permissions, for groups and supergroups. + * Returned only in getChat. + */ + ChatPermissions::Ptr permissions; + + /** * @brief Optional. For supergroups, name of group sticker set. * Returned only in getChat. */ diff --git a/include/tgbot/types/ChatMember.h b/include/tgbot/types/ChatMember.h index 79fff0e..f5e5acd 100644 --- a/include/tgbot/types/ChatMember.h +++ b/include/tgbot/types/ChatMember.h @@ -102,6 +102,11 @@ public: bool canSendOtherMessages = false; /** + * @brief Optional. Restricted only. True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages. + */ + bool canSendPolls = false; + + /** * @brief Optional. Restricted only. True, if user may add web page previews to his messages, implies can_send_media_messages. */ bool canAddWebPagePreviews = false; diff --git a/include/tgbot/types/ChatPermissions.h b/include/tgbot/types/ChatPermissions.h new file mode 100644 index 0000000..8db32e6 --- /dev/null +++ b/include/tgbot/types/ChatPermissions.h @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2019 Marcel Alexandru + * + * 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_CPP_CHATPERMISSIONS_H +#define TGBOT_CPP_CHATPERMISSIONS_H + +#include <memory> +#include <string> + + +namespace TgBot { + + /** + * @brief This object describes actions that a non-administrator user is allowed to take in a chat. + * @ingroup types + */ + + class ChatPermissions { + public: + typedef std::shared_ptr<ChatPermissions> Ptr; + + /** + * @brief Optional. True, if the user is allowed to send text messages, contacts, locations and venues. + */ + bool canSendMessages = false; + + /** + * @brief Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages. + */ + bool canSendMediaMessages = false; + + /** + * @brief Optional. True, if the user is allowed to send polls, implies can_send_messages. + */ + bool canSendPolls = false; + + /** + * @brief Optional. True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages. + */ + bool canSendOtherMessages = false; + + /** + * @brief Optional. True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages. + */ + bool canAddWebPagePreviews = false; + + /** + * @brief Optional. True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups. + */ + bool canChangeInfo = false; + + /** + * @brief Optional. True, if the user is allowed to invite new users to the chat. + */ + bool canInviteUsers = false; + + /** + * @brief Optional. True, if the user is allowed to pin messages. Ignored in public supergroups. + */ + bool canPinMessages = false; + + + + }; +} + +#endif //TGBOT_CPP_CHATPERMISSIONS_H diff --git a/include/tgbot/types/Sticker.h b/include/tgbot/types/Sticker.h index 9fd200a..68fc574 100644 --- a/include/tgbot/types/Sticker.h +++ b/include/tgbot/types/Sticker.h @@ -57,6 +57,11 @@ public: int32_t height; /** + * @brief True, if the sticker is animated. + */ + bool isAnimated = false; + + /** * @brief Optional. Optional. Sticker thumbnail in .webp or .jpg format. */ PhotoSize::Ptr thumb; diff --git a/include/tgbot/types/StickerSet.h b/include/tgbot/types/StickerSet.h index d08fd4a..deddf74 100644 --- a/include/tgbot/types/StickerSet.h +++ b/include/tgbot/types/StickerSet.h @@ -52,6 +52,11 @@ public: std::string title; /** + * @brief True, if the sticker set contains animated stickers. + */ + bool isAnimated = false; + + /** * @brief True, if the sticker set contains masks. */ bool containsMasks = false; |