mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 14:29:29 +01:00
Fixed outputting multiple posts per check
This commit is contained in:
parent
639467fe27
commit
b5a8929931
@ -39,9 +39,10 @@ var rss = function(dbot) {
|
|||||||
|
|
||||||
while (item = stream.read()) {
|
while (item = stream.read()) {
|
||||||
if(item.pubdate.getTime() - feed.lastPosted > 0) {
|
if(item.pubdate.getTime() - feed.lastPosted > 0) {
|
||||||
|
if(item.pubdate.getTime() > feed.newTime) {
|
||||||
|
feed.newTime = item.pubdate.getTime();
|
||||||
|
}
|
||||||
var rss = item;
|
var rss = item;
|
||||||
feed.lastPosted = item.pubdate.getTime();
|
|
||||||
dbot.db.feeds[fid].lastPosted = feed.lastPosted;
|
|
||||||
var options = {
|
var options = {
|
||||||
uri: 'https://www.googleapis.com/urlshortener/v1/url',
|
uri: 'https://www.googleapis.com/urlshortener/v1/url',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@ -60,6 +61,10 @@ var rss = function(dbot) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
feedparser.on('end', function() {
|
||||||
|
feed.lastPosted = feed.newTime;
|
||||||
|
dbot.db.feeds[fid] = feed;
|
||||||
|
});
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
'checkFeeds': function() {
|
'checkFeeds': function() {
|
||||||
console.log("Checking feeds...");
|
console.log("Checking feeds...");
|
||||||
@ -78,7 +83,7 @@ var rss = function(dbot) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
dbot.db.feeds.push({server:event.server, channel:event.channel.name, name:event.params[1], url:event.params[2], lastPosted: now});
|
dbot.db.feeds.push({server:event.server, channel:event.channel.name, name:event.params[1], url:event.params[2], lastPosted: now, newTime: now});
|
||||||
event.reply("Adding RSS feed named "+event.params[1]+" with URL "+event.params[2]);
|
event.reply("Adding RSS feed named "+event.params[1]+" with URL "+event.params[2]);
|
||||||
},
|
},
|
||||||
'~rsstest': function(event) {
|
'~rsstest': function(event) {
|
||||||
|
Loading…
Reference in New Issue
Block a user