This commit is contained in:
2024-11-15 13:16:07 +01:00
parent d68f6d6f3c
commit b5a64c02ce

View File

@@ -41,6 +41,8 @@ class TokenStorage:
class TwitchService: class TwitchService:
lock = Lock()
SCOPES = [ SCOPES = [
AuthScope.CHAT_READ, AuthScope.CHAT_READ,
AuthScope.CHAT_EDIT, AuthScope.CHAT_EDIT,
@@ -126,6 +128,7 @@ class TwitchService:
if stream is None: if stream is None:
return return
async with self.lock:
current_state = self.state.get(brodcaster_id) current_state = self.state.get(brodcaster_id)
if current_state is None: if current_state is None:
return return
@@ -152,9 +155,9 @@ class TwitchService:
last_live_at=datetime.now() last_live_at=datetime.now()
) )
async with self.lock:
current_state = self.state.get(streamer_id) current_state = self.state.get(streamer_id)
is_need_notify = current_state is None or (datetime.now() - current_state.last_live_at).seconds >= self.ONLINE_NOTIFICATION_DELAY 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 self.state[streamer_id] = state