summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Api.cpp46
-rw-r--r--src/TgTypeParser.cpp20
-rw-r--r--src/types/InputFile.cpp6
3 files changed, 49 insertions, 23 deletions
diff --git a/src/Api.cpp b/src/Api.cpp
index b3ce4ea..0d11295 100644
--- a/src/Api.cpp
+++ b/src/Api.cpp
@@ -1156,7 +1156,7 @@ bool Api::unbanChatMember(boost::variant<std::int64_t, std::string> chatId,
bool Api::restrictChatMember(boost::variant<std::int64_t, std::string> chatId,
std::int64_t userId,
TgBot::ChatPermissions::Ptr permissions,
- std::int64_t untilDate,
+ std::uint32_t untilDate,
bool useIndependentChatPermissions) const {
std::vector<HttpReqArg> args;
args.reserve(5);
@@ -1164,10 +1164,10 @@ bool Api::restrictChatMember(boost::variant<std::int64_t, std::string> chatId,
args.emplace_back("chat_id", chatId);
args.emplace_back("user_id", userId);
args.emplace_back("permissions", _tgTypeParser.parseChatPermissions(permissions));
- if (useIndependentChatPermissions) {
+ if (useIndependentChatPermissions != false) {
args.emplace_back("use_independent_chat_permissions", useIndependentChatPermissions);
}
- if (untilDate) {
+ if (untilDate != 0) {
args.emplace_back("until_date", untilDate);
}
@@ -1187,46 +1187,58 @@ bool Api::promoteChatMember(boost::variant<std::int64_t, std::string> chatId,
bool canManageChat,
bool canManageVideoChats,
bool canRestrictMembers,
- bool canManageTopics) const {
+ bool canManageTopics,
+ bool canPostStories,
+ bool canEditStories,
+ bool canDeleteStories) const {
std::vector<HttpReqArg> args;
- args.reserve(14);
+ args.reserve(17);
args.emplace_back("chat_id", chatId);
args.emplace_back("user_id", userId);
- if (isAnonymous) {
+ if (isAnonymous != false) {
args.emplace_back("is_anonymous", isAnonymous);
}
- if (canManageChat) {
+ if (canManageChat != false) {
args.emplace_back("can_manage_chat", canManageChat);
}
- if (canPostMessages) {
+ if (canPostMessages != false) {
args.emplace_back("can_post_messages", canPostMessages);
}
- if (canEditMessages) {
+ if (canEditMessages != false) {
args.emplace_back("can_edit_messages", canEditMessages);
}
- if (canDeleteMessages) {
+ if (canDeleteMessages != false) {
args.emplace_back("can_delete_messages", canDeleteMessages);
}
- if (canManageVideoChats) {
+ if (canPostStories != false) {
+ args.emplace_back("can_post_stories", canPostStories);
+ }
+ if (canEditStories != false) {
+ args.emplace_back("can_edit_stories", canEditStories);
+ }
+ if (canDeleteStories != false) {
+ args.emplace_back("can_delete_stories", canDeleteStories);
+ }
+ if (canManageVideoChats != false) {
args.emplace_back("can_manage_video_chats", canManageVideoChats);
}
- if (canRestrictMembers) {
+ if (canRestrictMembers != false) {
args.emplace_back("can_restrict_members", canRestrictMembers);
}
- if (canPromoteMembers) {
+ if (canPromoteMembers != false) {
args.emplace_back("can_promote_members", canPromoteMembers);
}
- if (canChangeInfo) {
+ if (canChangeInfo != false) {
args.emplace_back("can_change_info", canChangeInfo);
}
- if (canInviteUsers) {
+ if (canInviteUsers != false) {
args.emplace_back("can_invite_users", canInviteUsers);
}
- if (canPinMessages) {
+ if (canPinMessages != false) {
args.emplace_back("can_pin_messages", canPinMessages);
}
- if (canManageTopics) {
+ if (canManageTopics != false) {
args.emplace_back("can_manage_topics", canManageTopics);
}
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp
index 86a25c1..6905c89 100644
--- a/src/TgTypeParser.cpp
+++ b/src/TgTypeParser.cpp
@@ -1132,7 +1132,9 @@ std::string TgTypeParser::parseChatShared(const ChatShared::Ptr& object) const {
WriteAccessAllowed::Ptr TgTypeParser::parseJsonAndGetWriteAccessAllowed(const boost::property_tree::ptree& data) const {
auto result(std::make_shared<WriteAccessAllowed>());
+ result->fromRequest = data.get<bool>("from_request", false);
result->webAppName = data.get<std::string>("web_app_name", "");
+ result->fromAttachmentMenu = data.get<bool>("from_attachment_menu", false);
return result;
}
@@ -1142,7 +1144,9 @@ std::string TgTypeParser::parseWriteAccessAllowed(const WriteAccessAllowed::Ptr&
}
std::string result;
result += '{';
+ appendToJson(result, "from_request", object->fromRequest);
appendToJson(result, "web_app_name", object->webAppName);
+ appendToJson(result, "from_attachment_menu", object->fromAttachmentMenu);
removeLastComma(result);
result += '}';
return result;
@@ -1682,6 +1686,9 @@ ChatAdministratorRights::Ptr TgTypeParser::parseJsonAndGetChatAdministratorRight
result->canPostMessages = data.get<bool>("can_post_messages", false);
result->canEditMessages = data.get<bool>("can_edit_messages", false);
result->canPinMessages = data.get<bool>("can_pin_messages", false);
+ result->canPostStories = data.get<bool>("can_post_stories", false);
+ result->canEditStories = data.get<bool>("can_edit_stories", false);
+ result->canDeleteStories = data.get<bool>("can_delete_stories", false);
result->canManageTopics = data.get<bool>("can_manage_topics", false);
return result;
}
@@ -1703,6 +1710,9 @@ std::string TgTypeParser::parseChatAdministratorRights(const ChatAdministratorRi
appendToJson(result, "can_post_messages", object->canPostMessages);
appendToJson(result, "can_edit_messages", object->canEditMessages);
appendToJson(result, "can_pin_messages", object->canPinMessages);
+ appendToJson(result, "can_post_stories", object->canPostStories);
+ appendToJson(result, "can_edit_stories", object->canEditStories);
+ appendToJson(result, "can_delete_stories", object->canDeleteStories);
appendToJson(result, "can_manage_topics", object->canManageTopics);
removeLastComma(result);
result += '}';
@@ -1799,6 +1809,9 @@ ChatMemberAdministrator::Ptr TgTypeParser::parseJsonAndGetChatMemberAdministrato
result->canPostMessages = data.get<bool>("can_post_messages", false);
result->canEditMessages = data.get<bool>("can_edit_messages", false);
result->canPinMessages = data.get<bool>("can_pin_messages", false);
+ result->canPostStories = data.get<bool>("can_post_stories", false);
+ result->canEditStories = data.get<bool>("can_edit_stories", false);
+ result->canDeleteStories = data.get<bool>("can_delete_stories", false);
result->canManageTopics = data.get<bool>("can_manage_topics", false);
result->customTitle = data.get<std::string>("custom_title", "");
return result;
@@ -1823,6 +1836,9 @@ std::string TgTypeParser::parseChatMemberAdministrator(const ChatMemberAdministr
appendToJson(result, "can_post_messages", object->canPostMessages);
appendToJson(result, "can_edit_messages", object->canEditMessages);
appendToJson(result, "can_pin_messages", object->canPinMessages);
+ appendToJson(result, "can_post_stories", object->canPostStories);
+ appendToJson(result, "can_edit_stories", object->canEditStories);
+ appendToJson(result, "can_delete_stories", object->canDeleteStories);
appendToJson(result, "can_manage_topics", object->canManageTopics);
appendToJson(result, "custom_title", object->customTitle);
// The last comma will be erased by parseChatMember().
@@ -1915,7 +1931,7 @@ std::string TgTypeParser::parseChatMemberLeft(const ChatMemberLeft::Ptr& object)
ChatMemberBanned::Ptr TgTypeParser::parseJsonAndGetChatMemberBanned(const boost::property_tree::ptree& data) const {
// NOTE: This function will be called by parseJsonAndGetChatMember().
auto result(std::make_shared<ChatMemberBanned>());
- result->untilDate = data.get<uint32_t>("until_date", 0);
+ result->untilDate = data.get<std::uint32_t>("until_date", 0);
return result;
}
@@ -1935,7 +1951,7 @@ ChatMemberUpdated::Ptr TgTypeParser::parseJsonAndGetChatMemberUpdated(const boos
auto result(std::make_shared<ChatMemberUpdated>());
result->chat = tryParseJson<Chat>(&TgTypeParser::parseJsonAndGetChat, data, "chat");
result->from = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "from");
- result->date = data.get<std::uint64_t>("date", 0);
+ result->date = data.get<std::uint32_t>("date", 0);
result->oldChatMember = tryParseJson<ChatMember>(&TgTypeParser::parseJsonAndGetChatMember, data, "old_chat_member");
result->newChatMember = tryParseJson<ChatMember>(&TgTypeParser::parseJsonAndGetChatMember, data, "new_chat_member");
result->inviteLink = tryParseJson<ChatInviteLink>(&TgTypeParser::parseJsonAndGetChatInviteLink, data, "invite_link");
diff --git a/src/types/InputFile.cpp b/src/types/InputFile.cpp
index c4d804d..2deb082 100644
--- a/src/types/InputFile.cpp
+++ b/src/types/InputFile.cpp
@@ -5,12 +5,10 @@
#include <memory>
#include <string>
-using namespace std;
-
namespace TgBot {
-InputFile::Ptr InputFile::fromFile(const string& filePath, const string& mimeType) {
- auto result(make_shared<InputFile>());
+InputFile::Ptr InputFile::fromFile(const std::string& filePath, const std::string& mimeType) {
+ auto result(std::make_shared<InputFile>());
result->data = FileTools::read(filePath);
result->mimeType = mimeType;
result->fileName = std::filesystem::path(filePath).filename().string();