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

!7

static volatile long updateInterval = 20000;
static volatile long versionCount, lastAutoCheck, lastChange;
static volatile long checks;

p {
  addToMultiPort("Version Count Bot.");
  updateLoop();
}

static void updateLoop() {
  thread "update loop" {
    while (true) {
      checkVersionCount();
      sleep(updateInterval);
    }
  }
}

static synchronized S answer(S s) {
  new Matches m;
  
  if (match3("check now", s))
    checkVersionCount();
    
  if (match3("num checks", s))
    ret String.valueOf(checks);
    
  if (match3("get version count", s))
    return versionCount == 0 ? "hold on, still loading" : format3("version count: *", versionCount);
    
  ret null;
}

static void checkVersionCount() {
  pcall {
    ++checks;
    long newCount = Long.parseLong(loadPageSilently("http://tinybrain.de:8080/tb-int/versioncount.php"));
    lastAutoCheck = now();
    synchronized(main.class) {
      if (newCount != versionCount) {
        versionCount = newCount;
        lastChange = now();
        print("Version count updated to " + versionCount + ".");
      }
    }
  }
}

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: 633 / 2490
Version history: 2 change(s)
Referenced in: #1001747 - Snippet Title Bot
#1002006 - Examples JavaX/Python (output of #1002005)
#1002079 - Snippet MD5 Bot (seems to work)
#1002243 - Transpilation MD5 Bot (developing)
#3000202 - Answer for stefanreich (>> T conversion bot)
#3000238 - Answer for stefanreich (>> t power bot)
#3000382 - Answer for ferdie (>> t = 1, f = 0)