static startInternetTrafficCountBot_Data startInternetTrafficCountBot_data; static Lock startInternetTrafficCountBot_lock = lock(); concept startInternetTrafficCountBot_Data { long downloaded, uploaded; } static void startInternetTrafficCountBot() { S bot = "Internet Traffic Counter."; if (!hasBot(bot)) { startInternetTrafficCountBot_answer(""); // load makeBot(bot, f startInternetTrafficCountBot_answer); } } static S startInternetTrafficCountBot_answer(S s) { lock startInternetTrafficCountBot_lock; if (startInternetTrafficCountBot_data == null) startInternetTrafficCountBot_data = uniq(new Concepts(#1009802).persist(), startInternetTrafficCountBot_Data); startInternetTrafficCountBot_Data data = startInternetTrafficCountBot_data; new Matches m; if "register downloaded bytes *" { data.downloaded += parseInt($1); data.change(); ret "OK, total: " + data.downloaded + "/" + data.uploaded; } if "register uploaded bytes *" { data.uploaded += parseInt($1); data.change(); ret "OK, total: " + data.downloaded + "/" + data.uploaded; } if "get traffic stats|traffic stats" ret "Total bytes downloaded/uploaded: " + data.downloaded + "/" + data.uploaded; null; }