Uses 5909K of libraries. Click here for Pure Java version (9740L/51K).
!7 cmodule ClustersBot extends DynTalkBot2<ClustersBot.ByServer> { start { makeByServer = () -> new ByServer; useAGIBlueForDropPunctuation = false; preprocessAtSelfToMyName = false; } sclass Cluster { GlobalID globalID = aGlobalIDObject(); Set<S> synonyms = ciSet(); *() {} *(S s) { synonyms.add(s); } } class ByServer extends DynTalkBot2.ByServer { new L<Cluster> clusters; Cluster topic; L<Cluster> 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<Cluster> 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; } } }
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025290 |
Snippet name: | Clusters Bot [old] |
Eternal ID of this version: | #1025290/18 |
Text MD5: | 07df9b2582bec9aabeb18d9c01cc3ac0 |
Transpilation MD5: | 2d7311a7434f459e558f796d47a934e4 |
Author: | stefan |
Category: | |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-09-20 14:36:34 |
Source code size: | 1955 bytes / 72 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 301 / 24591 |
Version history: | 17 change(s) |
Referenced in: | [show references] |