Libraryless. Click here for Pure Java version (1541L/11K/36K).
!747 m { static new Map<S, S> cache; // "122" (or "t123") to md5 static long lastUpdate; p { readLocally("cache lastUpdate"); Android3 android = new Android3("Boss Bot."); android.startPort = 4990; makeAndroid3(android); } static synchronized S answer(S s) { new Matches m; if (match3("get cache size", s)) return cache.size() + " entries"; if (match3("when was your last update", s)) return "" + lastUpdate; if (match3("please update", s)) { update(); return "OK, done."; } if (match3("get md5 of *", s, m)) { S md5 = cache.get("" + parseSnippetID(unquote(m.m[0]))); return md5 != null ? format3("MD5: *", md5) : "Snippet not found."; } if (match3("get text of *", s, m) || match3("get text for *", s, m)) { S snippetID = "" + parseSnippetID(unquote(m.m[0])); S md5 = cache.get(snippetID); if (md5 == null) ret "Snippet not found."; S text = ""; if (!md5.equals("-")) text = loadText(snippetID, md5); ret format3("Text: *", text); } if (match3("get transpilation of *", s, m) || match3("get transpilation for *", s, m)) { S snippetID = "t" + parseSnippetID(unquote(m.m[0])); S md5 = cache.get(snippetID); if (md5 == null) ret "Transpilation not found."; S text = ""; if (!md5.equals("-")) text = loadText(snippetID, md5); ret format3("Text: *", text); } ret null; } static synchronized void update() { S s = loadPage("http://tinybrain.de:8080/tb-int/all-md5s.php?withtranspiled=1"); cache.clear(); for (S line : toLinesFullTrim(s)) { S[] tok = line.split(":"); if (tok.length != 2) fail("huch: " + structure(tok)); S snippetID = tok[0]; S md5 = tok[1]; cache.put(snippetID, md5); } saveLocally("cache"); lastUpdate = now(); saveLocally("lastUpdate"); } static File getTextFile(S snippetID, S md5) { return new File(programDir(), snippetID + "-" + md5 + ".txt"); } static synchronized S loadText(S snippetID, S md5) { File f = getTextFile(snippetID, md5); if (f.exists()) return loadTextFile(f); S text = loadTextFromSite(snippetID, md5); saveTextFile(f, text); return text; } static S loadTextFromSite(S snippetID, S md5) { S url; if (snippetID.startsWith("t")) url = "http://tinybrain.de:8080/tb-int/get-transpiled.php?raw=1&withlibs=1&id=" + snippetID.substring(1); else url = "http://tinybrain.de:8080/tb/get-version-raw.php?id=" + parseSnippetID(snippetID) + "&md5=" + urlencode(md5); // TODO: try a few times :) return loadPage(url); } }
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, dhtvkmknsjym, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001369 |
Snippet name: | Boss Bot (has up-to-date snippet contents) |
Eternal ID of this version: | #1001369/1 |
Text MD5: | c12c16ccc75cba3d6092d8c3c4267f29 |
Transpilation MD5: | 67d4f314660dd5b0c76930c8d25cc26d |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-10-12 00:59:04 |
Source code size: | 2837 bytes / 94 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 603 / 700 |
Referenced in: | #1001383 - Boss Bot v2 (with continuous update, developing) #3000202 - Answer for stefanreich (>> T conversion bot) #3000238 - Answer for stefanreich (>> t power bot) #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |