From bc7c6acaa4c35b89b406b89bc68b948f52bbe387 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Fri, 17 May 2024 23:50:36 +0500 Subject: feat: send msg if the stream has been running for less than a minute --- src/stream.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/stream.cpp b/src/stream.cpp index cfb3387..c886446 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -47,6 +47,10 @@ namespace bot::stream { } void StreamListenerClient::check() { auto streams = this->helix_client.get_streams(this->ids); + auto now = std::chrono::system_clock::now(); + auto now_time_it = std::chrono::system_clock::to_time_t(now); + auto now_tm = std::gmtime(&now_time_it); + now = std::chrono::system_clock::from_time_t(std::mktime(now_tm)); // adding new ids for (const auto &stream : streams) { @@ -56,7 +60,14 @@ namespace bot::stream { if (!is_already_live) { this->online_ids.insert(stream.get_user_id()); - this->handler(schemas::EventType::LIVE, stream); + + auto difference = now - stream.get_started_at(); + auto difference_min = + std::chrono::duration_cast(difference); + + if (difference_min.count() < 1) { + this->handler(schemas::EventType::LIVE, stream); + } } } -- cgit v1.2.3