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
|
#!/usr/bin/env node
var http = require("http"),
email = require('mailer');
function poll() {
http.get(
{ host: 'api.twitter.com',
path: '/1/users/lookup.json?screen_name=spline' },
function (res) {
var data = '';
res.setEncoding('utf8');
res.on('data', function (chunk) {
data = data + chunk;
});
res.on('end', function () {
data = JSON.parse(data);
if (data.errors) {
email.send(
{
host : "mail",
port : "25",
domain : "localhost",
to : "alex@animux.de",
from : "alex@spline.inf.fu-berlin.de",
subject : "spline auf Twitter ist frei",
body: "Hi,\nder spline account auf twitter wurde soeben gelöscht.\nBitte jetzt registrieren.\n\nGruß,\ntwitter-poll"
},
function(err, result){
if(err){
console.log(err);
setTimeout(poll, 5 * 60 * 1000);
}
});
}
else {
console.log(new Date().toUTCString());
setTimeout(poll, 5 * 60 * 1000);
}
});
}
);
}
if (module === require.main) {
poll();
}
|