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

65
LINES

< > BotCompany Repo | #1002243 // Transpilation MD5 Bot (developing)

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

Libraryless. Click here for Pure Java version (3053L/20K/67K).

// Logic: Checks every 10 seconds and clears full cache when
// anything changed in the DB. So it's as good as traffic-free
// when the DB is not changing.

!752

static int updateInterval = 10000;
static long lastVersionCount;

static new Map<S, S> md5s;

p {
  startBot("Version Count Bot", "#1001745");
  makeBot("Transpilation MD5 Bot.");
  updateLoop();
}

static void update() {
  new Matches m;
  if (match("version count: *", sendToLocalBot_cached("Version Count Bot", "get version count"), m)) {
    long count = parseLong(m.get(0));
    if (count != lastVersionCount) {
      lastVersionCount = count;
      clear();
    }
  }
}

static synchronized S answer(S s) {
  new Matches m;
  // current = get transpilation md5 only if transpilation is up to date
  if (match3("what is the current transpilation md5 of snippet *", s, m)) {
    S snippetID = formatSnippetID(m.unq(0));
    S md5 = md5s.get(snippetID);
    if (md5 == null) {
      md5 = getCurrentTranspilationMD5(snippetID);
      if (md5 == null) ret "null";
      md5s.put(snippetID, md5);
    }
    if (isMD5(md5))
      ret format("The current transpilation md5 of snippet * is *.", snippetID, md5);
    else
      ret "Transpilation is out of date.";
  }
  
  if (match3("clear snippet md5 cache", s, m)) {
    clear();
    ret "OK.";
  }
  
  if (match3("get snippet md5 cache size", s, m)) {
    ret "Cache entries: " + md5s.size();
  }
  
  ret null;
}

static synchronized void clear() {
  md5s.clear();
}

static S getCurrentTranspilationMD5(S snippetID) {
  S s = loadPage("http://tinybrain.de:8080/tb-int/get-transpilation-md5.php?id=" + parseSnippetID(snippetID)).trim();
  ret s;
}

Author comment

Began life as a copy of #1002079

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1002243
Snippet name: Transpilation MD5 Bot (developing)
Eternal ID of this version: #1002243/1
Text MD5: 2222b3a35fd3324698cd300dc8e6edc7
Transpilation MD5: 82fc37d498b8e69d25a182e593cda777
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-12-31 22:45:52
Source code size: 1728 bytes / 65 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 626 / 699
Referenced in: [show references]