diff options
| author | ilotterytea <iltsu@alright.party> | 2024-04-30 01:10:58 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-04-30 01:10:58 +0500 |
| commit | d6e04fc50423601e33cbf73baf67a4e48c9f8787 (patch) | |
| tree | 4bf0dd1219d16705e999039341dd13a6d90336ea /src | |
| parent | 7813d34268513a775faea45cb96ae6ee2bcd983d (diff) | |
feat: join channels from db
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index 9593863..c7e8e2f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,7 @@ #include <iostream> #include <optional> +#include <pqxx/pqxx> +#include <string> #include "bundle.hpp" #include "commands/command.hpp" @@ -40,6 +42,19 @@ int main(int argc, char *argv[]) { client.join(cfg.bot_username); + pqxx::connection conn(GET_DATABASE_CONNECTION_URL(cfg)); + pqxx::work work(conn); + + auto rows = work.exec("SELECT alias_name FROM channels"); + + for (const auto &row : rows) { + auto name = row[0].as<std::string>(); + client.join(name); + } + + work.commit(); + conn.close(); + client.on<bot::irc::MessageType::Privmsg>( [&client, &command_loader, &localization]( const bot::irc::Message<bot::irc::MessageType::Privmsg> &message) { |
