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 tags; } static PersistentMap> tagMap; static PersistentLog msgs; static new L taggedMsgs; static new TreeMap msgsByIndex; static new MultiMap msgsByTag; static void init() { 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 tags = tagMap.get(msg.ts); /*if (nempty(tags)) print(structure(tags) + " " + structure(msg));*/ msg.text = trim(msg.text); 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."); } static void filterTag(S tag) { for (SlackMsg msg : msgs) { msg.tags = msg.tags.contains(tag) ? littreeset(tag) : main. littreeset(); } }