Libraryless. Click here for Pure Java version (2125L/13K/46K).
1 | !752 |
2 | |
3 | p {
|
4 | load("interestPoints");
|
5 | load("ipInfos");
|
6 | makeBot("Interest Points Bot");
|
7 | } |
8 | |
9 | static new L<S> interestPoints; |
10 | |
11 | static new Map<S, IP> ipInfos; |
12 | |
13 | static class Line {
|
14 | S user, text; |
15 | S removedBy; |
16 | |
17 | *(S *user, S *text) {}
|
18 | *() {}
|
19 | |
20 | public boolean equals(O o) {
|
21 | if (!(o instanceof Line)) ret false; |
22 | Line l = cast o; |
23 | ret eq(user, l.user) && eq(text, l.text); |
24 | } |
25 | } |
26 | |
27 | static class IP {
|
28 | S name; |
29 | new L<S> bumpedBy; |
30 | new L<Line> lines; |
31 | new L<Line> removedLines; |
32 | |
33 | *(S *name) {}
|
34 | *() {}
|
35 | |
36 | void addBumpedBy(S user) {
|
37 | if (user == null) ret; |
38 | bumpedBy.remove(user); |
39 | bumpedBy.add(user); |
40 | } |
41 | } |
42 | |
43 | synchronized answer {
|
44 | S user = getUserName(); |
45 | |
46 | 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)) {
|
47 | S point = m.unq(0); |
48 | if (interestPoints.contains(point)) {
|
49 | if (eq(currentInterestPoint(), point)) |
50 | ret "Interest point already selected."; |
51 | else {
|
52 | interestPoints.remove(point); |
53 | interestPoints.add(0, point); |
54 | getIpInfo(point).addBumpedBy(getUserName()); |
55 | save("ipInfos");
|
56 | save("interestPoints");
|
57 | ret format("Interest point * selected!", point);
|
58 | } |
59 | } |
60 | interestPoints.add(0, point); |
61 | getIpInfo(point).addBumpedBy(user); |
62 | save("ipInfos");
|
63 | save("interestPoints");
|
64 | ret format("OK, added & selected interest point *. Count now: *", point, l(interestPoints));
|
65 | } |
66 | |
67 | if "list interest points" {
|
68 | ret structure(interestPoints); |
69 | } |
70 | |
71 | /*if "close interest point *" {
|
72 | }*/ |
73 | |
74 | if (match("current interest point", s) || match("interest point", s)) {
|
75 | S ip = currentInterestPoint(); |
76 | ret ip == null ? "no interest point selected" : quote(ip); |
77 | } |
78 | |
79 | if "show interest point" {
|
80 | ret structure(ipInfos.get(currentInterestPoint())); |
81 | } |
82 | |
83 | if "add to *: *" { // TODO: actually match the colon
|
84 | S point = m.unq(0), text = m.unq(1); |
85 | IP ip = ipInfos.get(point); |
86 | if (ip == null) ret "Please create interest point first"; |
87 | Line l = new Line(user, text); |
88 | if (ip.lines.contains(l)) |
89 | ret "Line already there!"; |
90 | ip.lines.add(l); |
91 | save("ipInfos");
|
92 | ret "Line added as #" + l(ip.lines); |
93 | } |
94 | } |
95 | |
96 | static S currentInterestPoint() {
|
97 | ret first(interestPoints); |
98 | } |
99 | |
100 | static IP getIpInfo(S point) {
|
101 | IP ip = ipInfos.get(point); |
102 | if (ip == null) |
103 | ipInfos.put(point, ip = new IP(point)); |
104 | ret ip; |
105 | } |
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: | #1002242 |
| Snippet name: | Interest Points Bot (developing) |
| Eternal ID of this version: | #1002242/1 |
| Text MD5: | 63af22063e0c340a53a9d15b509117bb |
| Transpilation MD5: | 2957072031b0b32d382657c76168f2f8 |
| Author: | stefan |
| Category: | nl bots |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-01-02 18:01:19 |
| Source code size: | 2582 bytes / 105 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 918 / 1847 |
| Referenced in: | [show references] |