// Will handle updating feeds in all channels import { DebugBuilder } from "../modules/debugger.mjs"; import { updateFeeds } from "./feedHandler.mjs"; import dotenv from 'dotenv'; dotenv.config(); const log = new DebugBuilder("server", "rssController"); const refreshInterval = parseInt(process.env.RSS_REFRESH_INTERVAL) || 300000; export class RSSController { constructor(client) { this.client = client; this.intervalId = null; } async start() { try { log.INFO("Starting RSS Controller"); // Get initial feeds before starting the interval loop await this.collectLatestPosts(); // Start the interval loop for updating feeds this.intervalId = setInterval(async () => { await this.collectLatestPosts(); }, refreshInterval); } catch (error) { log.ERROR(`Failed to start RSS Controller: ${error.message}`); } } async stop() { if (this.intervalId) { clearInterval(this.intervalId); log.INFO("RSS Controller stopped"); } } async collectLatestPosts() { try { log.INFO("Updating sources"); await updateFeeds(this.client); } catch (error) { log.ERROR(`Error updating feeds: ${error.message}`); } } }