summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/stream.cpp22
-rw-r--r--src/stream.hpp1
2 files changed, 23 insertions, 0 deletions
diff --git a/src/stream.cpp b/src/stream.cpp
index 2fa1a34..4868995 100644
--- a/src/stream.cpp
+++ b/src/stream.cpp
@@ -39,6 +39,7 @@ namespace bot::stream {
}
void StreamListenerClient::run() {
while (true) {
+ this->update_channel_ids();
this->check();
std::this_thread::sleep_for(std::chrono::seconds(5));
}
@@ -159,4 +160,25 @@ namespace bot::stream {
conn.close();
}
}
+ void StreamListenerClient::update_channel_ids() {
+ pqxx::connection conn(GET_DATABASE_CONNECTION_URL(this->configuration));
+ pqxx::work work(conn);
+
+ pqxx::result ids =
+ work.exec("SELECT target_alias_id FROM events WHERE event_type < 99");
+
+ for (const auto &row : ids) {
+ int id = row[0].as<int>();
+
+ if (std::any_of(this->ids.begin(), this->ids.end(),
+ [&](const auto &x) { return x == id; })) {
+ continue;
+ }
+
+ this->ids.push_back(id);
+ }
+
+ work.commit();
+ conn.close();
+ }
}
diff --git a/src/stream.hpp b/src/stream.hpp
index 7701cb3..28fe0e3 100644
--- a/src/stream.hpp
+++ b/src/stream.hpp
@@ -30,6 +30,7 @@ namespace bot::stream {
void check();
void handler(const schemas::EventType &type,
const api::twitch::schemas::Stream &stream);
+ void update_channel_ids();
const api::twitch::HelixClient &helix_client;
irc::Client &irc_client;