#!/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(); }