Correct way to response to PING IRCBOT reddit / irc ---------------------------------------------------------------------- lazyfingersy · 2021-01-30 18:18 `while 1:` `time.sleep(2)` `data=s.recv(2040).decode('utf8')` `data = data.strip("\n\r")` `print(data)` `if data.find ("PING :"):` `s.send(bytes(f'PONG {data.split()[1]}\r\n' .encode('UTF-8')))` ​ I'm ending up with broken pipe error. ---------------------------------------------------------------------- MachaHack · 2021-01-30 20:27 It's been a while since I did IRC programming but things to check: 1. Are you getting multiple messages in a single recv? e.g. is the value of data something like `:user@foo PRIVMSG abcdef\r\nPING foobar\r\n:user2@bar PRIVMSG adb` 2. You've mixed up the order of `\n\r` - it should be `\r\n`. 3. PING's final parameter is not necessarily multipart. `PING WiZ` is a valid PING message from rfc1459 - notice no `:`.