const fs = require('fs') const util = require('util') const CommandSource = require('../util/command/command_source') const Console = require('../util/console') function inject (bot, options) { bot.console = options.console ? options.console.fork(bot.hostPortPair) : new Console({ namespace: bot.hostPortPair }) bot.on('registry_loaded', () => (bot.console.language = bot.registry.language)) bot.console.on('line', handleLine) function handleLine (line) { // if (bot.host !== bot.console.host && bot.console.host !== 'all') return if (line.startsWith('.')) { const source = new CommandSource({ bot, permissionLevel: Infinity, sendFeedback, displayName: '_ChipMC_' }) bot.commands.execute(line.substring(1), source) } else { bot.fancyMsg('test', '_ChipMC_', line) } } function sendFeedback (text, broadcase) { bot.console.log(text) } } module.exports = inject