Download Jar. Libraryless. Click here for Pure Java version (9690L/68K).
1 | // Logic: Checks every 5 minutes and clears full cache when |
2 | // anything changed in the DB. So it's as good as traffic-free |
3 | // when the DB is not changing. |
4 | |
5 | !7 |
6 | |
7 | static int updateInterval = 5*60000; |
8 | static long lastVersionCount; |
9 | |
10 | static new Map<S, S> titles; |
11 | |
12 | p {
|
13 | startBot("Version Count Bot", "#1001745");
|
14 | makeAndroid3("Snippet Title Bot.");
|
15 | updateLoop(); |
16 | } |
17 | |
18 | static void update() {
|
19 | new Matches m; |
20 | if (match3("version count: *", sendToLocalBot_cached("Version Count Bot", "get version count"), m)) {
|
21 | long count = parseLong(m.get(0)); |
22 | if (count != lastVersionCount) {
|
23 | lastVersionCount = count; |
24 | clear(); |
25 | } |
26 | } |
27 | } |
28 | |
29 | static synchronized S answer(S s) {
|
30 | new Matches m; |
31 | if (match3("what is the title of snippet *", s, m)) {
|
32 | S snippetID = formatSnippetID(m.unq(0)); |
33 | S title = titles.get(snippetID); |
34 | if (title == null) {
|
35 | title = getSnippetTitle(snippetID); |
36 | if (title == null) ret "null"; |
37 | titles.put(snippetID, title); |
38 | } |
39 | ret format("The title of snippet * is *.", snippetID, title);
|
40 | } |
41 | |
42 | if (match3("clear snippet title cache", s, m)) {
|
43 | clear(); |
44 | ret "OK."; |
45 | } |
46 | |
47 | if (match3("get snippet title cache size", s, m)) {
|
48 | ret "Cache entries: " + titles.size(); |
49 | } |
50 | |
51 | ret null; |
52 | } |
53 | |
54 | static synchronized void clear() {
|
55 | titles.clear(); |
56 | } |
download show line numbers debug dex old transpilations
Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1001747 |
| Snippet name: | Snippet Title Bot |
| Eternal ID of this version: | #1001747/4 |
| Text MD5: | 303235a90f2ad65c7ab8d7ceed43e2db |
| Transpilation MD5: | 4a9099e2d2463357b25272dd3e4a9a83 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX source code (desktop) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-12-14 04:28:26 |
| Source code size: | 1367 bytes / 56 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1007 / 6237 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |