From 74828ca1b4aa0dedb952daec457f0aacca9c549d Mon Sep 17 00:00:00 2001 From: Bulat Kurbanov Date: Thu, 15 Aug 2024 20:25:46 +0200 Subject: [PATCH] Update --- src/services/twitch.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/services/twitch.py b/src/services/twitch.py index d3889f3..9fc4a08 100644 --- a/src/services/twitch.py +++ b/src/services/twitch.py @@ -171,11 +171,14 @@ class TwitchService: current_state = self.state.get(streamer_id) - if current_state is None or (datetime.now() - current_state.last_live_at).seconds >= self.ONLINE_NOTIFICATION_DELAY: - await self.notify_online(streamer_id) + + is_need_notify = current_state is None or (datetime.now() - current_state.last_live_at).seconds >= self.ONLINE_NOTIFICATION_DELAY self.state[streamer_id] = state + if is_need_notify: + await self.notify_online(streamer_id) + async def on_stream_online(self, event: StreamOnlineEvent): await self._on_stream_online(event.event.broadcaster_user_id)