-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (34 loc) · 827 Bytes
/
index.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
const say = require('say');
const request = require('request');
const interval = 60000; // 1 minute
let lastTx = "";
let firstRun = true; // laaazy
function checkTx() {
let requestOptions = {
url: 'http://omniexplorer.info/ask.aspx',
qs: {
api: 'gethistory',
address: '3MbYQMMmSkC3AgWkj9FMo5LsPTW1zBTwXL'
}
};
request(requestOptions,
(error, response, body) => {
console.log(body);
let parsedBody = JSON.parse(body);
if(parsedBody.transactions[0] !== lastTx) {
sayAlert();
lastTx = parsedBody.transactions[0];
}
}
);
}
function sayAlert() {
if(firstRun) {
say.speak("Tether alerter initialized");
firstRun = false;
} else {
say.speak("Warning! New Tethers have been created!");
}
}
checkTx();
setInterval(checkTx,interval);