3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-03 17:39:28 +01:00

Roi requested the RSS module use goo.gl shortened links

This commit is contained in:
amki 2014-05-24 17:13:40 +00:00
parent 64f5f61a0a
commit bc00fabb81

View File

@ -39,12 +39,27 @@ var rss = function(dbot) {
while (item = stream.read()) {
if(item.pubdate.getTime() - feed.lastPosted > 0) {
var rss = item;
feed.lastPosted = item.pubdate.getTime();
// FIXME: This doesn't work AT ALL
dbot.db.feeds.splice(fid,1);
dbot.db.feeds.push(feed);
//
dbot.say(feed.server,feed.channel,"["+feed.name+"] ["+item.title+"] [Post by "+item.author+" in "+item.categories[0]+"] - "+item.link);
var options = {
uri: 'https://www.googleapis.com/urlshortener/v1/url',
method: 'POST',
json: {
"longUrl": rss.link
}
};
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
dbot.say(feed.server,feed.channel,"["+feed.name+"] ["+rss.title+"] [Post by "+rss.author+" in "+rss.categories[0]+"] - "+body.id);
} else {
dbot.say(feed.server,feed.channel,"RSS: Request to shorten URL returned: "+body.id);
}
});
}
}
});