2

I'm using the net.Socket module to connect to EFNET and testing my code in order to add a reconnect event to my bot.

What are some ways I can mimic the bot disconnecting? The issue is very 2-3 weeks it disconnects - I have added event handlers in order to understand which happens when it disconnects from IRC:

irc = {
      info:{}
    , listeners : []
    , socket : new net.Socket()
}


irc.socket.on('timeout', function() {
    console.log('timeout');
}); 

irc.socket.on('error', function() {
    console.log('error');
}); 

irc.socket.on('end', function() {
    console.log('end??')
    setTimeout(function() {
        //irc.socket.connect(config.server.port, config.server.addr);
    }, 1000 );
}); 

Or if anyone has knowledge on which actual event happens usually with relating to irc bots, I'd appreciate it.

EDIT #1: Maybe I could I do something with iptables and filter the port while it's running or something along those lines?

meder omuraliev
  • 183,342
  • 71
  • 393
  • 434

1 Answers1

2

An IRC event isn't fired when the bot disconnects, it just closes the connection between the client and server.

You could setup your own IRC server and use the KLINE or GLINE command (As an IRC administrator) to ban your bot off the server which would force close the connection and mimic a disconnect.

Darren
  • 68,902
  • 24
  • 138
  • 144
  • Ah ok. Would you recommend having some sort of ping/pong connectivity test in order to see if it's still "connected", or what can I do for that? – meder omuraliev Nov 28 '14 at 22:30
  • The server should sending regular `PING` intervals to the client. Simply don't reply to them and the server should disconnect you. – Darren Nov 28 '14 at 22:34