!747 m { static new Map convos; // mapped by dialog ID static class Convo { S dialogID; long date; L lines; S botID; S computerID; } p { readLocally("convos"); print("Conversations in my database: " + convos.size()); makeAndroid("Conversations Log Bot."); } static synchronized S answer(S s) { new Matches m; if (match3("New dialog. dialog id: *. date: *. computer ID: *, bot ID: *. lines: *", s, m)) { new Convo x; x.dialogID = unquote(m.m[0]); x.date = parseLong(unquote(m.m[1])); x.computerID = unquote(m.m[2]); x.botID = unquote(m.m[3]); x.lines = (List) unstructure(unquote(m.m[4])); convos.put(x.dialogID, x); saveLocally("convos"); return "OK, now " + convos.size() + " conversations."; } if (match3("Add line to dialog. dialog id: *. line: *", s, m)) { S dialogID = unquote(m.m[0]); Convo x = convos.get(dialogID); if (x == null) return format3("Dialog not found: *", dialogID); x.lines.add(unquote(m.m[1])); return "OK, now " + x.lines.size() + " lines in conversation."; } return standardQuery(s, "convos"); } }