Libraryless. Click here for Pure Java version (2293L/14K/49K).
1 | !752 |
2 | static new MultiMap<S, Line> map; |
3 | static class Line { |
4 | S text; |
5 | S timestamp; |
6 | |
7 | Line(){ |
8 | |
9 | } |
10 | *(S *text, S *timestamp) {} |
11 | } |
12 | p{ |
13 | makeBot("Store messages bot"); |
14 | load("map"); |
15 | } |
16 | |
17 | synchronized answer{ |
18 | S username = ""; |
19 | if(getUserName() == null){ |
20 | username = "anonymous"; |
21 | }else{ |
22 | username = getUserName(); |
23 | } |
24 | if(matchStart("list all messages from *", s, m)){ |
25 | ret structure(map.get(m.unq(0))); |
26 | } |
27 | if(match("list all users", s)){ |
28 | ret structure(map.keySet()); |
29 | } |
30 | if(matchStart("did * say something about *", s, m)){ |
31 | if(map.containsKey(m.unq(0))){ |
32 | List<Line> list = map.get(m.unq(0)); |
33 | int times = 0; |
34 | L<S> lolist = new L; |
35 | for (int i = l(list)-1; i >= 0; i--) { |
36 | if(list.get(i).text.contains(m.unq(1))){ |
37 | times = times + 1; |
38 | lolist.add(list.get(i).text); |
39 | } |
40 | } |
41 | if (times == 0){ |
42 | ret "no results found"; |
43 | }else{ |
44 | ret lolist + "\n" + times +" results found"; |
45 | } |
46 | }else{ |
47 | ret m.unq(0) + " did not say anything."; |
48 | } |
49 | } |
50 | Line line = new Line(s,getSlackTS()); |
51 | map.put(username, line); |
52 | save("map"); |
53 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1002356 |
Snippet name: | Store messages bot |
Eternal ID of this version: | #1002356/1 |
Text MD5: | 00707ecb99cf1c4f37125fd7e8066388 |
Transpilation MD5: | 69f2caf0c62d1c9fd01eefe730cc8a54 |
Author: | bgrgndz |
Category: | |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-01-15 22:37:02 |
Source code size: | 1191 bytes / 53 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 949 / 1341 |
Referenced in: | [show references] |