!752 static class LineSaid extends Status { S lineID, text; *() {} *(O line) { lineID = getString(line, "id"); text = getString(line, "text"); } S answer(S s) { status(null); ret askSelf("dn add * to *", s, lineID); } } static class WhatShouldISayTo extends Status { S lineID, text; *() {} *(O line) { lineID = getString(line, "id"); text = getString(line, "text"); } S answer(S s) { status(null); new Matches m; if (matchStart("say", s, m)) { S text = unquote(m.rest().trim()); ret askSelf("dn add * to *", text, lineID); } ret null; } } answer { if "say something" exceptionToUser { L starters = cast call(getDialogEngine(), "findStarters"); if (empty(starters)) ret "Nothing found to say..."; O line = randomOne(starters); ret lineSaid(line); } try answer status_answer(s); if (attn()) exceptionToUser { O line = call(getDialogEngine(), "findStarter", s); if (line != null) { L refs = cast call(getDialogEngine(), "getReferences", line); line = randomOne(refs); if (line != null) ret lineSaid(line); } // make new entry line = call(getDialogEngine(), "add", s); status(new WhatShouldISayTo(line)); // ask what i should say ret "what should i say to that, master?"; } } static O getDialogEngine() { O dialogEngine = getBot("#1002666"); if (dialogEngine == null) ret "No dialog engine (install #1002666!)"; ret dialogEngine; } static S lineSaid(O line) { status(new LineSaid(line)); ret getString(line, "text"); }