diff options
| author | ilotterytea <iltsu@alright.party> | 2025-07-06 12:40:01 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-07-06 12:40:01 +0500 |
| commit | c445bc6def35a9e01b4303ab6fac3a7d71c8f56f (patch) | |
| tree | 5ab45b533e822a8a497d0624990c110badd8280a /bot/src/commands/request.cpp | |
| parent | 0194f86ee840b9585fdc9a111b3d9521217b39bf (diff) | |
feat: command aliases
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()) { |
