My code if it doesn’t get a PING/other message in a timely it’ll send it’s own PING and if no PONG do the restart loop.
Either way, it’s possible for a bot to miss a server ping, which is why if you don’t have a sever ping in a timely fashion you send your own to test if it was a missed ping, or you connection dropped/terminated/whatever.
Twitch docs states:
About once every five minutes, you will receive a PING :tmi.twitch.tv from the server, in order to ensure that your connection to the server is not prematurely terminated, you should reply with PONG :tmi.twitch.tv.
Source: Chat & Chatbots | Twitch Developers
Interestingly RFC 1459 says that servers don’t have to respond to client initiated PING’s but I’m sure they all do:
Any client which receives a PING message must respond to
(server which sent the PING message out) as quickly as possible with
an appropriate PONG message to indicate it is still there and alive.
Servers should not respond to PING commands but rely on PINGs from
the other end of the connection to indicate the connection is alive.
If the parameter is specified, the PING message gets
forwarded there.
NodeIRC itself uses a cycling ping timer and sends a PING to the Server if it’s not had one for a while. Which is the logical thing to do.
That said, if a bot hasn’t had a server initiated ping, or ANY packer of data, then yeah it’s supposed to reconnect/deal with it how ever it wants.
So to take this topic back on track. It’s a problem with the bot not realising it may have disconnected from Twitch chat, and dealing with that accordingly