forked from dhruhin/dogbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrss.js
More file actions
33 lines (31 loc) · 1.08 KB
/
Copy pathrss.js
File metadata and controls
33 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//Uses an RSS reader library to display a numbered list of items in the group
var feed = require('feed-read');
//Error message
var error = process.env.error;
//link: rss feed link to read throuhg
//intro: intro message before numbered list
//limit: max number of items
//func: callback function to run after message from the list has been created
function rss_feed(link, intro, limit, func){
var string = intro;
feed(link, function(err, articles) {
if (err){
//Print error message if it doesn't work as expected
string+="\n";
string+=error;
throw err;
}
if(limit>articles.length)
limit = articles.length;
for (var i = 0; i < limit; i++) {
string+="\n";
string+=(i+1)+". ";
//If GroupMe ever supports formatted messages, code for link's left in here
//string+="<a href="+articles[i].link+" >";
string+=articles[i].title;
//string+="</a>";
}
func(string);
});
}
exports.rss_feed = rss_feed;