diff options
Diffstat (limited to 'src/commands/command.cpp')
| -rw-r--r-- | src/commands/command.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/commands/command.cpp b/src/commands/command.cpp new file mode 100644 index 0000000..b6852cc --- /dev/null +++ b/src/commands/command.cpp @@ -0,0 +1,30 @@ +#include "command.hpp" + +#include <iostream> +#include <memory> +#include <optional> + +#include "../modules/ping.hpp" + +namespace bot { + namespace command { + CommandLoader::CommandLoader() { + this->add_command(std::make_unique<mod::Ping>()); + } + + void CommandLoader::add_command(std::unique_ptr<Command> command) { + this->commands.push_back(std::move(command)); + } + + std::optional<std::variant<std::vector<std::string>, std::string>> + CommandLoader::run(const irc::Message<irc::MessageType::Privmsg> &msg) { + for (const std::unique_ptr<Command> &command : this->commands) { + if (command->get_name() == msg.message) { + return command->run(msg); + } + } + + return std::nullopt; + } + } +} |
