chipmunkbot3/plugins/!console.js

29 lines
901 B
JavaScript
Raw Normal View History

2024-02-11 21:23:41 -05:00
const fs = require('fs')
const util = require('util')
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-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-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-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