TwitchPlaysPokemon - How does it work? reddit / irc ---------------------------------------------------------------------- ShitfaceTom · 2014-02-17 21:22 The whole concept is interesting. How does it work? What's the behind the scenes stuff? ---------------------------------------------------------------------- [deleted] · 2014-02-17 21:29 [deleted] ---------------------------------------------------------------------- Nascimentos · 2014-02-17 21:29 "The broadcaster chooses to remain anonymous, but he did share how the channel works. "I wrote a script in Python that listens for buttons said in chat and simulates a keypress for the corresponding button in the emulator. The script also outputs button presses to a locally- hosted website which provides the overlay. I use Open Broadcaster Software to merge the website and emulator output into a video feed that gets sent off to Twitch." [Source](http://www.gamespot.com/articles/over-60k-people-watching- twitch-play-pokemon-update/1100-6417762/) ---------------------------------------------------------------------- shadowh511 · 2014-02-19 00:29 Pretty much: Twitch chat exposes an IRC-like interface I wrote something similar in python as programming challenge and would be happy to explain it. https://github.com/lyska/StreamControl/blob/master/main.py The part that you would care about is here: https://github.com/lyska/StreamControl/blob/master/main.py#L33-L51 elif message.verb == "PRIVMSG": `PRIVMSG` is the verb from the server that means a channel or private message is being directed toward the bot. key = message.args[-1].lower() With the IRC line parsing code I use, `message.args` is an array of all the arguments to the verb. if key == "a": pressKey("z") elif key == "b": pressKey("x") elif key == "down": pressKey("j") elif key == "up": pressKey("k") elif key == "left": pressKey("h") elif key == "right": pressKey("l") elif key == "start": pressKey(";") elif key == "select": pressKey("p") If you have any more questions about how my simple example works, please let me know and I will explain it further to the best of my ability. ---------------------------------------------------------------------- ShitfaceTom · 2014-02-19 09:04 Really interesting and would love if you'd explain it more! ---------------------------------------------------------------------- [deleted] · 2014-02-24 23:05 what language are you using? wouldn't a switch statement be more efficient? ---------------------------------------------------------------------- sprocklem · 2014-03-11 01:03 That looks to be Python which doesn't have a switch statement.