Twitch integration with Spelunky 2 that uses channel point rewards to generate random events.
This was made possible thanks to SilverStar07's repo on Twitch's EventSub. Please check them out!
You can use this mod for your Spelunky 2 stream, but be warned: there are quite a lot of steps to set it up. If you have any questions, you can send me a message on Discord (pigcowhybrid), and I will hopefully be able to answer.
- Pull this repo. Easiest way is probably to download the ZIP and extracting it.
- Install NodeJS
- Go to the root folder of your copy of this repo and open up a terminal (Right click->Open in Terminal)
- Run
npm install
- Install Chocolatey.
- Open up powershell and run
choco install openssl
. Note that if you used powershell to change execution policy in the previous step, you'll have to restart the powershell. - Install and authenticate ngrok. Note that after installation, you should also go to "Your Authtoken" on the ngrok dashboard and follow the instructions there.
- Open a terminal in
src\cert
- Run
openssl genrsa -out key.pem
- Run
openssl req -new -key key.pem -out csr.pem
. You will be asked for some information. You don't need to fill in any field except for common name, which should belocalhost:4000
- Run
openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
- Open
src\config.js
with a source code editor like Notepad++. You will notice some fields to fill in. - In
username
, type in any name you want in between the quotation marks. "Spelunky 2 Bot" works just fine. - Go to Twitch Chat OAuth Password Generator and press connect. Then, copy the given password (it should start with "oauth:") and paste it into the quotation marks for
password
- In
channels
, replace pigcowhybrid with the name of your twitch channel - Go to Twitch Dev Consolehttps://dev.twitch.tv/console) and create an application. Copy the given client id and paste it into the field for
API_KEY
. ClickNew Secret
and paste the given string into the field forAPI_SECRET
. - Turn on your stream. Next, go to Postman and create a new http request. Set the command to GET and the url to
https://api.twitch.tv/helix/streams?user_login=[YOUR USERNAME]
, replacing [YOUR USERNAME] with your twitch username. Click send and you will see some data. Copy the string in theuser_id
field and paste it into thebroadcaster_id
field in the config file. - (Optional) Generate a random string for
TWITCH_SIGNING_SECRET
- Open a terminal in
src
- Run
node bot.js
. You will get some errors but ignore them for now. - Go to
https://id.twitch.tv/oauth2/authorize?response_type=token&client_id=[CLIENT ID]&redirect_uri=https://localhost:4000/redirect&scope=channel:read:redemptions
, replacing[CLIENT ID]
with the client ID of your twitch app - Click accept to give permissions
- Install Modlunky if you haven't done so yet.
- Copy the entire folder into
Spelunky 2\Mods\Packs
. You should see it show up in Modlunky. - Create a reward for your channel called
the magic button
. For details on how to change this, check the "How to edit" section below.
And we are finally done with the setup!
- Open the ngrok executable and run
ngrok http https://localhost:4000
- Copy the forwarding address (it should start with "https://" and end with ".app") and paste it in line 19 of
bot.js
, replacing the already existing address. Savebot.js
. - Open a terminal in
src
- Run
node bot.js
- You are good to go! While playing Spelunky 2, if any viewer redeems "the magic button", you should get a random event.
- When stopping your stream, press Ctrl + C on both terminal windows.
You may not want to have "the magic button" as the reward, but you can change it to something else. But before that, open Data\parse.lua
. Search for if MSG == "the magic button"
and replace the magic button
with whatever your reward is called.