kulmapaikka-ircbot/plugins/help.js
2019-11-20 20:28:11 +02:00

34 lines
796 B
JavaScript

var BasePlugin = require('./base.js')
const fs = require('fs')
class Help extends BasePlugin {
constructor (config) {
super(config)
this.name = 'Help'
}
test (input) {
if (input.match(/^\.apua/i)) {
return true
}
return false
}
result (input) {
return new Promise((resolve, reject) => {
let help = []
this.config.plugins.forEach((pluginName) => {
if (fs.existsSync('./plugins/' + pluginName.toLowerCase() + '.js')) {
let Plugin = require('./' + pluginName.toLowerCase() + '.js')
let plugin = new Plugin(this.config)
if (typeof plugin.help === 'function') {
help.push({message: plugin.help(), to: 'nick'})
}
}
})
resolve(help)
})
}
}
module.exports = Help