diff options
Diffstat (limited to 'bot/src/commands/request.cpp')
| -rw-r--r-- | bot/src/commands/request.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/bot/src/commands/request.cpp b/bot/src/commands/request.cpp index e5a1e7e..d8a91f9 100644 --- a/bot/src/commands/request.cpp +++ b/bot/src/commands/request.cpp @@ -172,17 +172,25 @@ namespace bot::command { std::string command_id = parts[0]; - auto cmd = std::find_if( - command_loader.get_commands().begin(), - command_loader.get_commands().end(), - [&command_id](const auto &c) { return c->get_name() == command_id; }); - - if (cmd == command_loader.get_commands().end()) { + auto &cmds = command_loader.get_commands(); + auto cmd = + std::find_if(cmds.begin(), cmds.end(), [&command_id](const auto &c) { + auto aliases = c->get_aliases(); + return c->get_name() == command_id || + std::any_of(aliases.begin(), aliases.end(), + [&command_id](const std::string &alias) { + return alias == command_id; + }); + }); + + if (cmd == cmds.end()) { return std::nullopt; } parts.erase(parts.begin()); + command_id = (*cmd)->get_name(); + Request req{command_id, std::nullopt, std::nullopt, irc_message, requester}; if (parts.empty()) { |
