Python : Check if IRC connection is lost (PING PONG?)

后端 未结 4 1853
一向
一向 2020-12-25 09:28

So my question is, how would i get my bot to listen if there is a PING and if there\'s no ping in an interval of a minute, it will react as though the connection has been lo

4条回答
  •  有刺的猬
    2020-12-25 09:37

    You should not use data.find('PING') because it also finds "PING" in other messages. And then you send an incorrect PONG...

    Instead try something like that:

    if data[0:4] == "PING":
        irc.send("PONG " + data.split()[1] + "\n")
    

提交回复
热议问题