-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.js
32 lines (30 loc) · 954 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const jsonFile = require('jsonfile')
const bot = require('./libs/botcommands')
const webserver = require('./libs/webserver')
const api = require('./libs/api/api')
const db = require('./libs/db')
const configFile = 'config/config.json'
// Global DB connection
jsonFile.readFile(configFile, function (err, config) {
console.log(err)
db.connect(config, () => {
if (process.argv.length > 2) {
process.argv.forEach((val, index, array) => {
switch (val) {
case '--bot':
bot.run(config) // run bot to log chats
break
case '--webserver':
webserver.serve(config) // serve the data
api.serve(config) // provide api
break
}
})
} else {
// No specific arguments have been passed; run all scripts:
bot.run(config) // run bot to log chats
webserver.serve(config) // serve the data
api.serve() // provide api
}
})
})