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)