diff options
| author | ilotterytea <iltsu@alright.party> | 2024-04-21 02:36:45 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-04-21 02:36:45 +0500 |
| commit | 744b36aefee654530158f06d682e9e330ffc06c9 (patch) | |
| tree | 3e88ff8e693d99840fd7bb9f17923e360a4e2155 /src/main.cpp | |
| parent | aa21312f18ef86a335dd28272e317da959ceb9b7 (diff) | |
feat: .env config parser
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index b940d1d..129b074 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,11 +1,27 @@ #include <iostream> +#include <optional> +#include "config.hpp" #include "irc/client.hpp" int main(int argc, char *argv[]) { std::cout << "hi world\n"; - bot::irc::Client client("", ""); + std::optional<bot::Configuration> o_cfg = + bot::parse_configuration_from_file(".env"); + + if (!o_cfg.has_value()) { + return -1; + } + + bot::Configuration cfg = o_cfg.value(); + + if (cfg.bot_password.empty() || cfg.bot_username.empty()) { + std::cerr << "*** BOT_USERNAME and BOT_PASSWORD must be set!\n"; + return -1; + } + + bot::irc::Client client(cfg.bot_username, cfg.bot_password); client.run(); |
