summaryrefslogtreecommitdiff
path: root/src/commands/command.hpp
blob: 6efe505f3aaf8c13af7a7f4071ef525b6ee2bbc6 (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
#pragma once

#include <memory>
#include <optional>
#include <string>
#include <variant>
#include <vector>

#include "../irc/message.hpp"

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;
    };
  }
}