forked from xieisabug/botvs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BTC-LTC 地址监视, 短信通知.js
73 lines (68 loc) · 2.38 KB
/
BTC-LTC 地址监视, 短信通知.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
策略出处: https://www.botvs.com/strategy/1295
策略名称: BTC-LTC 地址监视, 短信通知
策略作者: Zero
策略描述:
有新的交易, 立即提醒
参数 默认值 描述
--------- ---------------------------------- -----------
Type 0 类型: BTC|LTC
Addr 1LuckyY9fRzcJre7aou7ZhWVXktxjjBb9S 地址
Interval 3 轮询间隔
EnableSMS false 启动短信通知
SMSUser *** 短信宝用户名
SMSPass *** 短信宝MD5密码
PhoneNum 1111 接收短信手机号
*/
var LastMsg = "";
function SMSSend(msg) {
if (msg == LastMsg) {
return true;
}
Log('SMS:', msg);
LastMsg = msg;
var ret = false;
var phones = PhoneNum.split(',');
for (var i = 0; i < phones.length; i++) {
ret = HttpQuery("http://www.smsbao.com/sms?u=" + encodeURIComponent(SMSUser) + "&p=" + SMSPass.toUpperCase() + "&m=" + phones[i] + "&c=" + encodeURIComponent(msg)) == "0";
if (ret) {
Log("短信通知", phones[i], "成功");
} else {
Log("短信通知", phones[i], "失败");
}
}
return ret;
}
function main() {
var url = "http://open.qukuai.com/address/" + Addr + "?key=2ejf4jgfNoya8Y3GnQf68e4J23HherpUh1&limit=1";
if (Type == 1) {
url += "<c=true";
}
var lt = "";
Log("监视: ", Addr, Type == 0 ? 'BTC' : 'LTC');
if (EnableSMS) {
if (!SMSSend("策略启动成功")) {
return false;
}
}
while (true) {
try {
var res = HttpQuery(url);
if (res) {
var obj = JSON.parse(res);
if (typeof(obj.t0) !='undefined' && obj.t0.length > 0) {
if (obj.t0.toString() != lt) {
if (lt != "") {
LogProfit(obj.balance, obj.received);
if (EnableSMS) SMSSend('有新交易, 当前余额: ' + obj.balance/100000000 + '接收总数: ' + obj.received/100000000);
}
lt = obj.t0.toString();
}
}
}
} catch(e) {
Log(e);
}
Sleep(Interval*1000);
}
}