diff --git a/SerialPrograms/Source/CommonFramework/Globals.cpp b/SerialPrograms/Source/CommonFramework/Globals.cpp index c1a631f51..468cff474 100644 --- a/SerialPrograms/Source/CommonFramework/Globals.cpp +++ b/SerialPrograms/Source/CommonFramework/Globals.cpp @@ -22,8 +22,8 @@ namespace PokemonAutomation{ const bool IS_BETA_VERSION = true; const int PROGRAM_VERSION_MAJOR = 0; -const int PROGRAM_VERSION_MINOR = 42; -const int PROGRAM_VERSION_PATCH = 7; +const int PROGRAM_VERSION_MINOR = 43; +const int PROGRAM_VERSION_PATCH = 1; const std::string PROGRAM_VERSION_BASE = "v" + std::to_string(PROGRAM_VERSION_MAJOR) + diff --git a/SerialPrograms/Source/Integrations/DiscordIntegrationSettings.cpp b/SerialPrograms/Source/Integrations/DiscordIntegrationSettings.cpp index bf61cc047..9208b899c 100644 --- a/SerialPrograms/Source/Integrations/DiscordIntegrationSettings.cpp +++ b/SerialPrograms/Source/Integrations/DiscordIntegrationSettings.cpp @@ -94,6 +94,11 @@ DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption() LockMode::LOCK_WHILE_RUNNING, "", "123456789012345678" ) + , allow_buttons_from_users( + "Allow Buttons from Users:
Allow other users to issue button presses.", + LockMode::LOCK_WHILE_RUNNING, + false + ) { PA_ADD_OPTION(run_on_start); PA_ADD_OPTION(library0); @@ -105,6 +110,7 @@ DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption() PA_ADD_OPTION(hello_message); PA_ADD_OPTION(sudo); PA_ADD_OPTION(owner); + PA_ADD_OPTION(allow_buttons_from_users); PA_ADD_OPTION(channels); DiscordIntegrationSettingsOption::value_changed(); @@ -132,6 +138,7 @@ void DiscordIntegrationSettingsOption::value_changed(){ use_suffix.set_visibility(state); sudo.set_visibility(state); owner.set_visibility(state); + allow_buttons_from_users.set_visibility(ConfigOptionState::HIDDEN); break; } #endif @@ -145,6 +152,7 @@ void DiscordIntegrationSettingsOption::value_changed(){ token.set_visibility(state); game_status.set_visibility(state); hello_message.set_visibility(state); + allow_buttons_from_users.set_visibility(state); command_prefix.set_visibility(state); use_suffix.set_visibility(ConfigOptionState::HIDDEN); diff --git a/SerialPrograms/Source/Integrations/DiscordIntegrationSettings.h b/SerialPrograms/Source/Integrations/DiscordIntegrationSettings.h index 64f0d2f7c..ab2fc4e29 100644 --- a/SerialPrograms/Source/Integrations/DiscordIntegrationSettings.h +++ b/SerialPrograms/Source/Integrations/DiscordIntegrationSettings.h @@ -48,6 +48,7 @@ class DiscordIntegrationSettingsOption : public GroupOption, private ConfigOptio StringOption hello_message; StringOption sudo; StringOption owner; + BooleanCheckBoxOption allow_buttons_from_users; DiscordIntegrationTable channels; }; diff --git a/SerialPrograms/Source/Integrations/DppIntegration/DppCommandHandler.cpp b/SerialPrograms/Source/Integrations/DppIntegration/DppCommandHandler.cpp index abf15b4c1..7f491dab2 100644 --- a/SerialPrograms/Source/Integrations/DppIntegration/DppCommandHandler.cpp +++ b/SerialPrograms/Source/Integrations/DppIntegration/DppCommandHandler.cpp @@ -227,7 +227,7 @@ void Handler::create_unified_commands(commandhandler& handler) { }, [&handler, this](const std::string& command, const parameter_list_t& params, command_source src) { log_dpp("Executing " + command + "...", "Unified Command Handler", ll_info); - if (src.issuer.id != owner.id) { + if (!GlobalSettings::instance().DISCORD.integration.allow_buttons_from_users && src.issuer.id != owner.id) { handler.reply(message("You do not have permission to use this command."), src); return; } @@ -258,7 +258,7 @@ void Handler::create_unified_commands(commandhandler& handler) { }, [&handler, this](const std::string& command, const parameter_list_t& params, command_source src) { log_dpp("Executing " + command + "...", "Unified Command Handler", ll_info); - if (src.issuer.id != owner.id) { + if (!GlobalSettings::instance().DISCORD.integration.allow_buttons_from_users && src.issuer.id != owner.id) { handler.reply(message("You do not have permission to use this command."), src); return; } @@ -289,7 +289,7 @@ void Handler::create_unified_commands(commandhandler& handler) { }, [&handler, this](const std::string& command, const parameter_list_t& params, command_source src) { log_dpp("Executing " + command + "...", "Unified Command Handler", ll_info); - if (src.issuer.id != owner.id) { + if (!GlobalSettings::instance().DISCORD.integration.allow_buttons_from_users && src.issuer.id != owner.id) { handler.reply(message("You do not have permission to use this command."), src); return; } @@ -320,7 +320,7 @@ void Handler::create_unified_commands(commandhandler& handler) { }, [&handler, this](const std::string& command, const parameter_list_t& params, command_source src) { log_dpp("Executing " + command + "...", "Unified Command Handler", ll_info); - if (src.issuer.id != owner.id) { + if (!GlobalSettings::instance().DISCORD.integration.allow_buttons_from_users && src.issuer.id != owner.id) { handler.reply(message("You do not have permission to use this command."), src); return; } @@ -384,7 +384,7 @@ void Handler::create_unified_commands(commandhandler& handler) { }, [&handler, this](const std::string& command, const parameter_list_t& params, command_source src) { log_dpp("Executing " + command + "...", "Unified Command Handler", ll_info); - if (src.issuer.id != owner.id) { + if (!GlobalSettings::instance().DISCORD.integration.allow_buttons_from_users && src.issuer.id != owner.id) { handler.reply(message("You do not have permission to use this command."), src); return; } @@ -447,7 +447,7 @@ void Handler::create_unified_commands(commandhandler& handler) { }, [&handler, this](const std::string& command, const parameter_list_t& params, command_source src) { log_dpp("Executing " + command + "...", "Unified Command Handler", ll_info); - if (src.issuer.id != owner.id) { + if (!GlobalSettings::instance().DISCORD.integration.allow_buttons_from_users && src.issuer.id != owner.id) { handler.reply(message("You do not have permission to use this command."), src); return; } @@ -511,7 +511,7 @@ void Handler::create_unified_commands(commandhandler& handler) { }, [&handler, this](const std::string& command, const parameter_list_t& params, command_source src) { log_dpp("Executing " + command + "...", "Unified Command Handler", ll_info); - if (src.issuer.id != owner.id) { + if (!GlobalSettings::instance().DISCORD.integration.allow_buttons_from_users && src.issuer.id != owner.id) { handler.reply(message("You do not have permission to use this command."), src); return; } @@ -569,7 +569,9 @@ void Handler::create_unified_commands(commandhandler& handler) { for (auto& cmd : commands) { std::string name = cmd.first; log_dpp(name, "help command", ll_info); - if (src.issuer.id != owner.id && name != "hi" && name != "ping" && name != "about" && name != "status" && name != "help") { + if (!GlobalSettings::instance().DISCORD.integration.allow_buttons_from_users && + src.issuer.id != owner.id && name != "hi" && name != "ping" && name != "about" && name != "status" && name != "help" + ){ continue; }