summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tgbot/Api.h24
-rw-r--r--src/Api.cpp15
2 files changed, 28 insertions, 11 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index 4cf8a7d..cabcd2a 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -39,6 +39,7 @@
#include "tgbot/types/Venue.h"
#include "tgbot/types/WebhookInfo.h"
#include "tgbot/types/ChatMember.h"
+#include "tgbot/types/File.h"
namespace TgBot {
@@ -318,30 +319,37 @@ public:
UserProfilePhotos::Ptr getUserProfilePhotos(int32_t userId, int32_t offset = 0, int32_t limit = 100) const;
/**
+ * Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size.
+ * @param fileId File identifier to get info about
+ * @return A File object.
+ */
+ File::Ptr getFile(int32_t fileId) const;
+
+ /**
* Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success.
- * @param chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
+ * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
* @return Chat object.
*/
Chat::Ptr getChat(int32_t chatId) const;
/**
* Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
- * @param chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
+ * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
* @return ChatMember object.
*/
std::vector<ChatMember::Ptr> getChatAdministrators(int32_t chatId) const;
/**
* Use this method to get the number of members in a chat. Returns Int on success.
- * @param chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
+ * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
* @return Int.
*/
int32_t getChatMembersCount(int32_t chatId) const;
/**
* Use this method to get information about a member of a chat. Returns a ChatMember object on success.
- * @param chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
- * @param user_id Unique identifier of the target user
+ * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
+ * @param userId Unique identifier of the target user
* @return ChatMember object.
*/
ChatMember::Ptr getChatMember(int32_t chatId, int32_t userId) const;
@@ -397,15 +405,17 @@ public:
* 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.
+ * @return True on success
*/
- void kickChatMember(int64_t chatId, int32_t userId) const;
+ bool kickChatMember(int64_t chatId, int32_t userId) const;
/**
* Use this method to unban a previously kicked user in a supergroup.
* @param chatId Unique identifier for the target group.
* @param userId Unique identifier of the target user.
+ * @return True on success
*/
- void unbanChatMember(int64_t chatId, int32_t userId) const;
+ bool unbanChatMember(int64_t chatId, int32_t userId) const;
private:
boost::property_tree::ptree sendRequest(const std::string& method, const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>()) const;
diff --git a/src/Api.cpp b/src/Api.cpp
index 4b08f98..673f368 100644
--- a/src/Api.cpp
+++ b/src/Api.cpp
@@ -410,6 +410,13 @@ UserProfilePhotos::Ptr Api::getUserProfilePhotos(int32_t userId, int32_t offset,
return TgTypeParser::getInstance().parseJsonAndGetUserProfilePhotos(sendRequest("getUserProfilePhotos", args));
}
+File::Ptr Api::getFile(int32_t fileId) const
+{
+ vector<HttpReqArg> args;
+ args.push_back(HttpReqArg("file_id", fileId));
+ return TgTypeParser::getInstance().parseJsonAndGetFile(sendRequest("getFile", args));
+}
+
Chat::Ptr Api::getChat(int32_t chatId) const
{
vector<HttpReqArg> args;
@@ -515,18 +522,18 @@ void Api::answerInlineQuery(const std::string& inlineQueryId, const std::vector<
sendRequest("answerInlineQuery", args);
}
-void Api::kickChatMember(int64_t chatId, int32_t userId) const {
+bool Api::kickChatMember(int64_t chatId, int32_t userId) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("user_id", userId));
- sendRequest("kickChatMember", args);
+ return sendRequest("kickChatMember", args).get<bool>("", false);
}
-void Api::unbanChatMember(int64_t chatId, int32_t userId) const {
+bool Api::unbanChatMember(int64_t chatId, int32_t userId) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("user_id", userId));
- sendRequest("unbanChatMember", args);
+ return sendRequest("unbanChatMember", args).get<bool>("", false);
}
ptree Api::sendRequest(const string& method, const vector<HttpReqArg>& args) const {