From 45dae6eb0ac52a2eee2e24b0bfb553a0d7371a2e Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 17 Mar 2014 01:05:55 +0100 Subject: newsbot.js: use guid to identify articles --- news/newsbot.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'news') diff --git a/news/newsbot.js b/news/newsbot.js index 998482cd..18a7fb07 100644 --- a/news/newsbot.js +++ b/news/newsbot.js @@ -134,22 +134,22 @@ function create_feedbot (nick, uri, channels) { return a.date - b.date }) - var indexOfLastTitle = items - .map(function (x) { return x.title }) - .indexOf(client.lastTitle) + var indexOfLastGuid = items + .map(function (x) { return x.guid }) + .indexOf(client.lastGuid) var newitems = items var olditems = [] - // if items contain lastTitle, then only items after that are news - if (!!~indexOfLastTitle) { - olditems = newitems.splice(0, indexOfLastTitle + 1) + // if items contain lastGuid, then only items after that are news + if (!!~indexOfLastGuid) { + olditems = newitems.splice(0, indexOfLastGuid + 1) } if (newitems.length > 0) { // only broadcast news if we're not starting up - // (i.e. we already have a lastTitle) - if (client.lastTitle) { + // (i.e. we already have a lastGuid) + if (client.lastGuid) { newitems.forEach(function (item) { return getShortLink(item.link, function (error, shortlink) { return broadcast(item.title + ' ' + shortlink) @@ -157,7 +157,7 @@ function create_feedbot (nick, uri, channels) { }) } - client.lastTitle = newitems[newitems.length - 1].title + client.lastGuid = newitems[newitems.length - 1].guid } return setTimeout(loop_feedparser, feedbot_loop_delay) -- cgit v1.2.3