Baphomet is the dedicated bot for nulloctet matrix
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

50 lines
1.4 KiB

/**
* Help module
*/
let { AbstractModule } = require('./abstract');
let { logger } = require('../logging');
class HelpModule extends AbstractModule {
constructor(commandMap) {
super(
"Help",
"Provide helpful information about other modules.",
"help"
);
this._commandMap = commandMap;
this._commandList = Array.from(commandMap.keys()).sort();
this.defaultCommand = 'help';
}
_default_help_message() {
let help = `!help <command>`;
for (let command of this._commandList) {
help += "\n!help " + command + " : " + this._commandMap.get(command).description;
}
return help;
}
cmd_help(...args) {
logger.debug("%o", args)
if (args.length < 1) {
return this._default_help_message();
} else {
let command = args[0];
logger.debug("Looking up help for %s from %o", command, this._commandMap);
if (this._commandList.includes(command)) {
return this._commandMap.get(command).cmd_help();
} else {
let help = command + " is an unrecognized module\n";
help += this._default_help_message();
return help;
}
}
}
}
function create(commandMap) {
return new HelpModule(commandMap);
}
exports.create = create;