Libraryless. Click here for Pure Java version (1106L/8K/24K).
1 | !759 |
2 | |
3 | // Should be an "always" bot so it notices mode changes. |
4 | |
5 | static new HashMap<S, Long> on; // dialog ID -> start time |
6 | |
7 | static long timeout = 5*60*1000; // 5 minutes |
8 | |
9 | static L<S> nastyStuff = toLinesFullTrim([[ |
10 | Go away! |
11 | What do you want? |
12 | I DON'T KNOW |
13 | I AM BORED |
14 | Do it yourself! |
15 | I'm not your bitch! |
16 | Leave me alone! |
17 | You annoy me!! |
18 | ]]); |
19 | |
20 | synchronized static S answer(S s) {
|
21 | S dialog = getDialogID(); |
22 | //printF("nasty: * *", dialog, s);
|
23 | if (match("mode nasty", s) || match("nasty mode", s)) {
|
24 | print("Nasty on: " + getDialogID());
|
25 | on.put(dialog, now()); |
26 | } else if (isNasty() && (match("mode *", s) || match("* mode", s) || match("help", s) || match("exit", s) || match("stop", s))) {
|
27 | print("Nasty off: " + dialog);
|
28 | on.remove(dialog); |
29 | ret "OK, exiting nasty mode."; |
30 | } else if (match("mode", s) && isNasty())
|
31 | ret "I'm in " + quote("nasty") + " mode (" + formatSnippetID(getProgramID()) + ")";
|
32 | |
33 | if (!isNasty()) null; |
34 | |
35 | ret randomElement(nastyStuff); |
36 | } |
37 | |
38 | static boolean isNasty() {
|
39 | cleanUpMap(); |
40 | ret on.containsKey(getDialogID()); |
41 | } |
42 | |
43 | // remove the expired entries |
44 | static void cleanUpMap() {
|
45 | new HashMap<S, Long> newMap; |
46 | for (S dialogID : keys(on)) {
|
47 | long time = on.get(dialogID); |
48 | if (!isExpired(time, timeout)) |
49 | newMap.put(dialogID, time); |
50 | } |
51 | on = newMap; |
52 | } |
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: | #1002477 |
| Snippet name: | Nasty Eleu |
| Eternal ID of this version: | #1002477/1 |
| Text MD5: | f1f8826ee2a1dc7766ea0da2deb8cd10 |
| Transpilation MD5: | b0d97daeb72f791d3a445d2c08ce7c0f |
| Author: | stefan |
| Category: | eleu |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-01-26 19:43:49 |
| Source code size: | 1366 bytes / 52 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 946 / 1411 |
| Referenced in: | [show references] |