diff options
| author | LLLL Colonq <llll@colonq> | 2024-08-04 02:09:37 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2024-08-04 02:09:37 -0400 |
| commit | 7b101b8c3c0481d76733c77008b5b763ceb3b535 (patch) | |
| tree | a2a8b3c46f4b6ae87eb288d7834be8b254522da2 /fig-monitor-twitch | |
| parent | 790b517b8e64c46bcd6bb71637d2d0eb68c51abd (diff) | |
Live monitor endpoint
Diffstat (limited to 'fig-monitor-twitch')
| -rw-r--r-- | fig-monitor-twitch/src/Fig/Monitor/Twitch.hs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/fig-monitor-twitch/src/Fig/Monitor/Twitch.hs b/fig-monitor-twitch/src/Fig/Monitor/Twitch.hs index ef493c4..561c574 100644 --- a/fig-monitor-twitch/src/Fig/Monitor/Twitch.hs +++ b/fig-monitor-twitch/src/Fig/Monitor/Twitch.hs @@ -487,23 +487,21 @@ twitchChannelLiveMonitor cfg busAddr = do -- updateLive = fmap Map.fromList . runAuthed cfg $ forM cfg.monitor \user -> do -- liftIO . threadDelay $ 5 * 1000000 -- (user,) <$> userIsLive user - loop :: Map.Map Text Bool -> IO () - loop old = do + loop :: IO () + loop = do log "Updating liveness..." - new <- updateLive + live <- updateLive log "Update complete!" forM_ cfg.monitor \user -> - case (Map.lookup user old, Map.lookup user new) of - (Just False, Just True) -> do - log $ "Newly online: " <> user + case Map.lookup user live of + Just True -> do cmds.publish [sexp|(monitor twitch stream online)|] [SExprString user] - (Just True, Just False) -> do - log $ "Newly offline: " <> user + Just False -> do cmds.publish [sexp|(monitor twitch stream offline)|] [SExprString user] _ -> pure () threadDelay $ 5 * 60 * 1000000 - loop new - loop Map.empty + loop + loop ) (\_cmds _d -> pure ()) (pure ()) |
