Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

48
LINES

< > BotCompany Repo | #1023494 // Monkey

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 5909K of libraries. Click here for Pure Java version (11309L/63K).

!7

cmodule Monkey > DynDiscordHopper {
  switchable S myName = "Monkey";
  
  transient PKIKeyPair keys;
  
  start {
    keys = keyPairForProgram();
    dm_vmBus_onMessage_q('discordGuildLeave, voidfunc(Map map) {
      ret unless map.get('module) == module();
      O user = rcall getUser(map.get('event));
      S name = cast rcall getName(user);
      postInChannel(preferredChannelID, nempty(name) ? name + " just left us" : "I sense a leaver");
    });
  }
  
  @Override S answer(S input, Map map) {
    ret mapEachLine_tlft_nempties(input, s -> {
      new Matches m;
      
      if "what's your name" ret myName;
      
      if (swic_trim(s, "!power ", m)) {
        ret or2(joinWithSpacedPlus(ai_powerWordsExpand(agiBlue_parsedPowerWords(), tok_splitAtPlus(m.rest()))), "No results");
      }
      
      try answer super.answer(s, map);
      //try answer agiBlue_getAnswer(s);
      try answer agiBlue_lookup(s, 'answer , /*'is, 'means*/);
      
      if (flexMatchIC("what does * mean", s, m))
        //try answer agiBlue_lookup($1, 'means);
        try answer random(agiBlue_multiLookupInAllSlices($1, 'means);
      
      if (contains(s, "..."))
        try answer random(listMinusElementIC(s, (LS) collect q(jsonDecodeList(loadPageWithParams("http://agi.blue/bot/allPagesContainingRegexp", q := "^" + ellipsisToDotStarRegexp(s) + "$", max := 10)))));
        
      T3S triple = agiBlue_parseTriple(s);
      if (triple != null && !any isDollarVar(tripleToList(triple))) {
        agiBot_postSignedEntry(keys, triple);
        ret "Stored. <" + agiBlue_linkForPhrase(triple.a) + ">";
      }

      null;
    });
  }
}

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: 452 / 32440
Version history: 35 change(s)
Referenced in: #1023928 - eeZee [LIVE, socket/http]
#1024114 - GBot (Discord Bot that googles, v2, old)
#1024415 - Giraffe (bot based on an agi.blue slice)