Libraryless. Click here for Pure Java version (1792L/11K/37K).
1 | !752 |
2 | |
3 | static class LineSaid extends Status {
|
4 | S lineID, text; |
5 | |
6 | *() {}
|
7 | *(O line) {
|
8 | lineID = getString(line, "id"); |
9 | text = getString(line, "text"); |
10 | } |
11 | |
12 | S answer(S s) {
|
13 | status(null); |
14 | ret askSelf("dn add * to *", s, lineID);
|
15 | } |
16 | } |
17 | |
18 | static class WhatShouldISayTo extends Status {
|
19 | S lineID, text; |
20 | |
21 | *() {}
|
22 | *(O line) {
|
23 | lineID = getString(line, "id"); |
24 | text = getString(line, "text"); |
25 | } |
26 | |
27 | S answer(S s) {
|
28 | status(null); |
29 | new Matches m; |
30 | if (matchStart("say", s, m)) {
|
31 | S text = unquote(m.rest().trim()); |
32 | ret askSelf("dn add * to *", text, lineID);
|
33 | } |
34 | ret null; |
35 | } |
36 | } |
37 | |
38 | answer {
|
39 | if "say something" exceptionToUser {
|
40 | L starters = cast call(getDialogEngine(), "findStarters"); |
41 | if (empty(starters)) ret "Nothing found to say..."; |
42 | O line = randomOne(starters); |
43 | ret lineSaid(line); |
44 | } |
45 | |
46 | try answer status_answer(s); |
47 | |
48 | if (attn()) exceptionToUser {
|
49 | O line = call(getDialogEngine(), "findStarter", s); |
50 | if (line != null) {
|
51 | L refs = cast call(getDialogEngine(), "getReferences", line); |
52 | line = randomOne(refs); |
53 | if (line != null) |
54 | ret lineSaid(line); |
55 | } |
56 | |
57 | // make new entry |
58 | |
59 | line = call(getDialogEngine(), "add", s); |
60 | status(new WhatShouldISayTo(line)); |
61 | |
62 | // ask what i should say |
63 | ret "what should i say to that, master?"; |
64 | } |
65 | |
66 | |
67 | } |
68 | |
69 | static O getDialogEngine() {
|
70 | O dialogEngine = getBot("#1002666");
|
71 | if (dialogEngine == null) ret "No dialog engine (install #1002666!)"; |
72 | ret dialogEngine; |
73 | } |
74 | |
75 | static S lineSaid(O line) {
|
76 | status(new LineSaid(line)); |
77 | ret getString(line, "text"); |
78 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1002669 |
| Snippet name: | Dialog Network Action Bot (dev.) |
| Eternal ID of this version: | #1002669/1 |
| Text MD5: | 27b42ac2e7fcfe24a284a813d978c871 |
| Transpilation MD5: | 6bbc57b474e972021b0e6bb3dacda5f2 |
| Author: | stefan |
| Category: | eleu / javax |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-02-12 01:20:25 |
| Source code size: | 1699 bytes / 78 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1071 / 1153 |
| Referenced in: | [show references] |