Initial Emmelia merge

This commit is contained in:
Logan Cusano
2023-05-06 14:56:51 -04:00
parent 6e8af5dbcc
commit f3a4f25f85
44 changed files with 5530 additions and 1115 deletions

View File

@@ -0,0 +1,38 @@
//Will handle updating feeds in all channels
const { DebugBuilder } = require("../utilities/debugBuilder");
const log = new DebugBuilder("server", "rssController");
const libCore = require("../libCore");
const libUtils = require("../libUtils");
const refreshInterval = process.env.RSS_REFRESH_INTERVAL ?? 300000;
exports.RSSController = class RSSController {
constructor(_client) {
this.client = _client;
}
async start(){
// Wait for the refresh period before starting rss feeds, so the rest of the bot can start
await new Promise(resolve => setTimeout(resolve, refreshInterval));
log.INFO("Starting RSS Controller");
// Get initial feeds before the starting the infinite loop
await libCore.updateFeeds(this.client);
while(true){
// Wait for the refresh interval, then wait for the posts to return, then wait a quarter of the refresh interval to make sure everything is cleared up
await new Promise(resolve => setTimeout(resolve, refreshInterval));
await this.collectLatestPosts();
await new Promise(resolve => setTimeout(resolve, refreshInterval / 4));
continue;
}
}
async collectLatestPosts(){
log.INFO("Updating sources");
await libCore.updateFeeds(this.client)
return;
}
}