summaryrefslogtreecommitdiff
path: root/src/commands/command.hpp
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-04-21 03:25:12 +0500
committerilotterytea <iltsu@alright.party>2024-04-21 03:25:12 +0500
commitb4fca15aec26332c1315c8c3030169bbf342da3e (patch)
treef2529eeb93f20520f378049dce90173f2f42ce74 /src/commands/command.hpp
parent59084cf514386726df20c3b8e334f4f77685b97e (diff)
feat: command loader
Diffstat (limited to 'src/commands/command.hpp')
-rw-r--r--src/commands/command.hpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/commands/command.hpp b/src/commands/command.hpp
index 6e05779..6efe505 100644
--- a/src/commands/command.hpp
+++ b/src/commands/command.hpp
@@ -1,3 +1,7 @@
+#pragma once
+
+#include <memory>
+#include <optional>
#include <string>
#include <variant>
#include <vector>
@@ -7,9 +11,23 @@
namespace bot {
namespace command {
class Command {
+ public:
virtual std::string get_name() = 0;
virtual std::variant<std::vector<std::string>, std::string> run(
const irc::Message<irc::MessageType::Privmsg> &msg) = 0;
};
+
+ class CommandLoader {
+ public:
+ CommandLoader();
+ ~CommandLoader() = default;
+
+ 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);
+
+ private:
+ std::vector<std::unique_ptr<Command>> commands;
+ };
}
}