fix alias case-sensitivity + fix endless options workers

This commit is contained in:
hgw 2023-10-02 02:11:26 +00:00
parent 0403585736
commit d573bec6ad
2 changed files with 9 additions and 6 deletions

2
bot.js
View File

@ -90,7 +90,7 @@ async function feed(chan, nick, provfeed, n) {
}
} else if (uconfig[nick].alias !== undefined ) { //Alias Lookup
consoleLog('[bot.feed] Alias requested')
var provfeed = uconfig[nick].alias[provfeed]
var provfeed = uconfig[nick].alias[provfeed.toUpperCase()]
openPostWorker(chan, "feed-preset", provfeed, n);
} else {
consoleLog('[bot.feed] No valid feed entered')

View File

@ -27,8 +27,8 @@ function consoleLog(log) {
}
async function sendUpstream(content) {
parentPort.postMessage(content);
consoleLog('[options] All done.')
parentPort.postMessage(content);
process.exit()
}
@ -97,19 +97,20 @@ async function feed(nick, setting, value) {
async function alias(setting, value, url, nick) {
if (setting === 'add') {
var value = value.toUpperCase()
consoleLog('[options.alias] Adding/editing an alias for'+nick+': '+value+' ==> '+url)
await testFeed(url);
var file = editJsonFile('/home/node/app/config/usersettings.json');
file.set(nick+'.alias.'+value, url);
file.set(nick+'.alias.'+value.toUpperCase(), url);
file.save();
sendUpstream('Alias added ('+value+' ==> '+url+')')
sendUpstream('Alias added ('+value.toUpperCase()+' ==> '+url+')')
}
if (setting === 'del') {
consoleLog('[options.alias] Removing an alias for '+nick+': '+value+' ==> \"\"')
var file = editJsonFile('/home/node/app/config/usersettings.json');
file.set(nick+'.alias.'+value, "");
file.set(nick+'.alias.'+value.toUpperCase(), "");
file.save();
sendUpstream('Alias removed ('+value+' ==> BTFO\'d)')
sendUpstream('Alias removed ('+value.toUpperCase()+' ==> BTFO\'d)')
}
if (setting === 'list') {
content = [];
@ -141,4 +142,6 @@ if (setting === 'feed') {
get(setting2);
} else if(setting === 'alias') {
alias(setting2, value, value2, user)
} else {
sendUpstream(errorMsg+' '+setting+' is not a valid option')
}