diff --git a/bot.js b/bot.js index a738fe2..8bef112 100644 --- a/bot.js +++ b/bot.js @@ -43,7 +43,7 @@ async function feed(chan, provfeed, n) { return; } if (n === undefined) { - var n = 5; + var n = config.feed.default_amount; } const worker = new Worker('./commands/feed.js', { workerData: { @@ -63,7 +63,7 @@ async function twitter(chan, provfeed, n) { return; } if (n === undefined) { - var n = 5; + var n = config.twitter.default_amount; } const worker = new Worker('./commands/twitter.js', { workerData: { diff --git a/commands/feed.js b/commands/feed.js index 0c634f1..59921af 100644 --- a/commands/feed.js +++ b/commands/feed.js @@ -50,8 +50,8 @@ async function fetchFeed(feedURL, n) { var n = newFeed.items.length; content.push(warningMsg+" Your requested post amount exceeded the total available. Reverting to " + newFeed.items.length); } else if (n < 1) { - var n = 5 - content.push(warningMsg+" You requested a number less than 1. Reverting to 5"); + var n = config.feed.default_amount + content.push(warningMsg+" You requested a number less than 1. Reverting to default ("+config.feed.default_amount+")"); } //for (let i = 0; i < newFeed.items.length; i++) { for (let i = 0; i < n; i++) { diff --git a/commands/twitter.js b/commands/twitter.js index 0eac9c4..21511dd 100644 --- a/commands/twitter.js +++ b/commands/twitter.js @@ -57,8 +57,8 @@ async function fetchFeed(feedURL, n) { var n = newFeed.items.length; content.push(warningMsg+" Your requested post amount exceeded the total available. Reverting to " + newFeed.items.length); } else if (n < 1) { - var n = 5 - content.push(warningMsg+" You requested a number less than 1. Reverting to 5"); + var n = config.twitter.default_amount + content.push(warningMsg+" You requested a number less than 1. Reverting to default ("+config.twitter.default_amount+")"); } for (let i = 0; i < n; i++) { diff --git a/config/example.default.json b/config/example.default.json index 16ad265..f2f1259 100644 --- a/config/example.default.json +++ b/config/example.default.json @@ -27,13 +27,15 @@ "useragent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 13.4; rv:109.0) Gecko/20100101 Firefox/114.0", "body_max_chars": "200", "time_format": "DD MMM YYYY HH:mm:ss ZZ", - "timezone": "Pacific/Auckland" + "timezone": "Pacific/Auckland", + "default_amount": "5" }, "twitter": { "nitter_instances": [ "nitter.1d4.us", "nitter.it", "nitter.pufe.org" - ] + ], + "default_amount": "5" } } \ No newline at end of file