Hello I dunno if this is the right section or not but I don’t have a clue what I am doing but I have set up a python program it connects to my twitch all fine but after so long it keeps losing connecting and then close itself down or says connection was shut by a remote location. Dunno what I am doing wrong but would like some help/advice.
This file here is main . Py
#Define the imports
import twitch
import keypresser
import keyholder
t = twitch.Twitch();
k = keypresser.Keypresser();
#Enter your twitch username and oauth-key below, and the app connects to twitch with the details.
#Your oauth-key can be generated at http://.com/tmi/
username = “abc”;
key = “abc”;
t.twitch_connect(username, key);
#The main loop
while True:
#Check for new mesasages
new_messages = t.twitch_recieve_messages();
if not new_messages:
#No new messages...
continue
else:
for message in new_messages:
#Wuhu we got a message. Let's extract some details from it
msg = message['message'].lower()
username = message['username'].lower()
print(username + ": " + msg.encode('utf-8'));
#This is where you change the keys that shall be pressed and listened to.
#The code below will simulate the key q if "q" is typed into twitch by someone
#.. the same thing with "w"
#Change this to make Twitch fit to your game!
if msg == "w": keyholder.holdForSeconds(msg, 0.3);
if msg == "b": keyholder.holdForSeconds(msg, 0.3);
if msg == "a": keyholder.holdForSeconds(msg, 0.1);
if msg == "d": keyholder.holdForSeconds(msg, 0.1);
if msg == "x": keyholder.holdForSeconds(msg, 0.5);
if msg == "q": keyholder.holdForSeconds(msg, 0.1);
if msg == "r": keyholder.holdForSeconds(msg, 0.5);
if msg == "y": keyholder.holdForSeconds(msg, 0.1);
if msg == "u": keyholder.holdForSeconds(msg, 0.1);
if msg == "f": keyholder.holdForSeconds(msg, 0.1);
if msg == "e": keyholder.holdForSeconds(msg, 0.1);
if msg == "l": keyholder.holdForSeconds(msg, 0.1);