2018-04-29 17:37:07 +03:00
|
|
|
// Start without app
|
|
|
|
|
2019-08-13 19:37:22 +03:00
|
|
|
function prompt (question, callback) {
|
|
|
|
var stdin = process.stdin
|
|
|
|
var stdout = process.stdout
|
2018-04-29 17:37:07 +03:00
|
|
|
|
2019-08-13 19:37:22 +03:00
|
|
|
stdin.resume()
|
|
|
|
stdout.write(question)
|
2018-04-29 17:37:07 +03:00
|
|
|
|
|
|
|
stdin.once('data', function (data) {
|
2019-08-13 19:37:22 +03:00
|
|
|
callback(data.toString().trim())
|
|
|
|
})
|
2018-04-29 17:37:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Load config
|
2019-08-13 19:37:22 +03:00
|
|
|
const config = require('./config')
|
2018-04-29 17:37:07 +03:00
|
|
|
|
|
|
|
// Load new plugins
|
2019-08-13 19:37:22 +03:00
|
|
|
const PluginManager = require('./plugins/pluginManager.js')
|
|
|
|
const pluginManager = new PluginManager(config)
|
|
|
|
pluginManager.loadAllPlugins()
|
2018-04-29 17:37:07 +03:00
|
|
|
|
|
|
|
// Configure logger
|
|
|
|
// create a write stream (in append mode)
|
|
|
|
// ensure log directory exists
|
2019-08-13 19:37:22 +03:00
|
|
|
const logger = require('./logger')
|
2018-04-29 17:37:07 +03:00
|
|
|
const isPm = false
|
|
|
|
|
2019-08-13 19:37:22 +03:00
|
|
|
function query () {
|
2018-04-29 17:37:07 +03:00
|
|
|
prompt('> ', function (message) {
|
2019-08-13 19:37:22 +03:00
|
|
|
if (!isPm) {
|
|
|
|
pluginManager.testPlugins(message).then(function (results) {
|
|
|
|
for (var i = 0; i < results.length; i++) {
|
2019-11-20 20:28:11 +02:00
|
|
|
let result = results[i]
|
|
|
|
|
|
|
|
console.log('[' + result.to + ']', result.message)
|
2018-04-29 17:37:07 +03:00
|
|
|
}
|
|
|
|
query()
|
2019-08-13 19:37:22 +03:00
|
|
|
}, function (error) {
|
|
|
|
logger.error('Plugin error: ', error)
|
|
|
|
query()
|
|
|
|
})
|
2018-04-29 17:37:07 +03:00
|
|
|
} else {
|
|
|
|
// PM
|
2019-08-13 19:37:22 +03:00
|
|
|
pluginManager.testPlugins(message, false).then(function (results) {
|
|
|
|
for (var i = 0; i < results.length; i++) {
|
|
|
|
console.log(results[i])
|
2018-04-29 17:37:07 +03:00
|
|
|
}
|
|
|
|
query()
|
2019-08-13 19:37:22 +03:00
|
|
|
}, function (error) {
|
|
|
|
logger.error('Plugin error: ', error)
|
|
|
|
query()
|
|
|
|
})
|
2018-04-29 17:37:07 +03:00
|
|
|
}
|
2019-08-13 19:37:22 +03:00
|
|
|
})
|
2018-04-29 17:37:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
query()
|