mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
expose proxy to bot + unused proxy which will be used later..
This commit is contained in:
parent
fb39b6586c
commit
4f5db7a740
3 changed files with 15 additions and 6 deletions
|
@ -10,7 +10,7 @@ function inject (bot, dcclient, config) {
|
|||
bot.command_handler.commands = await loadFiles(path.join(__dirname, config.commandsDir))
|
||||
}
|
||||
bot.command_handler.reload()
|
||||
bot.command_handler.main = function (prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector) {
|
||||
bot.command_handler.main = function (prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector, proxy) {
|
||||
bot.command_handler.reload()
|
||||
let raw
|
||||
let command
|
||||
|
@ -41,7 +41,7 @@ function inject (bot, dcclient, config) {
|
|||
if (!command.discordExecute) throw new Error('This command is not yet supported on discord!')
|
||||
command.discordExecute(bot, username, usernameraw, sender, prefix, args, channeldc, message, config)
|
||||
} else {
|
||||
command.execute(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector)
|
||||
command.execute(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector, proxy)
|
||||
}
|
||||
} catch (e) {
|
||||
if (prefix === config.discord.prefix) {
|
||||
|
@ -55,10 +55,10 @@ function inject (bot, dcclient, config) {
|
|||
}
|
||||
}
|
||||
}
|
||||
bot.command_handler.run = function (username, usernameraw, message, sender, channeldc, hash, ownerhash, selector = '@a') {
|
||||
bot.command_handler.run = function (username, usernameraw, message, sender, channeldc, hash, ownerhash, selector = '@a', proxy) {
|
||||
for (const prefix of config.prefixes) {
|
||||
if (!message.startsWith(prefix)) continue
|
||||
bot.command_handler.main(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector)
|
||||
bot.command_handler.main(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector, proxy)
|
||||
}
|
||||
}
|
||||
let previousMessage = { username: '', message: '' }
|
||||
|
|
|
@ -13,6 +13,8 @@ function inject (bot, dcclient, config) {
|
|||
index = _index
|
||||
})
|
||||
|
||||
bot.proxy = {}
|
||||
|
||||
const version = config.proxy.version
|
||||
const srv = mc.createServer({
|
||||
'online-mode': false,
|
||||
|
@ -100,9 +102,15 @@ function inject (bot, dcclient, config) {
|
|||
target.write(meta.name, data)
|
||||
})
|
||||
|
||||
bot.proxy[client.username] = {
|
||||
target,
|
||||
client
|
||||
}
|
||||
|
||||
function endListener (reason) {
|
||||
bot.off('end', endListener)
|
||||
delete bot.proxy[client.username]
|
||||
client.end(`Bot disconnected with reason: ${util.inspect(reason)}`)
|
||||
bot.off('end', endListener)
|
||||
}
|
||||
bot.on('end', endListener)
|
||||
})
|
||||
|
|
|
@ -15,7 +15,8 @@ function inject (bot, client, target, config, clientPacketBlacklist) {
|
|||
null,
|
||||
'h', // real hash hardcode
|
||||
'o',
|
||||
client.username
|
||||
client.username,
|
||||
true
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue