summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/command.cpp7
-rw-r--r--src/commands/command.hpp9
2 files changed, 11 insertions, 5 deletions
diff --git a/src/commands/command.cpp b/src/commands/command.cpp
index b6852cc..9d6ec6a 100644
--- a/src/commands/command.cpp
+++ b/src/commands/command.cpp
@@ -4,6 +4,7 @@
#include <memory>
#include <optional>
+#include "../bundle.hpp"
#include "../modules/ping.hpp"
namespace bot {
@@ -17,10 +18,12 @@ namespace bot {
}
std::optional<std::variant<std::vector<std::string>, std::string>>
- CommandLoader::run(const irc::Message<irc::MessageType::Privmsg> &msg) {
+ 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(msg);
+ return command->run(bundle, msg);
}
}
diff --git a/src/commands/command.hpp b/src/commands/command.hpp
index 0266301..5f69788 100644
--- a/src/commands/command.hpp
+++ b/src/commands/command.hpp
@@ -6,15 +6,17 @@
#include <variant>
#include <vector>
+#include "../bundle.hpp"
#include "../irc/message.hpp"
namespace bot {
namespace command {
class Command {
public:
- virtual std::string get_name() = 0;
+ virtual std::string get_name() const = 0;
virtual std::variant<std::vector<std::string>, std::string> run(
- const irc::Message<irc::MessageType::Privmsg> &msg) = 0;
+ const InstanceBundle &bundle,
+ const irc::Message<irc::MessageType::Privmsg> &msg) const = 0;
};
class CommandLoader {
@@ -24,7 +26,8 @@ namespace bot {
void add_command(std::unique_ptr<Command> cmd);
std::optional<std::variant<std::vector<std::string>, std::string>> run(
- const irc::Message<irc::MessageType::Privmsg> &msg);
+ const InstanceBundle &bundle,
+ const irc::Message<irc::MessageType::Privmsg> &msg) const;
const std::vector<std::unique_ptr<Command>> &get_commands() const {
return this->commands;