summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-04-30 01:16:41 +0500
committerilotterytea <iltsu@alright.party>2024-04-30 01:16:41 +0500
commit2064d219e19550cd885bee103a06e3f1cb7bc8e2 (patch)
tree51265bee92ae413322bc2972204157ab5ad05aaf /src/main.cpp
parentd6e04fc50423601e33cbf73baf67a4e48c9f8787 (diff)
feat: create a new db connection for each message and pass work to it
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index c7e8e2f..67cf3a5 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -56,10 +56,18 @@ int main(int argc, char *argv[]) {
conn.close();
client.on<bot::irc::MessageType::Privmsg>(
- [&client, &command_loader, &localization](
- const bot::irc::Message<bot::irc::MessageType::Privmsg> &message) {
+ [&client, &command_loader, &localization,
+ &cfg](const bot::irc::Message<bot::irc::MessageType::Privmsg> &message) {
bot::InstanceBundle bundle{client, localization};
- bot::handlers::handle_private_message(bundle, command_loader, message);
+
+ pqxx::connection conn(GET_DATABASE_CONNECTION_URL(cfg));
+ pqxx::work work(conn);
+
+ bot::handlers::handle_private_message(bundle, command_loader, message,
+ work);
+
+ work.commit();
+ conn.close();
});
client.run();