Jump to content

[Release] Twitch Chat Integration (PyWitch)


Recommended Posts


THIS MOD REQUIRE EXTERNAL TOOLS TO WORK, FOLLOW THE INSTRUCTIONS CAREFULLY!
 


PyWtich: Twitch Chat Integration

This mod uses from a external tool called PyWitch Client to capture Twitch events, like chat messages, and show these events in-game.

For this version, only chat-messages are being integrated.

Everything is open source, so you can check PyWitch, PyWitch Client and PyWitch Auth in my Github!

How to use

First, you need to download PyWitch Client from the RELASES page in my Github. You can do so by clicking this text

I strongly recomend you to download it from source and run it using Python

After downloading and openning it, read the EULA. Since PyWitch Chat read from your Twitch Chat, your authorization will be required in the next step.
If you agree with the EULA, PyWitch Client will be ready to use.
Now you need to write your channel in the "channel box" (you can find your channel by acessing it on Twitch and reading the current URL).
Feel free to disable all features, leaving only PyWitch Chat enabled. The other features will be avaible in the following versions of this mod.

After that, click "Start PyWitch Server". Now a tab in your browser will be open, requesting authorization. This authorization is necessary to PyWitch Client be able to read your chat messages.

The authorization will redirect you to a tab with the name of all streamers that are using PyWitch Auth! Please consider visiting and supporting these Streamers channels!

For safety reasons, after you get your token from PyWitch Auth, it will be destroyed from the server, so if your token become invalid, a new one need to be generated.

Now, just wait for PyWitch Client to establish connection with Twitch server and its done! You can verify its working by acessing the following localhost URL:

127.0.0.1:13846/tmi

If you see an empty json "{}", PyWitch Client started correctly
Now, send a message in your Twitch Chat and hit the refresh button in the PyWitch Client TMI URL.

If everything is working fine, you will see an json with your message and display name.

And its done!

In game, you just need to install the mod to your server and, in-game, open the PyWitch Menu by click its logo in the bottom left corner and hit the "Activate" button!

Now you will see the following Twitch Chat messages in your game!!

Upcoming features

As you can see from PyWitch and PyWitch Client, it already has some extra features. In the upcoming versions of this mod you will be able to capture Twitch Chat Redemptions in your server, making unique events and interactions to your game!

How it work

Don't Starve Together provides an internal function to perform REQUESTS on HTTP servers, which is very great to access data from server. However, Twitch Events, like chat messages and chat redemptions can only be accessed by WebSockets.
So, I developed a Python library to capture these events from Twitch. This library is called "PyWitch", and its source can be accessed by the following URL:

https://github.com/ouriquegustavo/pywitch

Ok, we are able to recover Twitch Events using a Python script... But we need to transfer that to Don't Starve Together.
To do so, I developed PyWitch Client, which is a GUI Interface combined with Web Framework (Flask). Its main purpose is to get events from Twitch using PyWitch and provide them on a localhost endpoint using Flask. Its source can be accessed by the following URL:

https://github.com/ouriquegustavo/pywitch_client

Now we can access Twitch Events from an HTTP server provided by PyWitch Client, the only remaining thing to solve is the token authentication.
Token authentication is made server side PyWitch Auth, which the source can be seen in the following URL:

https://github.com/ouriquegustavo/pywitch_auth

PyWitch Auth receives code from Twitch Authorization page and perform the required OAuth flow to generate the associated access token.
Any token is stored PyWith Auth server for more than 120 seconds. If you are not able to recover your token in this time, it will be destroyed. Every token generated in the server has an unique 128 characters state-code used for token request.
The server only will store public information about your Twitch user, like 'Display Name'. So I can recommend your live to other streamers :D

Special thanks!

I want to thanks HypeZ, 2000 and Butterflyholix for helping me testing this mod!

Enjoy!

Workshop Link:
https://steamcommunity.com/sharedfiles/filedetails/?id=2655149465

 

Edited by Gleenus
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...