Wituz

main.py

Feb 24th, 2014
7,271
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×