Uses 5909K of libraries. Click here for Pure Java version (11309L/63K).
1 | !7 |
2 | |
3 | cmodule Monkey > DynDiscordHopper { |
4 | switchable S myName = "Monkey"; |
5 | |
6 | transient PKIKeyPair keys; |
7 | |
8 | start { |
9 | keys = keyPairForProgram(); |
10 | dm_vmBus_onMessage_q('discordGuildLeave, voidfunc(Map map) { |
11 | ret unless map.get('module) == module(); |
12 | O user = rcall getUser(map.get('event)); |
13 | S name = cast rcall getName(user); |
14 | postInChannel(preferredChannelID, nempty(name) ? name + " just left us" : "I sense a leaver"); |
15 | }); |
16 | } |
17 | |
18 | @Override S answer(S input, Map map) { |
19 | ret mapEachLine_tlft_nempties(input, s -> { |
20 | new Matches m; |
21 | |
22 | if "what's your name" ret myName; |
23 | |
24 | if (swic_trim(s, "!power ", m)) { |
25 | ret or2(joinWithSpacedPlus(ai_powerWordsExpand(agiBlue_parsedPowerWords(), tok_splitAtPlus(m.rest()))), "No results"); |
26 | } |
27 | |
28 | try answer super.answer(s, map); |
29 | //try answer agiBlue_getAnswer(s); |
30 | try answer agiBlue_lookup(s, 'answer , /*'is, 'means*/); |
31 | |
32 | if (flexMatchIC("what does * mean", s, m)) |
33 | //try answer agiBlue_lookup($1, 'means); |
34 | try answer random(agiBlue_multiLookupInAllSlices($1, 'means); |
35 | |
36 | if (contains(s, "...")) |
37 | try answer random(listMinusElementIC(s, (LS) collect q(jsonDecodeList(loadPageWithParams("http://agi.blue/bot/allPagesContainingRegexp", q := "^" + ellipsisToDotStarRegexp(s) + "$", max := 10))))); |
38 | |
39 | T3S triple = agiBlue_parseTriple(s); |
40 | if (triple != null && !any isDollarVar(tripleToList(triple))) { |
41 | agiBot_postSignedEntry(keys, triple); |
42 | ret "Stored. <" + agiBlue_linkForPhrase(triple.a) + ">"; |
43 | } |
44 | |
45 | null; |
46 | }); |
47 | } |
48 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1023494 |
Snippet name: | Monkey |
Eternal ID of this version: | #1023494/36 |
Text MD5: | ef54ac918347f2ea64f74bd393d249c7 |
Transpilation MD5: | 508445cfa74ca9e92199e21763c5102f |
Author: | stefan |
Category: | javax / discord / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-08-17 22:06:04 |
Source code size: | 1688 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 451 / 32438 |
Version history: | 35 change(s) |
Referenced in: | [show references] |