You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
974 B

// import * as SphinxBot from '../../../sphinx-bot'
import * as SphinxBot from 'sphinx-bot'
import * as MotherBot from './mother'
5 years ago
import * as WelcomeBot from './welcome'
import * as LoopBot from './loop'
import {Msg} from '../network/interfaces'
5 years ago
import * as path from 'path'
import { models } from '../models'
4 years ago
import {buildBotPayload} from '../controllers/bots'
5 years ago
const constants = require(path.join(__dirname, '../../config/constants.json'))
async function init(){
MotherBot.init()
5 years ago
const builtInBots = await models.ChatBot.findAll({where:{
botType: constants.bot_types.builtin
}})
if(!(builtInBots && builtInBots.length)) return
builtInBots.forEach(b=>{
if(b.botPrefix==='/welcome') WelcomeBot.init()
if(b.botPrefix==='/loopout') LoopBot.init()
5 years ago
})
}
4 years ago
function builtinBotEmit(msg:Msg){
setTimeout(()=>{
SphinxBot._emit('message', buildBotPayload(msg))
},1200)
}
4 years ago
export {init,builtinBotEmit,buildBotPayload}