!7 cmodule ClustersBot extends DynTalkBot2 { start { makeByServer = () -> new ByServer; useAGIBlueForDropPunctuation = false; preprocessAtSelfToMyName = false; } sclass Cluster { GlobalID globalID = aGlobalIDObject(); Set synonyms = ciSet(); *() {} *(S s) { synonyms.add(s); } } class ByServer extends DynTalkBot2.ByServer { new L clusters; Cluster topic; L searchForCluster(S s) { ret filter(clusters, c -> contains(c.synonyms, s)); } synchronized S processSimplifiedLine(S s, O... _) { try answer super.processSimplifiedLine(s, _); // adding authorized users etc. new Matches m; S sOld = s; s = dropPrefixOrNull(myPrefix(), s); if (s == null) { print("no got prefix: " + quote(myPrefix()) + " / " + quote(sOld)); null; } if (matchX2("do you know ...|name ...", s, m)) { L found = searchForCluster($1); if (empty(found)) { topic = new Cluster($1); clusters.add(topic); change(); ret "No I don't know " + $1; } topic = random(found); change(); ret (l(found) > 1 ? "I know multiple. " : "") + "You mean " + join(" = ", topic.synonyms) + "?"; } if (matchX2("he is ...|she is ...|it is ...|he's ...|she's ...|it's ...|they are ...", s, m)) { if (topic == null) ret "Who is?"; if (topic.synonyms.add($1)) { change(); ret "Aha. " + join(" = ", topic.synonyms); } else ret "Yup, I know"; } if "number of clusters" ret l_str(clusters); if (eqic(s, "help")) ret trim([[ Help text will go here. [Bot made by https://BotCompany.de] ]]).replace("@me", atSelf()); null; } } }