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

49
LINES

< > BotCompany Repo | #1001745 // Version Count Bot (has current total version count from server)

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

Libraryless. Click here for Pure Java version (3845L/27K/87K).

1  
!7
2  
3  
static volatile long updateInterval = 20000;
4  
static volatile long versionCount, lastAutoCheck, lastChange;
5  
static volatile long checks;
6  
7  
p {
8  
  addToMultiPort("Version Count Bot.");
9  
  updateLoop();
10  
}
11  
12  
static void updateLoop() {
13  
  thread "update loop" {
14  
    while (true) {
15  
      checkVersionCount();
16  
      sleep(updateInterval);
17  
    }
18  
  }
19  
}
20  
21  
static synchronized S answer(S s) {
22  
  new Matches m;
23  
  
24  
  if (match3("check now", s))
25  
    checkVersionCount();
26  
    
27  
  if (match3("num checks", s))
28  
    ret String.valueOf(checks);
29  
    
30  
  if (match3("get version count", s))
31  
    return versionCount == 0 ? "hold on, still loading" : format3("version count: *", versionCount);
32  
    
33  
  ret null;
34  
}
35  
36  
static void checkVersionCount() {
37  
  pcall {
38  
    ++checks;
39  
    long newCount = Long.parseLong(loadPageSilently("http://tinybrain.de:8080/tb-int/versioncount.php"));
40  
    lastAutoCheck = now();
41  
    synchronized(main.class) {
42  
      if (newCount != versionCount) {
43  
        versionCount = newCount;
44  
        lastChange = now();
45  
        print("Version count updated to " + versionCount + ".");
46  
      }
47  
    }
48  
  }
49  
}

Author comment

Began life as a copy of #1001383

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001745
Snippet name: Version Count Bot (has current total version count from server)
Eternal ID of this version: #1001745/3
Text MD5: 31d53a658143215ac854e4f8eeb88932
Transpilation MD5: e34e3b623716536c9c220f1e3db78e61
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-24 16:24:50
Source code size: 1140 bytes / 49 lines
Pitched / IR pitched: No / No
Views / Downloads: 632 / 2490
Version history: 2 change(s)
Referenced in: [show references]