So i have coded a small twitch irc bot, but its getting disconnected, the bot just stays ponging the pings and after 3 pongs my bot receives 0 data from twitch and disappear from the viewer list.
Here is the code(the important part):
readbuffer = ""
while (1):
readbuffer=readbuffer+s.recv(4000)
temp=string.split(readbuffer, "\n")
readbuffer=temp.pop( )
for line in temp:
print line
elif(line[0]=="PING"):
s.sendall("PONG %s\r\n" % line[1])
Its a function that is deployed as a thread 2 times with different arguments..
The thing is i see the 2 bots on twitch.tv viewer list at first for around 5 minutes then after 3 pings exactly twitch no longer pings or sends anything.
Ask me for more code if you'd like more information, please.
Maybe unrelated:
Interpret the socket as a file: https://docs.python.org/2/library/socket.html#socket.socket.makefile
f = s.makefile()
for line in f:
print 'Read:', line
command, arguments = line.rstrip().split(' ', 2)
if command == 'PING':
f.write('PONG ' + arguments + '\r\n')
That makes so many things so much easier. Please try that and comment if the problem persist.