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

45
LINES

< > BotCompany Repo | #1002084 // Snippet Text Bot (seems to work)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (5851L/40K/130K).

// Logic: asks Snippet MD5 Bot for current MD5

!752

m {
  static DiskTextMap map; // snippet ID to text
  
  p {
    map = new DiskTextMap("mymap");
    startBot("Snippet MD5 Bot", "#1002079");
    makeBot("Snippet Text Bot.");
  }
  
  static synchronized S answer(S s) {
    new Matches m;
    if (match3("what is the text of snippet *", s, m)) {
      S snippetID = formatSnippetID(m.unq(0));
      S answer = sendToLocalBot("Snippet MD5 Bot", "what is the md5 of snippet *", snippetID);
      assertTrue(match("the md5 of snippet * is *", answer, m));
      S md5 = m.unq(1);
      S text = map.get(snippetID);
      if (text == null || neq(md5(text), md5)) {
        text = loadSnippetVersion(snippetID, md5);
        if (text == null) ret "null";
        map.put(snippetID, text);
      }
      ret format("The text of snippet * is *.", snippetID, text);
    }
    
    if (match3("clear snippet text cache", s, m)) {
      clear();
      ret "OK.";
    }
    
    if (match3("get snippet text cache size", s, m)) {
      ret "Cache entries: " + map.size();
    }
    
    ret null;
  }
  
  static synchronized void clear() {
    map.clear();
  }
}

Author comment

Began life as a copy of #1002079

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1002084
Snippet name: Snippet Text Bot (seems to work)
Eternal ID of this version: #1002084/1
Text MD5: 5963cfcd9f338842f62b57596354e005
Transpilation MD5: ac85aa4a225b7a8534dc9ce07c2f07a9
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-06-09 03:18:18
Source code size: 1201 bytes / 45 lines
Pitched / IR pitched: No / No
Views / Downloads: 593 / 1883
Referenced in: #1002093 - List All Commands Bot
#1002307 - NL Parser, hotwirable
#1002328 - NL Parser, implementing "empty" classes & ground class optimisation
#1002369 - NL Parser, reworking the interface (CURRENT)
#1002472 - NL Parser, implementing names & new eval order (superseded by #1002719)
#1002719 - "Bottom-Up" NL Parser, faster explainMatch (LIVE EVERYWHERE)
#3000190 - Answer for stefanreich(>> t 20 questions)
#3000195 - Answer for stefanreich (>> y)
#3000196 - Answer for stefanreich (>> y)
#3000197 - Answer for stefanreich (>> program data sizes)
#3000198 - Answer for stefanreich (>> program data sizes)
#3000199 - Answer for stefanreich (>> program data sizes)
#3000200 - Answer for stefanreich (>> program data sizes)
#3000201 - Answer for stefanreich (>> list all files)
#3000202 - Answer for stefanreich (>> T conversion bot)
#3000238 - Answer for stefanreich (>> t power bot)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)