Working RSS Feed Manager

- Auto updates feeds
- Sends updates to specified channels
- Needs threading
This commit is contained in:
Logan Cusano
2023-02-25 20:56:01 -05:00
parent d33f1ceccc
commit 3266a1550e
4 changed files with 44 additions and 15 deletions

View File

@@ -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) => {