Libraryless. Click here for Pure Java version (5851L/40K/130K).
1 | // Logic: asks Snippet MD5 Bot for current MD5 |
2 | |
3 | !752 |
4 | |
5 | m { |
6 | static DiskTextMap map; // snippet ID to text |
7 | |
8 | p { |
9 | map = new DiskTextMap("mymap"); |
10 | startBot("Snippet MD5 Bot", "#1002079"); |
11 | makeBot("Snippet Text Bot."); |
12 | } |
13 | |
14 | static synchronized S answer(S s) { |
15 | new Matches m; |
16 | if (match3("what is the text of snippet *", s, m)) { |
17 | S snippetID = formatSnippetID(m.unq(0)); |
18 | S answer = sendToLocalBot("Snippet MD5 Bot", "what is the md5 of snippet *", snippetID); |
19 | assertTrue(match("the md5 of snippet * is *", answer, m)); |
20 | S md5 = m.unq(1); |
21 | S text = map.get(snippetID); |
22 | if (text == null || neq(md5(text), md5)) { |
23 | text = loadSnippetVersion(snippetID, md5); |
24 | if (text == null) ret "null"; |
25 | map.put(snippetID, text); |
26 | } |
27 | ret format("The text of snippet * is *.", snippetID, text); |
28 | } |
29 | |
30 | if (match3("clear snippet text cache", s, m)) { |
31 | clear(); |
32 | ret "OK."; |
33 | } |
34 | |
35 | if (match3("get snippet text cache size", s, m)) { |
36 | ret "Cache entries: " + map.size(); |
37 | } |
38 | |
39 | ret null; |
40 | } |
41 | |
42 | static synchronized void clear() { |
43 | map.clear(); |
44 | } |
45 | } |
Began life as a copy of #1002079
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1002084 |
Snippet name: | Snippet Text Bot (seems to work) |
Eternal ID of this version: | #1002084/1 |
Text MD5: | 5963cfcd9f338842f62b57596354e005 |
Transpilation MD5: | ac85aa4a225b7a8534dc9ce07c2f07a9 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-06-09 03:18:18 |
Source code size: | 1201 bytes / 45 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 667 / 1976 |
Referenced in: | [show references] |