diff options
| author | ilotterytea <iltsu@alright.party> | 2024-05-17 23:50:36 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-05-17 23:50:36 +0500 |
| commit | bc7c6acaa4c35b89b406b89bc68b948f52bbe387 (patch) | |
| tree | d58a03bad7196d28fcb76b219b5f71812e12da9d | |
| parent | 3bd63ba3ea36c2a392ff2a93b94e0fa41b49bd54 (diff) | |
feat: send msg if the stream has been running for less than a minute
| -rw-r--r-- | src/stream.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
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<std::chrono::minutes>(difference); + + if (difference_min.count() < 1) { + this->handler(schemas::EventType::LIVE, stream); + } } } |
