mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
add kick_disconnect and disconnect for proxy
so the reason will not always be 'socketClosed' or 'keepAliveError' or something
This commit is contained in:
parent
0508cf32d3
commit
76ea644bf8
1 changed files with 9 additions and 5 deletions
|
@ -79,11 +79,15 @@ function inject (bot, dcclient, config) {
|
|||
|
||||
target.on('error', () => {})
|
||||
|
||||
target.on('end', (reason) => {
|
||||
target.on('end', targetEndListener)
|
||||
target.on('kick_disconnect', targetEndListener)
|
||||
target.on('disconnect', targetEndListener)
|
||||
|
||||
function targetEndListener (reason) {
|
||||
target.end()
|
||||
client.end(`Target disconnected with reason: ${util.inspect(reason)}`)
|
||||
targetEnded = true
|
||||
})
|
||||
}
|
||||
|
||||
client.on('end', () => {
|
||||
clientEnded = true
|
||||
|
@ -110,12 +114,12 @@ function inject (bot, dcclient, config) {
|
|||
client
|
||||
}
|
||||
|
||||
function endListener (reason) {
|
||||
function botEndListener (reason) {
|
||||
delete bot.proxy[client.username]
|
||||
client.end(`Bot disconnected with reason: ${util.inspect(reason)}`)
|
||||
bot.off('end', endListener)
|
||||
bot.off('end', botEndListener)
|
||||
}
|
||||
bot.on('end', endListener)
|
||||
bot.on('end', botEndListener)
|
||||
})
|
||||
|
||||
bot.on('end', () => {
|
||||
|
|
Loading…
Reference in a new issue