diff options
| author | ilotterytea <iltsu@alright.party> | 2024-12-09 07:20:40 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-12-09 07:20:40 +0500 |
| commit | b68138950de42cdc62cacd1eb984358ee6be4c1a (patch) | |
| tree | 6fced912558d3068db337d73cbca714c9799c75a /bot/src | |
| parent | 52fd4ea8bad5cd7d3940a41df4f8f54b4e72beae (diff) | |
fix: custom prefix wasnt preferred
Diffstat (limited to 'bot/src')
| -rw-r--r-- | bot/src/commands/request_util.cpp | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/bot/src/commands/request_util.cpp b/bot/src/commands/request_util.cpp index 90750e5..ad8a174 100644 --- a/bot/src/commands/request_util.cpp +++ b/bot/src/commands/request_util.cpp @@ -23,28 +23,6 @@ namespace bot::command { std::vector<std::string> parts = utils::string::split_text(irc_message.message, ' '); - std::string command_id = parts[0]; - - if (command_id.substr(0, DEFAULT_PREFIX.length()) != DEFAULT_PREFIX) { - delete work; - return std::nullopt; - } - - command_id = - command_id.substr(DEFAULT_PREFIX.length(), command_id.length()); - - auto cmd = std::find_if( - command_loader.get_commands().begin(), - command_loader.get_commands().end(), - [&](const auto &command) { return command->get_name() == command_id; }); - - if (cmd == command_loader.get_commands().end()) { - delete work; - return std::nullopt; - } - - parts.erase(parts.begin()); - pqxx::result query = work->exec("SELECT * FROM channels WHERE alias_id = " + std::to_string(irc_message.source.id)); @@ -169,6 +147,31 @@ namespace bot::command { user_rights.set_level(level); } + + // Checking if the user has sent a command + std::string command_id = parts[0]; + + const std::string &prefix = channel_preferences.get_prefix(); + + if (command_id.substr(0, prefix.length()) != prefix) { + delete work; + return std::nullopt; + } + + command_id = + command_id.substr(prefix.length(), command_id.length()); + + auto cmd = std::find_if( + command_loader.get_commands().begin(), + command_loader.get_commands().end(), + [&](const auto &command) { return command->get_name() == command_id; }); + + if (cmd == command_loader.get_commands().end()) { + delete work; + return std::nullopt; + } + + parts.erase(parts.begin()); delete work; |
