Libraryless. Click here for Pure Java version (2397L/15K/51K).
!752 static new MultiMap<S, Line> map; static class Line { S text; S timestamp; Line(){ } *(S *text, S *timestamp) {} } static boolean saveLater; p{ load("#1002356", "map"); thread "msgs saver" { while (licensed()) { saveIt(); sleepSeconds(60); } } makeBot("Store messages bot"); } synchronized answer{ S username = ""; if(getUserName() == null){ username = "anonymous"; }else{ username = getUserName(); } if(matchStart("list all messages from *", s, m)){ S user = m.unq(0); boolean isMe = isMe(user); if (isMe) user = getUserName(); ret structure(map.get(user)); } if(match("list all users who said something", s)){ ret structure(map.keySet()); } if(matchStart("did * say something about *", s, m)){ S user = m.unq(0); boolean isMe = isMe(user); if (isMe) user = getUserName(); if(map.containsKey(user)){ List<Line> list = map.get(user); int times = 0; L<S> lolist = new L; for (int i = l(list)-1; i >= 0; i--) { if (indexOfIgnoreCase(list.get(i).text, m.unq(1)) >= 0){ times = times + 1; lolist.add(list.get(i).text); } } if (times == 0){ ret (isMe ? "You" : user) + " did not say anything about that."; }else{ ret lolist + "\n" + times +" results found"; } }else{ ret (isMe ? "You" : user) + " did not say anything yet."; } } Line line = new Line(s,getSlackTS()); map.put(username, line); saveLater = true; } synchronized static void saveIt() { if (saveLater) { time { print(programID() + ": Saving msgs."); save("#1002356", "map"); } saveLater = false; } } static void cleanUp() { saveIt(); } static boolean isMe(S user) { ret eqic(user, "I") || eqic(user, "me"); }
Began life as a copy of #1002356
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