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

39
LINES

< > BotCompany Repo | #1009802 // startInternetTrafficCountBot

JavaX fragment (include)

1  
static startInternetTrafficCountBot_Data  startInternetTrafficCountBot_data;
2  
static Lock startInternetTrafficCountBot_lock = lock();
3  
4  
concept startInternetTrafficCountBot_Data {
5  
  long downloaded, uploaded;
6  
}
7  
8  
static void startInternetTrafficCountBot() {
9  
  S bot = "Internet Traffic Counter.";
10  
  if (!hasBot(bot)) {
11  
    startInternetTrafficCountBot_answer(""); // load
12  
    makeBot(bot, f startInternetTrafficCountBot_answer);
13  
  }
14  
}
15  
16  
static S startInternetTrafficCountBot_answer(S s) {
17  
  lock startInternetTrafficCountBot_lock;
18  
  if (startInternetTrafficCountBot_data == null)
19  
    startInternetTrafficCountBot_data = uniq(new Concepts(#1009802).persist(), startInternetTrafficCountBot_Data);
20  
  startInternetTrafficCountBot_Data data = startInternetTrafficCountBot_data;
21  
  
22  
  new Matches m;
23  
  if "register downloaded bytes *" {
24  
    data.downloaded += parseInt($1);
25  
    data.change();
26  
    ret "OK, total: " + data.downloaded + "/" + data.uploaded;
27  
  }
28  
  
29  
  if "register uploaded bytes *" {
30  
    data.uploaded += parseInt($1);
31  
    data.change();
32  
    ret "OK, total: " + data.downloaded + "/" + data.uploaded;
33  
  }
34  
  
35  
  if "get traffic stats|traffic stats"
36  
    ret "Total bytes downloaded/uploaded: " + data.downloaded + "/" + data.uploaded;
37  
    
38  
  null;
39  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1009802
Snippet name: startInternetTrafficCountBot
Eternal ID of this version: #1009802/8
Text MD5: a6e450ecd430004cc992d815566954f4
Author: stefan
Category: javax / talking robots
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-11-13 23:51:04
Source code size: 1287 bytes / 39 lines
Pitched / IR pitched: No / No
Views / Downloads: 513 / 775
Version history: 7 change(s)
Referenced in: [show references]