mtfosbot/index.js
2018-09-20 22:08:42 +08:00

22 lines
567 B
JavaScript

require('module-alias/register')
const fs = require('fs')
const fork = require('child_process').fork
const path = require('path')
try {
fs.accessSync(path.resolve(__dirname, '.env'))
require('dotenv').config()
} catch (err) {}
require('./app')
const event = require('./event')
let bgProc = fork('./background.js')
bgProc.on('message', data => {
if ('type' in data && 'data' in data) {
event.emit(data.type, data.data)
}
})
bgProc.on('close', () => {
console.log(`background close`)
})
const twitchChat = require('./libs/twitch-bot')
twitchChat.runBot()