Libraryless. Click here for Pure Java version (1412L/10K/33K).
1 | !747 |
2 | |
3 | m {
|
4 | static new Map<S, Convo> convos; // mapped by dialog ID |
5 | |
6 | static class Convo {
|
7 | S dialogID; |
8 | long date; |
9 | L<S> lines; |
10 | S botID; |
11 | S computerID; |
12 | } |
13 | |
14 | p {
|
15 | readLocally("convos");
|
16 | print("Conversations in my database: " + convos.size());
|
17 | makeAndroid("Conversations Log Bot.");
|
18 | } |
19 | |
20 | static synchronized S answer(S s) {
|
21 | new Matches m; |
22 | |
23 | if (match3("New dialog. dialog id: *. date: *. computer ID: *, bot ID: *. lines: *", s, m)) {
|
24 | new Convo x; |
25 | x.dialogID = unquote(m.m[0]); |
26 | x.date = parseLong(unquote(m.m[1])); |
27 | x.computerID = unquote(m.m[2]); |
28 | x.botID = unquote(m.m[3]); |
29 | x.lines = (List) unstructure(unquote(m.m[4])); |
30 | convos.put(x.dialogID, x); |
31 | saveLocally("convos");
|
32 | return "OK, now " + convos.size() + " conversations."; |
33 | } |
34 | |
35 | if (match3("Add line to dialog. dialog id: *. line: *", s, m)) {
|
36 | S dialogID = unquote(m.m[0]); |
37 | Convo x = convos.get(dialogID); |
38 | if (x == null) |
39 | return format3("Dialog not found: *", dialogID);
|
40 | x.lines.add(unquote(m.m[1])); |
41 | return "OK, now " + x.lines.size() + " lines in conversation."; |
42 | } |
43 | |
44 | return standardQuery(s, "convos"); |
45 | } |
46 | } |
Began life as a copy of #1001245
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1001307 |
| Snippet name: | Conversations Logger Bot |
| Eternal ID of this version: | #1001307/1 |
| Text MD5: | 7e6e69ef378adafc5e204ed8736816f1 |
| Transpilation MD5: | 3ab168d65d822554d9562d9acee9884d |
| Author: | stefan |
| Category: | |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-10-08 18:40:04 |
| Source code size: | 1266 bytes / 46 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 858 / 1172 |
| Referenced in: | [show references] |