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

28
LINES

< > BotCompany Repo | #1001768 // Who Is Online Bot

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

Libraryless. Click here for Pure Java version (1832L/12K/40K).

!747

m {
  static new Map<S, Long> lastSeen; // computer ID to timestamp
  
  p {
    readLocally("lastSeen");
    makeAndroid3("Who Is Online Bot.");
  }
  
  static synchronized S answer(S s) {
    new Matches m;
    if (match3("I am online. -*", s, m)) {
      S computerID = m.unq(0);
      lastSeen.put(computerID, now());
      saveLocally("lastSeen");
      print("Got ping from " + computerID + ".");
      ret "OK, noted.";
    }
    
    if (match3("When was * last online?", s, m)) {
      Long time = lastSeen.get(m.unq(0));
      ret time != null ? format3("at *", time) : "never";
    }
    
    ret standardQuery(s, "lastSeen");
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001768
Snippet name: Who Is Online Bot
Eternal ID of this version: #1001768/1
Text MD5: 84e7d3c04db42f27e17c7cf839074b0d
Transpilation MD5: e3e3a783adb6bec4e2e8e351886fc1ad
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-11-13 17:22:57
Source code size: 677 bytes / 28 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 582 / 782
Referenced in: #1001248 - Public Comm Bot with forwarding (LIVE)
#3000195 - Answer for stefanreich (>> y)
#3000196 - Answer for stefanreich (>> y)
#3000197 - Answer for stefanreich (>> program data sizes)
#3000198 - Answer for stefanreich (>> program data sizes)
#3000199 - Answer for stefanreich (>> program data sizes)
#3000200 - Answer for stefanreich (>> program data sizes)
#3000201 - Answer for stefanreich (>> list all files)
#3000202 - Answer for stefanreich (>> T conversion bot)
#3000238 - Answer for stefanreich (>> t power bot)
#3000382 - Answer for ferdie (>> t = 1, f = 0)