Warning: session_start(): open(/var/lib/php/sessions/sess_s34iocqq5f6crfjm0mh0amov1m, 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
!7
sbool listen = true;
static O onUpdate;
static WebThoughtSpace ts;
p {
db();
ts = uniq(WebThoughtSpace);
assertSame(mainConcepts, ts._concepts);
if (isMain()) autoRestart();
if (empty(ts.webs)) loadFullHistory();
if (listen) {
print("Listening to chat.");
stefansChat_onLine(100, voidfunc(S line) {
ChatMsg msg = mapToObject(stefansChat_onLine_fullParams!, ChatMsg);
handleChatMsg(msg);
pcallF(onUpdate);
});
}
bot("Chat Single Theory.");
}
svoid loadFullHistory() {
int max = 10000;
L l = stefansChat_readArchive(max);
print("Got " + l(l) + "/" + max);
for (ChatMsg msg : l) pcall { handleChatMsg(msg); }
}
svoid handleChatMsg(ChatMsg msg) {
lock dbLock();
print("Handling " + msg.globalID);
S sMsg = "Msg " + msg.globalID;
WebNode node = ts.indexedNode(sMsg);
if (node != null) ret; // No overwrite for now
WebNode n = simpleWeb().newNode();
n.addLabel(/*"Text " +*/ quote(msg.text));
web_addString(n, msg.botMark ? "by bot" : "by user");
web_addStrings(n, ai_categoriesForChatLine(msg.text));
web_addString(n, "Time " + msg.time);
web_addString(n, "Should I react?");
n.addLabel("Msg " + msg.globalID);
thoughtSpace_addWeb(ts, n.web);
print(" Have " + n(ts.webs, "web"));
}
answer {
/*if "show *"
ret showWeb(theoryForLineMap.get($1)) != null ? "OK" : "Not found";*/
if "load full history"
ret "OK" with loadFullHistory();
if "size" ret lstr(ts.webs);
}