Fixed pluginmanager
This commit is contained in:
parent
d386c9d242
commit
ed800dbd81
|
@ -42,15 +42,14 @@ class PluginManager {
|
|||
})
|
||||
}
|
||||
|
||||
validateResult (resultPromise) {
|
||||
return new Promise((resolve) => {
|
||||
let wrapperPromise = new Promise((resolve) => resolve(resultPromise))
|
||||
wrapperPromise.then((results) => {
|
||||
async validateResult (resultPromise) {
|
||||
let results = await resultPromise
|
||||
|
||||
let promises = []
|
||||
if (!Array.isArray(results)) {
|
||||
results = [results]
|
||||
}
|
||||
|
||||
let promises = []
|
||||
results.forEach((result) => {
|
||||
let to = 'channel'
|
||||
let message = result
|
||||
|
@ -59,15 +58,12 @@ class PluginManager {
|
|||
message = result.message
|
||||
}
|
||||
|
||||
promises.push(new Promise({ to, message }))
|
||||
})
|
||||
|
||||
resolve(promises)
|
||||
})
|
||||
promises.push(new Promise((resolve) => resolve({ to, message })))
|
||||
})
|
||||
return promises
|
||||
}
|
||||
|
||||
testPlugins (input, publicChat) {
|
||||
async testPlugins (input, publicChat) {
|
||||
if (typeof publicChat === 'undefined') {
|
||||
publicChat = true
|
||||
}
|
||||
|
@ -79,7 +75,7 @@ class PluginManager {
|
|||
let plugin = this.plugins[i]
|
||||
if (plugin.test(input)) {
|
||||
logger.info('* Plugin ' + plugin.name + ' reported hit')
|
||||
promises.push(this.validateResult(plugin.result(input)))
|
||||
promises = [...promises, ...await this.validateResult(plugin.result(input))]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -88,7 +84,7 @@ class PluginManager {
|
|||
|
||||
if (plugin.test(input)) {
|
||||
logger.info('* Plugin ' + plugin.name + ' reported hit')
|
||||
promises.push(this.validateResult(plugin.result(input)))
|
||||
promises = [...promises, ...await this.validateResult(plugin.result(input))]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user