Download Jar. Libraryless. Click here for Pure Java version (14639L/104K).
!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<ChatMsg> 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); }
Began life as a copy of #1010963
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1011364 |
Snippet name: | Chat Single Theory Module |
Eternal ID of this version: | #1011364/3 |
Text MD5: | 053ce0cd1156d01473f2f6abd2908e9a |
Transpilation MD5: | 5431a62e7a24f32278d27e77b293fe38 |
Author: | stefan |
Category: | javax / chat |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-10-26 04:03:26 |
Source code size: | 1554 bytes / 62 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 486 / 6587 |
Version history: | 2 change(s) |
Referenced in: | #1011368 - Replace String with CharSequence [not that easy] |