diff options
Diffstat (limited to 'main.js')
-rwxr-xr-x | main.js | 36 |
1 files changed, 18 insertions, 18 deletions
@@ -1,12 +1,17 @@ #!/usr/bin/env node var http = require("http"), -email = require('mailer'); +mail = require('mail').Mail({host: 'mail'}); + +var config = { + user: 'spline', + time: 5 * 60 * 1000 +}; function poll() { http.get( { host: 'api.twitter.com', - path: '/1/users/lookup.json?screen_name=spline' }, + path: '/1/users/lookup.json?screen_name=' + config.user }, function (res) { var data = ''; @@ -20,27 +25,22 @@ function poll() { 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); + mail.message({ + from: 'alex@spline.inf.fu-berlin.de', + to: ['spline@spline.inf.fu-berlin.de'], + subject: config.user + ' auf Twitter ist frei' + }) + .body('Hi,\nder ' + config.user + ' Account auf twitter wurde soeben gelöscht.\nBitte jetzt registrieren.\n\nGruß,\ntwitter-poll') + .send(function(err) { + if (err) { + setTimeout(poll, config.time); } + console.log('Sent mail!'); }); } else { console.log(new Date().toUTCString()); - setTimeout(poll, 5 * 60 * 1000); + setTimeout(poll, config.time); } }); } |