blob: 9d6ec6a29a1f6fa781492d5cbd5891e70d36cd92 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#include "command.hpp"
#include <iostream>
#include <memory>
#include <optional>
#include "../bundle.hpp"
#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 InstanceBundle &bundle,
const irc::Message<irc::MessageType::Privmsg> &msg) const {
for (const std::unique_ptr<Command> &command : this->commands) {
if (command->get_name() == msg.message) {
return command->run(bundle, msg);
}
}
return std::nullopt;
}
}
}
|