1st commit Discord Bot
This commit is contained in:
48
libFlayer.js
Normal file
48
libFlayer.js
Normal file
@@ -0,0 +1,48 @@
|
||||
let Parser = require('rss-parser');
|
||||
let parser = new Parser();
|
||||
let feeds = require('./feeds.json');
|
||||
|
||||
|
||||
let linkFlayerMap = [];
|
||||
|
||||
exports.addSource = function(source){
|
||||
var linkData = {
|
||||
title: `${source}`,
|
||||
link: `${source}`
|
||||
}
|
||||
feeds.push(linkData);
|
||||
}
|
||||
|
||||
exports.loadFeeds = function() {
|
||||
linkFlayerMap = [];
|
||||
feeds.forEach(feedBlock => {
|
||||
(async () => {
|
||||
const feed = parser.parseURL(feedBlock.link, function(err, feed) {
|
||||
if (err) throw err;
|
||||
console.log(feed.title);
|
||||
feed.items.forEach(item => {
|
||||
|
||||
var linkData = {
|
||||
title: `${unescape(item.title)}`,
|
||||
link: `${unescape(item.link)}`
|
||||
}
|
||||
linkFlayerMap.push(linkData);
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
|
||||
})().then();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
exports.getFeeds = function () {
|
||||
return linkFlayerMap;
|
||||
|
||||
}
|
||||
|
||||
exports.getSources = function () {
|
||||
return feeds;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user