mirror of
https://github.com/Syping/dtranslatebot.git
synced 2024-11-04 21:16:58 +01:00
MSVC fixes
This commit is contained in:
parent
2c4464c134
commit
2ad1bc3aa5
5 changed files with 11 additions and 7 deletions
|
@ -58,6 +58,9 @@ find_package(Threads REQUIRED)
|
|||
|
||||
# dtranslatebot Target + Installs
|
||||
add_executable(dtranslatebot ${DTRANSLATEBOT_HEADERS} ${DTRANSLATEBOT_SOURCES})
|
||||
if (MSVC AND MSVC_VERSION GREATER_EQUAL 1914)
|
||||
target_compile_options(dtranslatebot PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/Zc:__cplusplus>)
|
||||
endif()
|
||||
target_link_libraries(dtranslatebot PRIVATE Threads::Threads ${DPP_LIBRARIES})
|
||||
target_include_directories(dtranslatebot PRIVATE ${DPP_INCLUDE_DIR})
|
||||
set_target_properties(dtranslatebot PROPERTIES
|
||||
|
|
|
@ -493,7 +493,7 @@ void file::list_guilds(std::vector<dpp::snowflake> *guilds)
|
|||
for (const auto &guild_file : std::filesystem::directory_iterator(guild_dir)) {
|
||||
const std::filesystem::path &guild_file_path = guild_file.path();
|
||||
if (guild_file_path.extension() == ".json") {
|
||||
const std::string &guild_filename = guild_file_path.stem();
|
||||
const std::string guild_filename = guild_file_path.stem().generic_string();
|
||||
if (std::all_of(guild_filename.begin(), guild_filename.end(), ::isdigit)) {
|
||||
try {
|
||||
dpp::snowflake guild_id = std::stoull(guild_filename);
|
||||
|
|
|
@ -93,7 +93,7 @@ void process_guild_settings(const dpp::json &json, std::vector<guild> *guilds, s
|
|||
auto json_guild_id = json_guild->find("id");
|
||||
if (json_guild_id != json_guild->end()) {
|
||||
if (json_guild_id->is_number())
|
||||
guild.id = *json_guild_id;
|
||||
guild.id = static_cast<uint64_t>(*json_guild_id);
|
||||
else if (json_guild_id->is_string())
|
||||
guild.id = std::stoull(std::string(*json_guild_id));
|
||||
else
|
||||
|
@ -109,7 +109,7 @@ void process_guild_settings(const dpp::json &json, std::vector<guild> *guilds, s
|
|||
auto json_channel_id = json_channel->find("id");
|
||||
if (json_channel_id != json_channel->end()) {
|
||||
if (json_channel_id->is_number())
|
||||
channel.id = *json_channel_id;
|
||||
channel.id = static_cast<uint64_t>(*json_channel_id);
|
||||
else if (json_channel_id->is_string())
|
||||
channel.id = std::stoull(std::string(*json_channel_id));
|
||||
else
|
||||
|
@ -230,7 +230,7 @@ void settings::add_channel(const channel &channel, dpp::snowflake guild_id)
|
|||
// We will create the guild structure when it is not in memory
|
||||
guild guild;
|
||||
guild.id = guild_id;
|
||||
guild.channel.push_back(std::move(channel));
|
||||
guild.channel.push_back(channel);
|
||||
m_guilds.push_back(std::move(guild));
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* responsible for anything with use of the software, you are self responsible.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <sstream>
|
||||
#include "slashcommands.h"
|
||||
using namespace std::string_literals;
|
||||
|
||||
|
@ -167,9 +168,9 @@ void bot::slashcommands::register_commands(dpp::cluster *bot, bot::settings::set
|
|||
dpp::command_option channel_translate_subcommand(dpp::co_sub_command, "channel", "Translate current channel to a channel");
|
||||
dpp::command_option webhook_translate_subcommand(dpp::co_sub_command, "webhook", "Translate current channel to a webhook");
|
||||
dpp::command_option source_option(dpp::co_string, "source", "Source language (ISO 639-1)", true);
|
||||
source_option.set_max_length(2).set_min_length(2);
|
||||
source_option.set_max_length(static_cast<int64_t>(2)).set_min_length(static_cast<int64_t>(2));
|
||||
dpp::command_option target_option(dpp::co_string, "target", "Target language (ISO 639-1)", true);
|
||||
target_option.set_max_length(2).set_min_length(2);
|
||||
target_option.set_max_length(static_cast<int64_t>(2)).set_min_length(static_cast<int64_t>(2));
|
||||
dpp::command_option channel_option(dpp::co_channel, "channel", "Target channel", true);
|
||||
channel_option.add_channel_type(dpp::CHANNEL_TEXT);
|
||||
dpp::command_option webhook_option(dpp::co_string, "webhook", "Target webhook", true);
|
||||
|
|
|
@ -40,7 +40,7 @@ void bot::webhook_push::run(const bot::translated_message &message, dpp::cluster
|
|||
message_v = message_v.substr(1333 + pos);
|
||||
}
|
||||
else {
|
||||
std::cmatch match;
|
||||
std::match_results<std::string_view::const_iterator> match;
|
||||
if (std::regex_match(message_eov.begin(), message_eov.end(), match, std::regex("^.*(\\.|\\?|\\!|\\。)\\s.*$"s))) {
|
||||
json_body["content"] = message_v.substr(0, 1334 + match.position(1));
|
||||
message_v = message_v.substr(1334 + match.position(1));
|
||||
|
|
Loading…
Reference in a new issue