#Chat Plays#
A way to crowdsource commands to a program (inspired by TwitchPlaysPokemon) Using MutationObservers in the browser to send to socket.io to run keyboard events through xdotool or win32api.
##INFO: Check out /~https://github.com/hzoo/TwitchPlaysX for a less hacky version using IRC.
Code is just hacked together so don't expect too much!
##General Method##
- Get chat (twitch, etc)
- Most people are using IRC to connect to twitch chat servers.
- Parse for certain commands
- can use simple if statements, regex, switch statment, check in array of commands, etc
- hook up to a program (emulator)
- if windows
- use the win32 api
- python:
win32api.keybd_event
- C#,java
- python:
- use the win32 api
- if nix
- xdotool
- if windows
- since most ways of sending keyboard commands are sent to the focused window, you might need to run a VM so you can still use your computer.
- Otherwise with xdotool and linux you need to figure out how to stream.
- Need a modern browser to use MutationObserver (Chrome, Firefox, IE11, etc)
###If Windows###
- Node.js and npm
- socket.io npm package
npm install socket.io
- python - http://www.python.org/download/releases/2.7.6/
- python win32 package - http://sourceforge.net/projects/pywin32/files/pywin32/
###If Ubuntu###
# to get nodejs
sudo apt-get update
sudo apt-get install -y python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
# to get socket.io
npm install socket.io
# to get xdotool
apt-get install xdotool
# or go to http://www.semicomplete.com/projects/xdotool/
- then find a program to send input to (an emulator, etc) and find out the Title of it's window
- for notepad.exe it would be "Notepad" or even "Untitled - Notepad"
##Run##
-
Open program/emulator to stream to (visualboy,desmume) 1a. Change the controls on desmume (keys.py for windows, for ubuntu its just the key itself) 1b. uncheck pause if unfocused if necessary
-
Run the socket.io server in nodejs
node server.js windows window_title_of_program
or
node server.js linux window_title_of_program
#if desmume
node server.js windows Desmume
-
Copy play.js and paste in browser console on a twitch stream page
twitch.tv/streamname
-
Type commands!
on windows, the program will send inputs by focusing on the emulator so you won't be able to use your computer at that time
##Notes##
Tried using AutoIt, AHK, Powershell as well but couldn't get any version of Send or ControlSend to work properly/consistently.
Would be great to find something that could send inputs to an unfocused window.
###Other awesome things###
- /~https://github.com/Abysice/TwitchIRCBot
- /~https://github.com/aidraj/twitch-plays
- /~https://github.com/AntCGallagher/TwitchSaysPokemon
- /~https://github.com/iCart/TwitchPlaysStreetFighter
- /~https://github.com/Lnxfx/IRCGameCommander
- /~https://github.com/matias49/twitchbotirc
- /~https://github.com/whitebird/TwitchMote
- /~https://github.com/vevix/twitch-plays
- /~https://github.com/Xesyto/TwitchPlays