forked from GitHub/dbot
dont repeat items with the same title within a bound of 30
This commit is contained in:
parent
09e91bf817
commit
3a2374ad59
@ -8,6 +8,8 @@ var FeedParser = require('feedparser'),
|
||||
|
||||
var rss = function(dbot) {
|
||||
this.pollInterval = 120000;
|
||||
this.titleCache = [];
|
||||
var self = this;
|
||||
|
||||
this.internalAPI = {
|
||||
'makeRequest': function(id,feed) {
|
||||
@ -50,6 +52,8 @@ var rss = function(dbot) {
|
||||
feed.newTime = item.pubdate.getTime();
|
||||
}
|
||||
var rss = item;
|
||||
|
||||
if(!_.include(self.titleCache, rss.title)) {
|
||||
var options = {
|
||||
uri: 'https://www.googleapis.com/urlshortener/v1/url',
|
||||
method: 'POST',
|
||||
@ -66,10 +70,14 @@ var rss = function(dbot) {
|
||||
}
|
||||
rString += "- "+body.id;
|
||||
dbot.say(feed.server,feed.channel, rString);
|
||||
} else {
|
||||
dbot.say(feed.server,feed.channel,"RSS: Request to shorten URL returned: "+body.id);
|
||||
}
|
||||
});
|
||||
|
||||
if(self.titleCache.length > 30) {
|
||||
self.titleCache.splice(0, 1);
|
||||
}
|
||||
self.titleCache.push(feed.title);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user