Twitch Chat Game

Morning!

I’m trying to make a small game where I can control using the twitch chat. Something like this:

Twitch_plays_pokemon_animated

Before ask here I did my research and I think the websocket asset can help with that BUT I don’t have a clue how something like this work. I downloaded the websocket example and tried to connect to the ‘://irc-ws.chat.twitch.tv:80’ (based on their API. I hope that ‘ws’ stands for ‘websocket’ hehe). It actually connected but gets disconnected a few seconds later. Maybe I missing out the params (using client_id, login, pass. I couldn’t find a good list of things needed to make a stable connection).

So my question is: any of you ever tried to make something like this? Is the websocket asset the right tool?
Thank you!

4 Likes

Hello Alex,

I was thinking I would look into writing a library for this in the next few months. Have you setup a Client ID and setup the authentication?

Otherwise I’ll try and look into it next weekend (23rd -24th).

Cheers,
Spen

3 Likes

Yes, I got a client ID and genereated an OAuth. But like I said maybe I did something wrong on the params. I’ll take a closer look this evening and update the the thread.

I was actually going to ask about something like this myself at some point! Would be very interested in a writeup on how to use the Twitch API in Defold. The more detailed the better - I’ve had a look at their docs but don’t even know how to get the OAuth done!

3 Likes

We actually implemented this in Interrogation. It was… thorny… And I’m not sure it’s even legal use of their API (since the redirect URL points to localhost). We spin up a HTTP server inside the game serving a small HTML page to handle opening OAuth and the redirect callback, then for the actual chat, I think I adapted some IRC Lua library if I remember correctly.

4 Likes

Have fun (this might or might not work for you, no warranties disclaimer blah blah):

irc.lua (1.9 KB)
twitch_desktop.lua (7.0 KB)
url_utils.lua (736 Bytes)
redirect_page.lua (5.5 KB)

There’s some interrogation-specific stuff in there, but you should be able to adapt it. It requires defnet and luasocket.

4 Likes