2024-02-11 21:23:41 -05:00
|
|
|
const fs = require('fs')
|
|
|
|
const util = require('util')
|
2024-03-16 16:03:36 -04:00
|
|
|
const CommandSource = require('../util/command/command_source')
|
2024-04-04 21:44:45 -04:00
|
|
|
const Console = require('../util/console')
|
2024-02-11 21:23:41 -05:00
|
|
|
|
2024-04-04 21:44:45 -04:00
|
|
|
function inject (bot, options) {
|
|
|
|
bot.console = options.console ? options.console.fork(bot.host) : new Console({ namespace: bot.host })
|
2024-03-17 23:52:58 -04:00
|
|
|
|
2024-04-04 21:44:45 -04:00
|
|
|
bot.on('registry_loaded', () => (bot.console.language = bot.registry.language))
|
2024-02-11 21:23:41 -05:00
|
|
|
|
2024-04-04 21:44:45 -04:00
|
|
|
bot.console.on('line', handleLine)
|
2024-03-17 23:52:58 -04:00
|
|
|
|
2024-04-04 21:44:45 -04:00
|
|
|
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)
|
2024-02-11 21:23:41 -05:00
|
|
|
}
|
2024-04-04 21:44:45 -04:00
|
|
|
}
|
2024-02-13 19:37:06 -05:00
|
|
|
|
2024-04-04 21:44:45 -04:00
|
|
|
function sendFeedback (text, broadcase) {
|
|
|
|
bot.console.log(text)
|
2024-02-11 21:23:41 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-29 20:39:21 -05:00
|
|
|
module.exports = inject
|