summaryrefslogtreecommitdiff
path: root/src/commands/command.hpp
blob: 02663012e0ad9b6244be044a0d8a7ed58b64d95c (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
34
35
36
37
#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);

        const std::vector<std::unique_ptr<Command>> &get_commands() const {
          return this->commands;
        };

      private:
        std::vector<std::unique_ptr<Command>> commands;
    };
  }
}