I was working on an IRC-bot as a little Python project. The bot works quite good, but is unable to stay connected for a long time. After a while, it just prints emptylines to the terminal and then pings out (because it can’t process the PING from the server).
This bit of code handles the receiving part:
def listen(channel):
while True:
data = conn.recv(4096)
print data
if data != '':
if data.split()[0] == 'PING':
process the data
After a while, the bot just prints whitelines to the terminal and I have no idea why.
The full code is available here on Github: https://github.com/Silox/Python-IRC-bot/blob/master/bot.py#L101
Quoting from here:
The server has closed the connection on you, probably due to a timeout since you are not replying to its pings.