move help command to own file, make help logo togglable

This commit is contained in:
hgw 2023-10-02 02:11:26 +00:00
parent 726d30f38c
commit 2fc39ca86f
3 changed files with 61 additions and 16 deletions

17
bot.js
View File

@ -46,22 +46,7 @@ function openPostWorker(chan, command, d1, d2, d3, d4, d5) {
}
async function help(chan, sub) {
if (sub === undefined) {
var sub = "default"
}
if (sub === "default") {
if (config.misc.display_help_logo === true ){
bot.say(chan, ' ____ ___ ___ ____________ _________ __')
bot.say(chan, ' / __ `__ \\/ _ \\/ ___/ ___/ / / / ___/ / / /')
bot.say(chan, ' / / / / / / __/ / / /__/ /_/ / / / /_/ / ')
bot.say(chan, '/_/ /_/ /_/\\___/_/ \\___/\\__,_/_/ \\__, / ')
bot.say(chan, ' /____/ ')
}
bot.say(chan, 'Mercury RSS Client - https://git.supernets.org/hogwart7/mercury')
bot.say(chan, 'm!feed [USER/FEED/ALIAS] [ENTRIES] - Return the last x amount of entries from any RSS feed or your own saved feeds (if you have saved feeds)')
bot.say(chan, "m!twitter [USER] [ENTRIES] - Return the last x amount of tweets from a particular user")
bot.say(chan, "m!opt [CATEGORY] [OPTION] [VALUE] - Control bot options, see wiki for info on usage.")
}
openPostWorker(chan, 'help', sub)
}
async function opt(chan, user, setting, setting2, value, value2) {

56
commands/help.js Normal file
View File

@ -0,0 +1,56 @@
const config = require('../config/default.json')
const { parentPort, workerData } = require('worker_threads');
const { d1 } = workerData;
var sub = d1;
const timer = ms => new Promise(res => setTimeout(res, ms))
warningMsg = ''+config.colours.brackets+'['+config.colours.warning+'WARNING'+config.colours.brackets+']'
errorMsg = ''+config.colours.brackets+'['+config.colours.error+'ERROR'+config.colours.brackets+']'
async function sendUpstream(content) {
var output = content.join("\n")
parentPort.postMessage(output);
process.exit()
}
function errorMessage(error, code, extra) {
console.log(error.code)
if (code == "404") {
var error = errorMsg+" 404: " + extra + " not found"
} else if (error.code == "ECONNREFUSED") {
var error = errorMsg+" Connection Refused"
} else if (error.code == "ERR_UNESCAPED_CHARACTERS"){
var error = errorMsg+" Unescaped Characters"
} else {
var error = errorMsg+" Unknown error"
}
parentPort.postMessage(error);
process.exit()
}
async function help(sub) {
content = [];
if (sub === undefined) {
var sub = "default"
}
if (sub === "default") {
console.log(config.misc.display_help_logo)
if (config.misc.display_help_logo === 'true' ) {
content.push(''+config.colours.help_logo+' ____ ___ ___ ____________ _________ __')
content.push(''+config.colours.help_logo+' / __ `__ \\/ _ \\/ ___/ ___/ / / / ___/ / / /')
content.push(''+config.colours.help_logo+' / / / / / / __/ / / /__/ /_/ / / / /_/ / ')
content.push(''+config.colours.help_logo+'/_/ /_/ /_/\\___/_/ \\___/\\__,_/_/ \\__, / ')
content.push(''+config.colours.help_logo+' /____/ ')
}
content.push('Mercury RSS Client - https://git.supernets.org/hogwart7/mercury')
content.push('m!feed [USER/FEED/ALIAS] [ENTRIES] - Return the last x amount of entries from any RSS feed or your own saved feeds (if you have saved feeds)')
content.push("m!twitter [USER] [ENTRIES] - Return the last x amount of tweets from a particular user")
content.push("m!opt [CATEGORY] [OPTION] [VALUE] - Control bot options, see wiki for info on usage.")
sendUpstream(content)
}
}
help(sub);

View File

@ -21,6 +21,7 @@
"author": "08",
"body": "00",
"link": "02",
"help_logo": "07",
"warning": "08",
"error": "05"
},
@ -38,5 +39,8 @@
"nitter.pufe.org"
],
"default_amount": "5"
},
"misc": {
"display_help_logo": "true"
}
}