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

75
LINES

< > BotCompany Repo | #1017583 // Telegram Think Bot v2 [Dyn Module, fading out]

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

Uses 408K of libraries. Compilation Failed (22676L/174K).

!7

set flag DynModule.

sclass TelegramThinkBot > AbstractTelegramThinkBot {
  void thinkAbout(S s) {
    s = trim(s);
    
    final new Matches m;
    S procedure = nlLookup(mechMap("Telegram Procedures"), s, m);
    if (procedure != null) {
      procedure = expandDollarRefsToMatches(procedure, m, true);
      print(">> " + procedure);
      postMessage(strOrNull(javaEvalOrInterpret(procedure)));
    }
    
    print("s=" + s);
    S language = 'english;
    if (swic_trim(s, "!german ", m)) {
      language = 'german;
      s = m.rest();
      print("s=" + s);
    }
    ai_setLanguage(language);

    if (swic_trim(s, "!say ", m))
      postMessage(m.rest());
    
    if (eq(s, "!gac"))
      postMessage(random_gac36k());
    
    if (swic_trim(s, "!parse ", m))
      postMessage(ai_renderCulledParseTree(ai_parseToTreeWithGuessing(m.rest())));
    
    if (swic_trim(s, "!simplify ", m))
      postMessage(lines(ai_parseTree_simplifiedTexts(ai_parseToTreeWithGuessing(m.rest()))));
    
    /*if (telegram_amIAuthorized())*/ {
      if (telegram_amIFullyAuthorized()) {
      if (eq(s, "!fresh")) { dm_refreshTranspiler(); postMessage("OK"); }
      
        if (swic_trim(s, "!eval ", m))
          postMessage(pcallOrExceptionText(func { strOrNull(javaEvalOrInterpret(m.rest())) }));
        
        if (swic_trim(s, "!real-eval ", m))
          postMessage(pcallOrExceptionText(func { strOrNull(javaEval(m.rest())) }));
      }
        
      if (swic_trim(s, "!rule ", m)) {
        S rule = m.rest();
        if (!telegram_authorizedToStoreRule(rule)) ret;
        LS rules = trimAll(ai_unparsedTalkRules());
        if (!contains(rules, rule)) { // TODO: ignore global IDs
          rule = nlLogic_addGlobalID(rule);
          appendToMechList_noUniq("NL Logic Examples", "\n" + rule);
          postMessage("Rule saved as " + leadingSquareBracketOptions_id(rule) + ". Have " + n2(l(rules)+1, "rule") + ".");
        }
      }
      
      if (swic_trim(s, "!fact ", m)) {
        S fact = m.rest();
        LS facts = mL("Random facts");
        if (!contains(facts, fact)) {
          appendToMechList_noUniq("Random facts", fact);
          postMessage("Fact saved. Have " + n2(l(facts)+1, "fact") + ".");
        }
      }
      
      if (eqic(s, "!deriveFacts"))
        postMessage("Got " + n2(ai_applyFactToFactRules(), "fact") + ". Total: " + l(mL("Derived facts")));
        
      // end of authorized functions
    }
  }
}

Author comment

Began life as a copy of #1017568

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1017583
Snippet name: Telegram Think Bot v2 [Dyn Module, fading out]
Eternal ID of this version: #1017583/30
Text MD5: 9bd8ad6267fd527234a13265ddcab766
Transpilation MD5: 5b669485d905202bc756351f711d7451
Author: stefan
Category: javax / telegram
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-08-27 22:57:43
Source code size: 2530 bytes / 75 lines
Pitched / IR pitched: No / No
Views / Downloads: 454 / 14231
Version history: 29 change(s)
Referenced in: [show references]