Libraryless. Click here for Pure Java version (1912L/12K/43K).
!752 sclass Tag { S name; } sclass SlackMsg { S user, botName; // one of these is going to be set S userName; // looked up if user != null S type, text, ts; O reactions; S channelID; int index; new TreeSet<S> tags; } static PersistentMap<S, L<Tag>> tagMap; static PersistentLog<SlackMsg> msgs; static new L<SlackMsg> taggedMsgs; static new TreeMap<Integer, SlackMsg> msgsByIndex; static new MultiMap<S, SlackMsg> msgsByTag; p { tagMap = new PersistentMap("#1002192", "tagsByTS.log"); print("Tags: " + l(tagMap)); S channelName = "talkingbots"; msgs = new PersistentLog("#1002185", parseChannelName(channelName) + ".msgs"); print("Msgs: " + l(msgs)); if (empty(tagMap) || empty(msgs)) fail("no data"); //printStructure(last(msgs)); // put tags and index in messages int n = 1; for (SlackMsg msg : msgs) { L<Tag> tags = tagMap.get(msg.ts); /*if (nempty(tags)) print(structure(tags) + " " + structure(msg));*/ msg.index = n++; msgsByIndex.put(msg.index, msg); for (Tag t : unnull(tags)) { if (msg.tags.add(t.name)) msgsByTag.put(t.name, msg); } if (nempty(msg.tags)) taggedMsgs.add(msg); } print(l(taggedMsgs) + " tagged msgs."); for (SlackMsg msg : taggedMsgs) { for (S tag : msg.tags) { if (tag.startsWith("@") && isInteger(tag.substring(1))) pcall { int i = parseInt(tag.substring(1)); if (i < 0) i += msg.index; SlackMsg m2 = msgsByIndex.get(i); S t2 = m2 == null ? "NOT FOUND" : m2.userName + ": " + m2.text; S t1 = msg.userName + ": " + msg.text; //print(msg.text + " => " + (m2 == null ? "NOT FOUND" : m2.text)); print(t2); print(" " + t1); print(); } } } print("Bot greetings: " + structure(collect(msgsByTag.get("bot greeting"), "text"))); }
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: | #1003042 | 
| Snippet name: | Load Slack log & tags | 
| Eternal ID of this version: | #1003042/1 | 
| Text MD5: | 9b9889358b833afa572ab6bfcb872642 | 
| Transpilation MD5: | 3baa3e36b5ea4f8720ceb9a23f015580 | 
| Author: | stefan | 
| Category: | javax | 
| Type: | JavaX source code | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2016-04-25 16:01:07 | 
| Source code size: | 1934 bytes / 70 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 862 / 973 | 
| Referenced in: | [show references] |