Working RSS Feed Manager
- Auto updates feeds - Sends updates to specified channels - Needs threading
This commit is contained in:
23
libCore.js
23
libCore.js
@@ -2,7 +2,7 @@
|
||||
let Parser = require('rss-parser');
|
||||
const axios = require('axios');
|
||||
let parser = new Parser();
|
||||
const storageHandler = require("./libStorage");
|
||||
const { FeedStorage, PostStorage } = require("./libStorage");
|
||||
const libUtils = require("./libUtils");
|
||||
const { createHash } = require("crypto");
|
||||
|
||||
@@ -19,15 +19,9 @@ const configuration = new Configuration({
|
||||
|
||||
const openai = new OpenAIApi(configuration);
|
||||
*/
|
||||
|
||||
// Data Structures
|
||||
var feeds = {};
|
||||
var rssFeedMap = [];
|
||||
var rssFeedCategories = [];
|
||||
|
||||
// Setup Storage handlers
|
||||
var feedStorage = new storageHandler.feedStorage();
|
||||
var postStorage = new storageHandler.postStorage();
|
||||
var feedStorage = new FeedStorage();
|
||||
var postStorage = new PostStorage();
|
||||
|
||||
/**
|
||||
* Adds or updates new source url to configured storage
|
||||
@@ -291,7 +285,10 @@ exports.getChat = async function (_prompt, { _model = "text-davinci-003", _tempe
|
||||
* @constructor
|
||||
*/
|
||||
exports.getSources = function () {
|
||||
return feeds;
|
||||
feedStorage.getAllRecords((err, records) => {
|
||||
if (err) throw err;
|
||||
return records;
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,7 +317,11 @@ exports.getQuotes = async function (quote_url) {
|
||||
* @constructor
|
||||
*/
|
||||
exports.getCategories = function () {
|
||||
return rssFeedCategories;
|
||||
feedStorage.getUniqueByKey("category", (err, results) => {
|
||||
if (err) throw err;
|
||||
|
||||
return results
|
||||
});
|
||||
}
|
||||
|
||||
exports.addPost = (postObject, callback) => {
|
||||
|
||||
Reference in New Issue
Block a user