Hey there! I"m trying to create a Twitch Plays Bot using Python.
I connect with this method (I have my oauth setup, don’t worry)
def twitch_connect(self, user, key):
self.user = user;
self.oauth= key;
print("Connecting to twitch.tv");
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM);
s.settimeout(0.6);
connect_host = "irc.twitch.tv";
connect_port = 6667;
try:
s.connect((connect_host, connect_port));
except:
print("Failed to connect to twitch");
sys.exit();
print("Connected to twitch");
print("Sending our details to twitch...");
s.send(('USER %s\r\n' % user +
'PASS %s\r\n' % key +
'NICK %s\r\n' % user).encode('utf-8'));
if not self.twitch_login_status(s.recv(1024)):
print("... and they didn't accept our details");
sys.exit();
else:
print("... they accepted our details");
print("Connected to twitch.tv!")
self.s = s;
s.send(('JOIN #%s\r\n' % user).encode('utf-8'))
s.recv(1024);
But then receiving a message will always ALWAYS time out, from the begginig
def twitch_recieve_messages(self, amount=1024):
data = None
try: data = self.s.recv(1024);
except:
print("FUCK!");
return False;
if not data:
print("Lost connection to Twitch, attempting to reconnect...");
self.twitch_connect(self.user, self.oauth);
return None
What is going on?