Libraryless. Click here for Pure Java version (1970L/13K/42K).
!752 static S atEleuPrefix = "<@u0hb7bpkm>"; static int maxLen = 100; static PersistentMap<S, S> inToOut; static S last; p { inToOut = new PersistentMap("inToOut"); load("last"); } synchronized answer { if (neq(getChannel(), "devchannel, #talkingbots")) null; if (match("clear ua ub uc", s) && master()) { inToOut.clear(); ret getProgramID() + " cleared"; } s = s.trim(); boolean at = startsWithIgnoreCase(s, atEleuPrefix); if (at) s = dropPrefixIgnoreCase(atEleuPrefix, s); S in = simplifySentence2(s); saveIt(s, in, at); S out = inToOut.get(in); print("1002967: in=" + in + ", out=" + out); if (nempty(out)) { // TODO: bump in LRU ret out; } } static void saveIt(S s, S in, boolean at) { S lastOut = getLastOut(); if (nempty(lastOut)) saveEntry(lastOut, s); if (!at && nempty(last)) saveEntry(last, s); last = s; save("last"); } static void saveEntry(S in, S out) { if (l(in) > maxLen || l(out) > maxLen) ret; in = simplifySentence2(in); print(getProgramID() + " saving: " + in + " -> " + out); inToOut.put(in, out); } static S getLastOut() { ret (S) callOpt(getBot("#1002979"), "getLastAnswer"); }
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: | #1002967 |
| Snippet name: | UA UB UC (#talkingbots) |
| Eternal ID of this version: | #1002967/1 |
| Text MD5: | 60b220e9d43cee5aedeb08d76c25874a |
| Transpilation MD5: | e99699e9b1bc28946ac2c7664ad75ca6 |
| Author: | stefan |
| Category: | nl bots |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-04-15 23:07:14 |
| Source code size: | 1255 bytes / 58 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 972 / 1127 |
| Referenced in: | [show references] |