As per the docs.
https://dev.twitch.tv/docs/irc/guide/#connecting-to-twitch-irc
About once every five minutes, the server will send you a
PING :tmi.twitch.tv
. To ensure that your connection to the server is not prematurely terminated, reply withPONG :tmi.twitch.tv
.
You should reply to a PING with a PONG
But you should also send your OWN PINGs to which Twitch will PONG in case you missed a PING/PONG this’ll help keep your connection alive.
Also shouldn’t your code be
s.send(s, line.replace(“PING”, “PONG”))
As otherwise it tries to replace PING with a undefined variable?