Uses 5909K of libraries. Click here for Pure Java version (9822L/52K).
1 | !7 |
2 | |
3 | cmodule ClustersBot extends DynTalkBot2<ClustersBot.ByServer> { |
4 | start { |
5 | makeByServer = () -> new ByServer; |
6 | useAGIBlueForDropPunctuation = false; |
7 | preprocessAtSelfToMyName = false; |
8 | } |
9 | |
10 | class ByServer extends DynTalkBot2.ByServer { |
11 | delegate Cluster to StringClustersWithIDs. |
12 | |
13 | new StringClustersWithIDs clusters; |
14 | Cluster topic; |
15 | |
16 | void _doneLoading { clusters.onChange(r change); } |
17 | |
18 | synchronized S processSimplifiedLine(S s, O... _) { |
19 | try answer super.processSimplifiedLine(s, _); // adding authorized users etc. |
20 | |
21 | new Matches m; |
22 | if null (s = dropMyPrefixOrNull(s)) null; |
23 | |
24 | if (matchX2("do you know ...|name ...", s, m)) { |
25 | L<Cluster> found = clusters.searchForCluster($1); |
26 | if (empty(found)) { |
27 | topic = clusters.newCluster($1); |
28 | ret "No I don't know " + $1; |
29 | } |
30 | topic = random(found); change(); |
31 | ret (l(found) > 1 ? "I know multiple. " : "") |
32 | + "You mean " + join(" = ", topic.synonyms) + "?"; |
33 | } |
34 | |
35 | if (matchX2("he is ...|she is ...|it is ...|he's ...|she's ...|it's ...|they are ...", s, m)) { |
36 | if (topic == null) ret "Who is?"; |
37 | if (topic.synonyms.add($1)) { |
38 | change(); |
39 | ret "Aha. " + join(" = ", topic.synonyms); |
40 | } else |
41 | ret "Yup, I know"; |
42 | } |
43 | |
44 | if "number of clusters" ret l_str(clusters.clusters); |
45 | |
46 | if (eqic(s, "help")) |
47 | ret ltrim([[ |
48 | I am a bot that knows synonyms. DB size: ]] + l(clusters.clusters) + [[ |
49 | |
50 | Stuff to say. |
51 | @me do you know james brown? |
52 | @me he is a singer |
53 | @me name an activist |
54 | @me number of clusters |
55 | |
56 | [Bot made by https://BotCompany.de] |
57 | ]]).replace("@me", atSelf()); |
58 | |
59 | null; |
60 | } |
61 | } |
62 | } |
Began life as a copy of #1025290
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: | #1025304 |
Snippet name: | Clusters Bot [shortened, LIVE] |
Eternal ID of this version: | #1025304/13 |
Text MD5: | 9a8a489c534e5d24b25f7aff3e010b52 |
Transpilation MD5: | f6d0d844318338ac27de0126d45680c2 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-09-22 13:27:44 |
Source code size: | 1801 bytes / 62 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 344 / 24521 |
Version history: | 12 change(s) |
Referenced in: | [show references] |