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).

1  
!7
2  
3  
set flag DynModule.
4  
5  
sclass TelegramThinkBot > AbstractTelegramThinkBot {
6  
  void thinkAbout(S s) {
7  
    s = trim(s);
8  
    
9  
    final new Matches m;
10  
    S procedure = nlLookup(mechMap("Telegram Procedures"), s, m);
11  
    if (procedure != null) {
12  
      procedure = expandDollarRefsToMatches(procedure, m, true);
13  
      print(">> " + procedure);
14  
      postMessage(strOrNull(javaEvalOrInterpret(procedure)));
15  
    }
16  
    
17  
    print("s=" + s);
18  
    S language = 'english;
19  
    if (swic_trim(s, "!german ", m)) {
20  
      language = 'german;
21  
      s = m.rest();
22  
      print("s=" + s);
23  
    }
24  
    ai_setLanguage(language);
25  
26  
    if (swic_trim(s, "!say ", m))
27  
      postMessage(m.rest());
28  
    
29  
    if (eq(s, "!gac"))
30  
      postMessage(random_gac36k());
31  
    
32  
    if (swic_trim(s, "!parse ", m))
33  
      postMessage(ai_renderCulledParseTree(ai_parseToTreeWithGuessing(m.rest())));
34  
    
35  
    if (swic_trim(s, "!simplify ", m))
36  
      postMessage(lines(ai_parseTree_simplifiedTexts(ai_parseToTreeWithGuessing(m.rest()))));
37  
    
38  
    /*if (telegram_amIAuthorized())*/ {
39  
      if (telegram_amIFullyAuthorized()) {
40  
      if (eq(s, "!fresh")) { dm_refreshTranspiler(); postMessage("OK"); }
41  
      
42  
        if (swic_trim(s, "!eval ", m))
43  
          postMessage(pcallOrExceptionText(func { strOrNull(javaEvalOrInterpret(m.rest())) }));
44  
        
45  
        if (swic_trim(s, "!real-eval ", m))
46  
          postMessage(pcallOrExceptionText(func { strOrNull(javaEval(m.rest())) }));
47  
      }
48  
        
49  
      if (swic_trim(s, "!rule ", m)) {
50  
        S rule = m.rest();
51  
        if (!telegram_authorizedToStoreRule(rule)) ret;
52  
        LS rules = trimAll(ai_unparsedTalkRules());
53  
        if (!contains(rules, rule)) { // TODO: ignore global IDs
54  
          rule = nlLogic_addGlobalID(rule);
55  
          appendToMechList_noUniq("NL Logic Examples", "\n" + rule);
56  
          postMessage("Rule saved as " + leadingSquareBracketOptions_id(rule) + ". Have " + n2(l(rules)+1, "rule") + ".");
57  
        }
58  
      }
59  
      
60  
      if (swic_trim(s, "!fact ", m)) {
61  
        S fact = m.rest();
62  
        LS facts = mL("Random facts");
63  
        if (!contains(facts, fact)) {
64  
          appendToMechList_noUniq("Random facts", fact);
65  
          postMessage("Fact saved. Have " + n2(l(facts)+1, "fact") + ".");
66  
        }
67  
      }
68  
      
69  
      if (eqic(s, "!deriveFacts"))
70  
        postMessage("Got " + n2(ai_applyFactToFactRules(), "fact") + ". Total: " + l(mL("Derived facts")));
71  
        
72  
      // end of authorized functions
73  
    }
74  
  }
75  
}

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: 455 / 14233
Version history: 29 change(s)
Referenced in: [show references]