Autojs OGX 控制台版本

 

var url = rawInput("地址", "https://eos.greymass.com")+"/v1/chain/get_table_rows";
var cs = {};
cs.timestamp = 0;
cs.eos = {
    "name": "EOS",
    "divide": 100,
    "rate": 0,
    "rice": 0
};
cs.eth = {
    "name": "ETH",
    "divide": 10000,
    "rate": 0,
    "rice": 0
};
cs.btc = {
    "name": "BTC",
    "divide": 10000,
    "rate": 0,
    "rice": 0
};
cs.dot = {
    "name": "DOT",
    "divide": 10000,
    "rate": 0,
    "rice": 0
};
var PrintMsg,PKmsg;
var getCnt = 0;

function excHandler(one, data) {
    var msg;
    if (one.rate == data.rate) {
        msg = "| ";
    }else if (one.rate > data.rate) {
        msg = "↓ ";
    }else if (one.rate < data.rate) {
        msg = "↑ ";
    }
    PrintMsg = PrintMsg + " " +one.name + " " + Math.round( data.rate / (one.divide*100));
    PKmsg=PKmsg+ " " +one.name + " "+ msg + Math.round(Math.abs(one.rate - data.rate) / (one.divide*10));
    one.rate = data.rate;
}

function loopmore() {
    console.show();
    while (true) {
        try {
            var res = http.postJson(url, {
                "json": true,
                "code": "core.ogx",
                "scope": "core.ogx",
                "table": "currrundrate",
                "table_key": "",
                "lower_bound": "",
                "upper_bound": "",
                "index_position": 1,
                "key_type": "",
                "limit": 100,
                "reverse": false,
                "show_payer": false
            });
            getCnt++;
            if (res.statusCode == 200) {
                getCnt++;
                toast("请求成功" + getCnt);
                var OgxRst = res.body.json();
                if (cs.timestamp == OgxRst.rows[0].timestamp) {
                    sleep(10000);
                    continue;
                }
                PrintMsg ="";
                PKmsg="";
                cs.timestamp = OgxRst.rows[0].timestamp;
                excHandler(cs.eos, OgxRst.rows[7]);
                excHandler(cs.eth, OgxRst.rows[5]);
                excHandler(cs.btc, OgxRst.rows[2]);
//excHandler(cs.dot, OgxRst.rows[3]);
                log(PrintMsg);
                log(OgxRst.rows[0].round+" "+PKmsg );
                files.append("/sdcard/OGX请求.txt", ""+OgxRst.rows[0].round+" "+ PrintMsg
                    +" "+PKmsg+ "\n");
                if(getCnt==1)
                    sleep(15000);
                else
                    sleep(80000);
            }else {
                toast("请求失败:" + res.statusMessage);
            }
        }catch (e) {
            sleep(15000);
        }finally {

        }
    }
}
loopmore();

 

posted @ 2019-04-15 12:31  海蓝7  阅读(91)  评论(0)    收藏  举报