summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJellyBrick <shlee1503@naver.com>2018-05-27 16:35:52 +0900
committerJellyBrick <shlee1503@naver.com>2018-05-27 16:35:52 +0900
commit1deb50e9db6e1b668af8c993b449d59f001c8977 (patch)
treeb341aff55cbccf3d695dc967b12b1dc17b8271f6 /include
parentfbdbc4d5d3cd61086500d2406f3345da55627a56 (diff)
Bot API 3.1 update
Diffstat (limited to 'include')
-rw-r--r--include/tgbot/Api.h94
-rw-r--r--include/tgbot/TgTypeParser.h3
-rw-r--r--include/tgbot/types/Chat.h41
-rw-r--r--include/tgbot/types/ChatMember.h73
-rw-r--r--include/tgbot/types/ChatPhoto.h52
5 files changed, 259 insertions, 4 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index 10cc91e..5750a83 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -493,15 +493,16 @@ public:
* @return True on success
*/
bool answerInlineQuery(const std::string& inlineQueryId, const std::vector<InlineQueryResult::Ptr>& results,
- int32_t cacheTime=300, bool isPersonal=false, const std::string& nextOffset="", const std::string& switchPmText="", const std::string& switchPmParameter="") const;
+ int32_t cacheTime = 300, bool isPersonal = false, const std::string& nextOffset = "", const std::string& switchPmText = "", const std::string& switchPmParameter = "") const;
/**
* Use this method to kick a user from a group or a supergroup.
* @param chatId Unique identifier for the target group.
* @param userId Unique identifier of the target user.
+ * @param untilDate Optional. Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever.
* @return True on success
*/
- bool kickChatMember(int64_t chatId, int32_t userId) const;
+ bool kickChatMember(int64_t chatId, int32_t userId, uint64_t untilDate = 0) const;
/**
* Use this method to unban a previously kicked user in a supergroup.
@@ -512,6 +513,95 @@ public:
bool unbanChatMember(int64_t chatId, int32_t userId) const;
/**
+ * Use this method to restrict a user in a supergroup.
+ * @param chatId Unique identifier for the target chat of the target supergroup.
+ * @param userId Unique identifier of the target user.
+ * @param untilDate Optional. Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever.
+ * @param canSendMessages Optional. Pass True, if the user can send text messages, contacts, locations and venues.
+ * @param canSendMediaMessages Optional. Pass True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages.
+ * @param canSendOtherMessages Optional. Pass True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages.
+ * @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;
+
+ /**
+ * Use this method to promote or demote a user in a supergroup or a channel.
+ * @param chatId Unique identifier for the target chat of the target supergroup or channal.
+ * @param userId Unique identifier of the target user.
+ * @param canChangeInfo Optional. Pass True, if the administrator can change chat title, photo and other settings.
+ * @param canPostMessages Optional. Pass True, if the administrator can create channel posts, channels only.
+ * @param canEditMessages Optional. Pass True, if the administrator can edit messages of other users and can pin messages, channels only.
+ * @param canDeleteMessages Optional. Pass True, if the administrator can delete messages of other users.
+ * @param canInviteUsers Optional. Pass True, if the administrator can invite new users to the chat.
+ * @param canRestrictMembers Optional. Pass True, if the administrator can restrict, ban or unban chat members.
+ * @param canPinMessages Optional. Pass True, if the administrator can pin messages, supergroups only.
+ * @param canPromoteMembers Optional. Pass 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 him).
+ * @return True on success
+ */
+ bool promoteChatMember(int64_t chatId, int32_t userId, bool canChangeInfo = false, bool canPostMessages = false,
+ bool canEditMessages = false, bool canDeleteMessages = false, bool canInviteUsers = false, bool canPinMessages = false, bool canPromoteMembers = false) const;
+
+ /**
+ * 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.
+ */
+ std::string exportChatInviteLink(int64_t chatId) const;
+
+ /**
+ * Use this method to set a new profile photo for the chat.
+ * Photos can't be changed for private chats.
+ * @param chatId Unique identifier for the target chat.
+ * @param photo New chat photo.
+ * @return True on success
+ */
+ bool setChatPhoto(int64_t chatId, InputFile::Ptr photo) const;
+
+ /**
+ * Use this method to delete a chat photo.
+ * Photos can't be changed for private chats.
+ * @param chatId Unique identifier for the target chat.
+ * @return True on success
+ */
+ bool deleteChatPhoto(int64_t chatId) const;
+
+ /**
+ * Use this method to change the title of a chat.
+ * Titles can't be changed for private chats.
+ * @param chatId Unique identifier for the target chat.
+ * @param title New chat title, 1-255 characters.
+ * @return True on success
+ */
+ bool setChatTitle(int64_t chatId, std::string title) const;
+
+ /**
+ * Use this method to change the description of a supergroup or a channel.
+ * @param chatId Unique identifier for the target chat.
+ * @param description New chat description, 1-255 characters.
+ * @return True on success
+ */
+ bool setChatDescription(int64_t chatId, std::string description) const;
+
+ /**
+ * Use this method to pin a message in a supergroup or a channel.
+ * @param chatId Unique identifier for the target chat.
+ * @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
+ */
+ bool pinChatMessage(int64_t chatId, int32_t messageId, bool disableNotification = false) const;
+
+ /**
+ * Use this method to unpin a message in a supergroup or a channel.
+ * @param chatId Unique identifier for the target chat.
+ * @return True on success
+ */
+ bool unpinChatMessage(int64_t chatId) const;
+
+
+ /**
* Downloads file from Telegram and saves it in memory.
* @param filePath Telegram file path.
* @param args Additional api parameters.
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index bfae9aa..0aea80b 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -47,6 +47,7 @@
#include "tgbot/types/ReplyKeyboardRemove.h"
#include "tgbot/types/ForceReply.h"
#include "tgbot/types/ChatMember.h"
+#include "tgbot/types/ChatPhoto.h"
#include "tgbot/types/ResponseParameters.h"
#include "tgbot/types/GenericReply.h"
#include "tgbot/types/InlineQuery.h"
@@ -149,6 +150,8 @@ public:
ChatMember::Ptr parseJsonAndGetChatMember(const boost::property_tree::ptree& data) const;
std::string parseChatMember(const ChatMember::Ptr& object) const;
+ ChatPhoto::Ptr parseJsonAndGetChatPhoto(const boost::property_tree::ptree& data) const; // returned only in getChat
+
ResponseParameters::Ptr parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const;
std::string parseResponseParameters(const ResponseParameters::Ptr& object) const;
diff --git a/include/tgbot/types/Chat.h b/include/tgbot/types/Chat.h
index 698b95f..d286a63 100644
--- a/include/tgbot/types/Chat.h
+++ b/include/tgbot/types/Chat.h
@@ -26,6 +26,9 @@
#include <string>
#include <memory>
+#include "tgbot/types/ChatPhoto.h"
+#include "tgbot/types/Message.h"
+
namespace TgBot {
/**
@@ -79,9 +82,45 @@ public:
/**
* Optional. True if a group
- * has �All Members Are Admins� enabled.
+ * has ‘All Members Are Admins’ enabled.
*/
bool allMembersAreAdministrators;
+
+ /**
+ * Optional. Chat photo.
+ * Returned only in getChat.
+ */
+ ChatPhoto::Ptr photo;
+
+ /**
+ * Optional. Description, for supergroups and channel chats.
+ * Returned only in getChat.
+ */
+ std::string description;
+
+ /**
+ * Optional. Chat invite link, for supergroups and channel chats.
+ * Returned only in getChat.
+ */
+ std::string inviteLink;
+
+ /**
+ * Optional. Pinned message, for supergroups and channel chats.
+ * Returned only in getChat.
+ */
+ Message::Ptr pinnedMessage;
+
+ /**
+ * Optional. For supergroups, name of group sticker set.
+ * Returned only in getChat.
+ */
+ std::string stickerSetName;
+
+ /**
+ * Optional. True, if the bot can change the group sticker set.
+ * Returned only in getChat.
+ */
+ bool canSetStickerSet;
};
}
diff --git a/include/tgbot/types/ChatMember.h b/include/tgbot/types/ChatMember.h
index 7f4b139..a77e23a 100644
--- a/include/tgbot/types/ChatMember.h
+++ b/include/tgbot/types/ChatMember.h
@@ -1,5 +1,6 @@
//
// Created by Konstantin Kukin on 26/12/16.
+// Edit by JellyBrick on 27/05/18.
//
#ifndef TGBOT_CHATMEMBER_H
@@ -26,9 +27,79 @@ public:
User::Ptr user;
/**
- * The member's status in the chat. Can be creator, administrator, member, left or kicked
+ * The member's status in the chat. Can be “creator”, “administrator”, “member”, “restricted”, “left” or “kicked”
*/
std::string status;
+
+ /**
+ * Optional. Restricted and kicked only. Date when restrictions will be lifted for this user, unix time.
+ */
+ uint64_t untilDate;
+
+ /**
+ * Optional. Administrators only. True, if the bot is allowed to edit administrator privileges of that user.
+ */
+ bool canBeEdited = false;
+
+ /**
+ * Optional. Administrators only. True, if the administrator can change the chat title, photo and other settings.
+ */
+ bool canChangeInfo = false;
+
+ /**
+ * Optional. Administrators only. True, if the administrator can post in the channel, channels only.
+ */
+ bool canPostMessages = false;
+
+ /**
+ * Optional. Administrators only. True, if the administrator can edit messages of other users and can pin messages, channels only.
+ */
+ bool canEditMessages = false;
+
+ /**
+ * Optional. Administrators only. True, if the administrator can delete messages of other users.
+ */
+ bool canDeleteMessages = false;
+
+ /**
+ * Optional. Administrators only. True, if the administrator can invite new users to the chat.
+ */
+ bool canInviteUsers = false;
+
+ /**
+ * Optional. Administrators only. True, if the administrator can restrict, ban or unban chat members.
+ */
+ bool canRestrictMembers = false;
+
+ /**
+ * Optional. Administrators only. True, if the administrator can pin messages, supergroups only.
+ */
+ bool canPinMessages = false;
+
+ /**
+ * 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;
+
+ /**
+ * Optional. Restricted only. True, if the user can send text messages, contacts, locations and venues.
+ */
+ bool canSendMessages = false;
+
+ /**
+ * Optional. Restricted only. True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages.
+ */
+ bool canSendMediaMessages = false;
+
+ /**
+ * Optional. Restricted only. True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages.
+ */
+ bool canSendOtherMessages = false;
+
+ /**
+ * 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/ChatPhoto.h b/include/tgbot/types/ChatPhoto.h
new file mode 100644
index 0000000..9469d2e
--- /dev/null
+++ b/include/tgbot/types/ChatPhoto.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2015 Oleg Morozenkov
+ * Copyright (c) 2018 JellyBrick
+ *
+ * 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_CHATPHOTO_H
+#define TGBOT_CHATPHOTO_H
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * This object represents a chat photo.
+ * @ingroup types
+ */
+class ChatPhoto {
+public:
+ typedef std::shared_ptr<ChatPhoto> Ptr;
+
+ /**
+ * Unique file identifier of small (160x160) chat photo. This file_id can be used only for photo download.
+ */
+ std::string smallFileId;
+
+ /**
+ * Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download.
+ */
+ std::string bigFileId;
+};
+}
+
+#endif //TGBOT_CHATPHOTO_H \ No newline at end of file