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

60
LINES

< > BotCompany Repo | #1001215 // Update Snippet Cache Bot with latest changed snippets

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

Libraryless. Click here for Pure Java version (747L/6K/22K).

!747

m {
  !include #1000850 // TableFinder

  static DialogIO cacheBot;
  static int linesSent;
  
  p {
    cacheBot = findMandatoryBot("Snippet Cache Bot");

    for (Change c : getLatestChanges())
      updateCache(c);
      
    print("Done, collecting responses from cache bot.");
      
    while (linesSent > 0) {
      --linesSent;
      cacheBot.waitForLine();
      print("CacheBot says: " + cacheBot.readLineNoBlock());
    }
  }
  
  static S sourceInfo() {
    return "meta " + quote(getProgramID() + "@" + getComputerID() + "@" + now()) + " - ";
  }
  
  static void toCacheBot(S s) {
    print("@Cache Bot: " + s);
    cacheBot.sendLine(s);
    ++linesSent;
  }
  
  static void updateCache(Change c) {
    toCacheBot(sourceInfo() + "Just got it from the web. Snippet " + quote(c.id) + " now has md5 " + quote(c.md5) + " and title " + quote(c.title) + ".");
  }
  
  static class Change {
    S id, title, md5;
    
    *(S *id, S *title, S *md5) {}
    *() {}
  }
  
  static L<Change> getLatestChanges() {
    S html = loadPage("http://tinybrain.de:8080/tb/snippets.php?withmd5=1");
    new TableFinder finder;
    finder.go(html);
    
    new L<Change> changes;
    for (int i = 1; i < finder.data.size(); i++) {
      L<S> row = finder.getRow(i);
      S title = dropAllTags(row.get(0));
      S id = dropAllTags(row.get(1));
      S md5 = dropAllTags(row.get(2));
      changes.add(new Change(id, title, md5));
    }
    return changes;
  }
}

Author comment

Began life as a copy of #1001214

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001215
Snippet name: Update Snippet Cache Bot with latest changed snippets
Eternal ID of this version: #1001215/1
Text MD5: d2f18ce38c875c13db2ab88c1c934bb6
Transpilation MD5: bb9a12d26021d76d762d7f05ab522ca7
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-10-02 17:20:09
Source code size: 1524 bytes / 60 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 492 / 513
Referenced in: [show references]