Warning: session_start(): open(/var/lib/php/sessions/sess_ttkjg16d43hskgferl6ne9nrld, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
// We're also using some of stefansChat_onLine's variables
please include function stefansChat_onLine.
static double smartBotsChat_onLine_safetyDelay = 1; // seconds
static double smartBotsChat_onLine_shortSafetyDelay = 0.1;
static double smartBotsChat_onLine_errorDelay = 10;
static int smartBotsChat_onLine_lookback = 0;
static int smartBotsChat_onLine_firstRead = -1;
static new ThreadLocal smartBotsChat_onLine_onHistoryRead;
static void smartBotsChat_onLine(int lookback, O f) {
smartBotsChat_onLine_lookback = lookback;
smartBotsChat_onLine(f);
}
static void smartBotsChat_onLine(fO f) {
fO hr = getAndClearThreadLocal(smartBotsChat_onLine_onHistoryRead);
thread "Smart Bot's Chat" {
int a = smartBotsChat_onLine_firstRead = max(0, smartBotsChat_n() - smartBotsChat_onLine_lookback);
bool first = true;
while licensed { pcall {
S s = loadPageWithTimeout("http://ai1.space/1011975/raw/incremental?json=1&a=" + a, 120*1000);
if (empty(trim(s))) {
sleepSeconds(smartBotsChat_onLine_safetyDelay);
//print("Re-polling.");
continue;
}
try {
Map map = safeUnstructMap(s);
int n = getInt(map, 'n);
L msgs = cast get(map, 'msgs);
for (O msg : msgs)
try {
stefansChat_onLine_fullParams.set(mapPlus((Map) msg, chatName := "Smart Bot's Chat"));
pcallF(f, getString(msg, 'text));
} finally {
stefansChat_onLine_fullParams.set(null);
}
sleepSeconds(smartBotsChat_onLine_shortSafetyDelay);
a = n;
} catch e {
printException(e);
sleepSeconds(smartBotsChat_onLine_errorDelay);
}
if (first) {
pcallF(hr);
first = false;
}
}} // end pcall, while licensed
}
}