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

1  
!747
2  
3  
m {
4  
  !include #1000850 // TableFinder
5  
6  
  static DialogIO cacheBot;
7  
  static int linesSent;
8  
  
9  
  p {
10  
    cacheBot = findMandatoryBot("Snippet Cache Bot");
11  
12  
    for (Change c : getLatestChanges())
13  
      updateCache(c);
14  
      
15  
    print("Done, collecting responses from cache bot.");
16  
      
17  
    while (linesSent > 0) {
18  
      --linesSent;
19  
      cacheBot.waitForLine();
20  
      print("CacheBot says: " + cacheBot.readLineNoBlock());
21  
    }
22  
  }
23  
  
24  
  static S sourceInfo() {
25  
    return "meta " + quote(getProgramID() + "@" + getComputerID() + "@" + now()) + " - ";
26  
  }
27  
  
28  
  static void toCacheBot(S s) {
29  
    print("@Cache Bot: " + s);
30  
    cacheBot.sendLine(s);
31  
    ++linesSent;
32  
  }
33  
  
34  
  static void updateCache(Change c) {
35  
    toCacheBot(sourceInfo() + "Just got it from the web. Snippet " + quote(c.id) + " now has md5 " + quote(c.md5) + " and title " + quote(c.title) + ".");
36  
  }
37  
  
38  
  static class Change {
39  
    S id, title, md5;
40  
    
41  
    *(S *id, S *title, S *md5) {}
42  
    *() {}
43  
  }
44  
  
45  
  static L<Change> getLatestChanges() {
46  
    S html = loadPage("http://tinybrain.de:8080/tb/snippets.php?withmd5=1");
47  
    new TableFinder finder;
48  
    finder.go(html);
49  
    
50  
    new L<Change> changes;
51  
    for (int i = 1; i < finder.data.size(); i++) {
52  
      L<S> row = finder.getRow(i);
53  
      S title = dropAllTags(row.get(0));
54  
      S id = dropAllTags(row.get(1));
55  
      S md5 = dropAllTags(row.get(2));
56  
      changes.add(new Change(id, title, md5));
57  
    }
58  
    return changes;
59  
  }
60  
}

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: 557 / 594
Referenced in: [show references]