From fc4ba61e861ac7d034e0d39ff73c7a7b67ad46f7 Mon Sep 17 00:00:00 2001 From: amki Date: Fri, 23 May 2014 23:27:57 +0000 Subject: [PATCH] Only post when there is something new, smaller fixes --- modules/rss/rss.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/modules/rss/rss.js b/modules/rss/rss.js index fc2db9f..809265b 100644 --- a/modules/rss/rss.js +++ b/modules/rss/rss.js @@ -10,26 +10,24 @@ var rss = function(dbot) { this.intervals = []; this.internalAPI = { 'makeRequest': function(server,channel,name,url) { - dbot.say(server,channel,"Starting request for "+name+" with url "+url); var req = request(url); var feedparser = new FeedParser(); req.on('error', function (error) { - dbot.say(server,channel,"Request got an error: "+error); + dbot.say(server,channel,"RSS: Request for RSS feed got an error: "+error+" Start self-destruct sequence."); }); req.on('response', function (res) { var stream = this; if (res.statusCode != 200){ - dbot.say(server,channel,"Request had status code "+res.statusCode); + dbot.say(server,channel,"RSS: RSS server returned status code "+res.statusCode+". Bastard."); return; } stream.pipe(feedparser); - dbot.say(server,channel,"Request piped to feedparser!"); }); feedparser.on('error', function(error) { - dbot.say(server,channel,"Feedparser got an error: "+error); + dbot.say(server,channel,"RSS: Feedparser encountered an error: "+error+";;; Inform administrator!"); }); feedparser.on('readable', function() { // This is where the action is! @@ -38,18 +36,17 @@ var rss = function(dbot) { , item; while (item = stream.read()) { - dbot.say(server,channel,"@ "+item.pubdate+": ["+name+"] ["+item.title+"] [Post by "+item.author+" in "+item.categories[0]+"] - "+item.link); + if(item.pubdate - self.lastPosted > 0) + dbot.say(server,channel,"["+name+"] ["+item.title+"] [Post by "+item.author+" in "+item.categories[0]+"] - "+item.link); } }); }.bind(this), 'reloadFeeds': function() { - console.log("rss: reloading feeds..."); for(var i=0;i