From d6e04fc50423601e33cbf73baf67a4e48c9f8787 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 30 Apr 2024 01:10:58 +0500 Subject: feat: join channels from db --- src/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') 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 #include +#include +#include #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(); + client.join(name); + } + + work.commit(); + conn.close(); + client.on( [&client, &command_loader, &localization]( const bot::irc::Message &message) { -- cgit v1.2.3