Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

main.py

Wituz Feb 24th, 2014 5,681 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. #Define the imports
  2. import twitch
  3. import keypresser
  4. t = twitch.Twitch();
  5. k = keypresser.Keypresser();
  6.  
  7. #Enter your twitch username and oauth-key below, and the app connects to twitch with the details.
  8. #Your oauth-key can be generated at http://twitchapps.com/tmi/
  9. username = "wituz";
  10. key = "oauth:codehere";
  11. t.twitch_connect(username, key);
  12.  
  13. #The main loop
  14. while True:
  15.     #Check for new mesasages
  16.     new_messages = t.twitch_recieve_messages();
  17.  
  18.     if not new_messages:
  19.         #No new messages...
  20.         continue
  21.     else:
  22.         for message in new_messages:
  23.             #Wuhu we got a message. Let's extract some details from it
  24.             msg = message['message'].lower()
  25.             username = message['username'].lower()
  26.             print(username + ": " + msg);
  27.  
  28.             #This is where you change the keys that shall be pressed and listened to.
  29.             #The code below will simulate the key q if "q" is typed into twitch by someone
  30.             #.. the same thing with "w"
  31.             #Change this to make Twitch fit to your game!
  32.             if msg == "q": k.key_press("q");
  33.             if msg == "w": k.key_press("w");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top