static double stefansChat_onLine_safetyDelay = 1; // seconds static int stefansChat_onLine_lookback = 0; static void stefansChat_onLine(fO f) { thread "Stefan's Chat" { int a = max(0, toInt(loadPage("http://ai1.lol/1008998/raw/n"))-stefansChat_onLine_lookback); while licensed { S s = loadPage("http://ai1.lol/1008998/raw/incremental?json=1&a=" + a); if (empty(trim(s))) { sleepSeconds(stefansChat_onLine_safetyDelay); print("Re-polling."); continue; } Map map = safeUnstructMap(s); int n = getInt(map, 'n); L msgs = cast get(map, 'msgs); for (O msg : msgs) pcallF(f, getString(msg, 'text)); a = n; } } }