1 | static S voice = "Alex"; |
2 | static new ThreadLocal<Boolean> pivoMode; |
3 | |
4 | static L<S> matches = litlist( |
5 | "Was machen wir heute?", |
6 | "Frau Petersen besuchen!", |
7 | "hallo du ey hey hi assistent sag doch mal mir na ja so yo denn eigentlich und noch alles überhaupt schönes", |
8 | |
9 | "Was wollen wir da?", |
10 | "Viel Geld beantragen", |
11 | "und dann denn", |
12 | |
13 | "Ich soll dich demonstrieren", |
14 | "Na denn man los!", |
15 | "", |
16 | |
17 | "Kannst du rechnen?", |
18 | "Na klar!", |
19 | "auch", |
20 | |
21 | "" |
22 | ); |
23 | |
24 | static void pivoLoad() {
|
25 | load("voice");
|
26 | } |
27 | |
28 | static S setVoice(S v) {
|
29 | voice = v; |
30 | save("voice");
|
31 | ret "Hallo, hier ist " + v; |
32 | } |
33 | |
34 | static synchronized S answer(S s) {
|
35 | new Matches m; |
36 | if (!attn()) ret null; |
37 | if (!eq(getUserName (), "stefanreich") && !pivoMode. get ()) ret null; |
38 | |
39 | if "Alex" ret setVoice("Alex");
|
40 | if (match("Leo", s) || match("Leopold", s))
|
41 | ret setVoice("Leopold");
|
42 | if "Gudrun" ret setVoice("Gudrun");
|
43 | |
44 | /*if (matchQuestion_dropping("Was machen wir heute?",
|
45 | "hallo du ey hey hi assistent sag doch mal mir na ja so yo denn eigentlich und noch alles überhaupt schönes", s)) |
46 | ret whatWeDoToday;*/ |
47 | |
48 | for (int i = 0; i+2 < l(matches); i += 3) {
|
49 | S pat = matches.get(i); |
50 | S words = matches.get(i+2); |
51 | if (matchQuestion_dropping(pat, words, s)) |
52 | ret matches.get(i+1); |
53 | } |
54 | |
55 | L<S> tok = codeTokensOnly(javaTok(s)); |
56 | |
57 | if (l(tok) == 3 && eq(get(tok, 1), "+") |
58 | && isInteger(get(tok, 0)) && isInteger(get(tok, 2))) |
59 | ret str(bigint(get(tok, 0)).add(bigint(get(tok, 2)))); |
60 | |
61 | ret s; |
62 | } |
63 | |
64 | static boolean matchQuestion_dropping(S pat, S wordsToDrop, S s) {
|
65 | ret match(pat, dropWords(s, wordsToDrop)); |
66 | } |
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: | #1002931 |
| Snippet name: | Pivo Logic (include) |
| Eternal ID of this version: | #1002931/1 |
| Text MD5: | a343bd7aecd69afc4e8091f6d33d4f7f |
| Author: | stefan |
| Category: | eleu / nl |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-04-07 17:03:41 |
| Source code size: | 1718 bytes / 66 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 871 / 1092 |
| Referenced in: | [show references] |