mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 18:54: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.commands = await loadFiles(path.join(__dirname, config.commandsDir))
|
||||||
}
|
}
|
||||||
bot.command_handler.reload()
|
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()
|
bot.command_handler.reload()
|
||||||
let raw
|
let raw
|
||||||
let command
|
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!')
|
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)
|
command.discordExecute(bot, username, usernameraw, sender, prefix, args, channeldc, message, config)
|
||||||
} else {
|
} 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) {
|
} catch (e) {
|
||||||
if (prefix === config.discord.prefix) {
|
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) {
|
for (const prefix of config.prefixes) {
|
||||||
if (!message.startsWith(prefix)) continue
|
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: '' }
|
let previousMessage = { username: '', message: '' }
|
||||||
|
|
|
@ -13,6 +13,8 @@ function inject (bot, dcclient, config) {
|
||||||
index = _index
|
index = _index
|
||||||
})
|
})
|
||||||
|
|
||||||
|
bot.proxy = {}
|
||||||
|
|
||||||
const version = config.proxy.version
|
const version = config.proxy.version
|
||||||
const srv = mc.createServer({
|
const srv = mc.createServer({
|
||||||
'online-mode': false,
|
'online-mode': false,
|
||||||
|
@ -100,9 +102,15 @@ function inject (bot, dcclient, config) {
|
||||||
target.write(meta.name, data)
|
target.write(meta.name, data)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
bot.proxy[client.username] = {
|
||||||
|
target,
|
||||||
|
client
|
||||||
|
}
|
||||||
|
|
||||||
function endListener (reason) {
|
function endListener (reason) {
|
||||||
bot.off('end', endListener)
|
delete bot.proxy[client.username]
|
||||||
client.end(`Bot disconnected with reason: ${util.inspect(reason)}`)
|
client.end(`Bot disconnected with reason: ${util.inspect(reason)}`)
|
||||||
|
bot.off('end', endListener)
|
||||||
}
|
}
|
||||||
bot.on('end', endListener)
|
bot.on('end', endListener)
|
||||||
})
|
})
|
||||||
|
|
|
@ -15,7 +15,8 @@ function inject (bot, client, target, config, clientPacketBlacklist) {
|
||||||
null,
|
null,
|
||||||
'h', // real hash hardcode
|
'h', // real hash hardcode
|
||||||
'o',
|
'o',
|
||||||
client.username
|
client.username,
|
||||||
|
true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue