From f5217bbdabe39ee11324229dacc63a0a82cdef42 Mon Sep 17 00:00:00 2001 From: hgw Date: Mon, 2 Oct 2023 02:11:24 +0000 Subject: [PATCH] maximum entry error handling --- commands/feed.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/commands/feed.js b/commands/feed.js index 769e602..c09ea45 100644 --- a/commands/feed.js +++ b/commands/feed.js @@ -1,3 +1,4 @@ +const config = require('../config/default.json') const { parentPort, workerData } = require('worker_threads'); const { provfeed, n } = workerData; let Parser = require('rss-parser'); @@ -5,7 +6,6 @@ let parser = new Parser({ headers: {'User-Agent': config.feed.useragent}, }); const striptags = require("striptags"); -const config = require('../config/default.json') async function sendUpstream(content) { var output = content.join("\n") @@ -16,6 +16,10 @@ async function sendUpstream(content) { async function fetchFeed(feedURL, n) { var content = []; let newFeed = await parser.parseURL(feedURL); + if (n > newFeed.items.length) { + var n = newFeed.items.length; + content.push("[08WARNING] Your requested post amount exceeded the total available. Reverting to " + newFeed.items.length); + } //for (let i = 0; i < newFeed.items.length; i++) { for (let i = 0; i < n; i++) { var data = newFeed.items[i]