Fix feed-predef not functioning

This commit is contained in:
hgw 2023-10-02 02:11:27 +00:00
parent 3e238b7983
commit d44b956aff
2 changed files with 7 additions and 6 deletions

2
bot.js
View File

@ -127,7 +127,7 @@ async function feed(chan, nick, provfeed, n) {
} else if (predefinedFeeds.includes(predefString[0])) { //Predefined Feed lookup } else if (predefinedFeeds.includes(predefString[0])) { //Predefined Feed lookup
consoleLog('[bot.feed] Detected predefined feed: '+predefString[0]) consoleLog('[bot.feed] Detected predefined feed: '+predefString[0])
openPostWorker(chan, "feed-predef", provfeed, n) openPostWorker(chan, "feed-predef", provfeed, n, nick)
} else if (provfeed === nick) { //User Feed Lookup } else if (provfeed === nick) { //User Feed Lookup
consoleLog('[bot.feed] User feed requested') consoleLog('[bot.feed] User feed requested')

View File

@ -1,9 +1,10 @@
const config = require('../config/default.json') const config = require('../config/default.json')
const uconfig = require('../config/usersettings.json') const uconfig = require('../config/usersettings.json')
const { parentPort, workerData } = require('worker_threads'); const { parentPort, workerData } = require('worker_threads');
const { d1, d2 } = workerData; const { d1, d2, d3 } = workerData;
var provfeed = d1; var provfeed = d1;
var n = d2 var n = d2
var nick = d3
let Parser = require('rss-parser'); let Parser = require('rss-parser');
let parser = new Parser({ let parser = new Parser({
headers: {'User-Agent': config.feed.useragent}, headers: {'User-Agent': config.feed.useragent},
@ -48,7 +49,7 @@ function errorMessage(error, code, extra) {
process.exit() process.exit()
} }
async function twitter(feedURL, n) { async function twitter(feedURL, n, nick) {
var content = []; var content = [];
consoleLog('[feed-predef.twitter] fetching @'+feedURL) consoleLog('[feed-predef.twitter] fetching @'+feedURL)
@ -120,7 +121,7 @@ async function twitter(feedURL, n) {
sendUpstream(content); sendUpstream(content);
} }
async function github(user, repo, type, n) { async function github(user, repo, type, n, nick) {
var content = []; var content = [];
var validTypes = ['commits', 'releases'] var validTypes = ['commits', 'releases']
if ( validTypes.includes(type) == false ) { if ( validTypes.includes(type) == false ) {
@ -193,7 +194,7 @@ async function github(user, repo, type, n) {
var provfeed = provfeed.toLowerCase().split("/") var provfeed = provfeed.toLowerCase().split("/")
if (provfeed[0] == "twitter") { if (provfeed[0] == "twitter") {
consoleLog("[feed-predef] Running twitter function") consoleLog("[feed-predef] Running twitter function")
twitter(provfeed[1], n); twitter(provfeed[1], n, nick);
} else if (provfeed[0] == "github") { } else if (provfeed[0] == "github") {
if (provfeed[3] == undefined) { if (provfeed[3] == undefined) {
consoleLog("[feed-predef] No GitHub feed type provided, defaulting to commits") consoleLog("[feed-predef] No GitHub feed type provided, defaulting to commits")
@ -202,7 +203,7 @@ if (provfeed[0] == "twitter") {
var type = provfeed[3] var type = provfeed[3]
} }
consoleLog("[feed-predef] Running GitHub function") consoleLog("[feed-predef] Running GitHub function")
github(provfeed[1], provfeed[2], type, n) github(provfeed[1], provfeed[2], type, n, nick)
} }