add kick_disconnect and disconnect for proxy

so the reason will not always be 'socketClosed' or 'keepAliveError'
or something
This commit is contained in:
ChomeNS 2023-01-22 12:28:32 +07:00
parent 0508cf32d3
commit 76ea644bf8

View file

@ -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', () => {