summaryrefslogtreecommitdiff
path: root/src/config.hpp
blob: 25519c3b6d07c85862211e5267f0dfde406e107b (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
38
39
40
41
42
43
44
#pragma once

#include <optional>
#include <string>

#define GET_DATABASE_CONNECTION_URL(c)                                      \
  "dbname = " + c.database.name + " user = " + c.database.user +            \
      " password = " + c.database.password + " host = " + c.database.host + \
      " port = " + c.database.port

namespace bot {
  struct DatabaseConfiguration {
      std::string name;
      std::string user;
      std::string password;
      std::string host;
      std::string port;
  };

  struct TwitchCredentialsConfiguration {
      std::string client_id;
      std::string token;
  };

  struct CommandConfiguration {
      bool join_allowed = true;
      bool join_allow_from_other_chats = false;
  };

  struct OwnerConfiguration {
      std::optional<std::string> name = std::nullopt;
      std::optional<int> id = std::nullopt;
  };

  struct Configuration {
      TwitchCredentialsConfiguration twitch_credentials;
      DatabaseConfiguration database;
      CommandConfiguration commands;
      OwnerConfiguration owner;
  };

  std::optional<Configuration> parse_configuration_from_file(
      const std::string &file_path);
}