!752 p { load("interestPoints"); load("ipInfos"); makeBot("Interest Points Bot"); } static new L interestPoints; static new Map ipInfos; static class Line { S user, text; S removedBy; *(S *user, S *text) {} *() {} public boolean equals(O o) { if (!(o instanceof Line)) ret false; Line l = cast o; ret eq(user, l.user) && eq(text, l.text); } } static class IP { S name; new L bumpedBy; new L lines; new L removedLines; *(S *name) {} *() {} void addBumpedBy(S user) { if (user == null) ret; bumpedBy.remove(user); bumpedBy.add(user); } } synchronized answer { S user = getUserName(); if (match("create interest point *", s, m) || match("open interest point *", s, m) || match("bump interest point *", s, m) || match("select interest point *", s, m)) { S point = m.unq(0); if (interestPoints.contains(point)) { if (eq(currentInterestPoint(), point)) ret "Interest point already selected."; else { interestPoints.remove(point); interestPoints.add(0, point); getIpInfo(point).addBumpedBy(getUserName()); save("ipInfos"); save("interestPoints"); ret format("Interest point * selected!", point); } } interestPoints.add(0, point); getIpInfo(point).addBumpedBy(user); save("ipInfos"); save("interestPoints"); ret format("OK, added & selected interest point *. Count now: *", point, l(interestPoints)); } if "list interest points" { ret structure(interestPoints); } /*if "close interest point *" { }*/ if (match("current interest point", s) || match("interest point", s)) { S ip = currentInterestPoint(); ret ip == null ? "no interest point selected" : quote(ip); } if "show interest point" { ret structure(ipInfos.get(currentInterestPoint())); } if "add to *: *" { // TODO: actually match the colon S point = m.unq(0), text = m.unq(1); IP ip = ipInfos.get(point); if (ip == null) ret "Please create interest point first"; Line l = new Line(user, text); if (ip.lines.contains(l)) ret "Line already there!"; ip.lines.add(l); save("ipInfos"); ret "Line added as #" + l(ip.lines); } } static S currentInterestPoint() { ret first(interestPoints); } static IP getIpInfo(S point) { IP ip = ipInfos.get(point); if (ip == null) ipInfos.put(point, ip = new IP(point)); ret ip; }