This is a program meant as a Twitch-Discord hybrid bot that also is a website. Made for Baalorlord on Twitch, so quite a few things are hardcoded currently. If interest picks up and people want to use it elsewhere, I will move the stuff out of the repo.
This needs Python 3.10. To set up the project, you should only need create a virtualenv and install the requirements:
python3.10 -m venv env
source env/bin/activate
pip install -r requirements.txtIf you want to change dependencies, be it upgrading or changing for a
different library, make sure to do a search-all for DEPCHECK. Those pieces of
code are likely to need attention during dependency upgrades, as they may rely
on private or unstable APIs. Conversely, they may implement a feature that is
present in later versions, and would benefit from changing it.
The data folder has a bunch of stuff to make the bot run. data.json contains
most of the commands
The documentation lives here, with the Sphinx source in the Docs repo.
python ./main.pyWhen you run it for the first time, a file called dev-config.yml will be
created, in which you can put authentication tokens and other configuration. The
configuration defaults and documentation for all the variables can be found in
default-config.yml.
The client side should run client.py. Client only needs the aiohttp library.
The client configuration needs the following to be set:
spire.steamdirserver.urlserver.secret
There will be no runs on the client initially. In order to sync your runs, while both the server and client from above are running, you'll need to complete a run in Slay the Spire. This can include just starting a run and abandoning it immediately. The synced runs can be found in the data folder in the root.
For any issues, feel free to open an issue or submit a PR.
Development discord: https://discord.gg/RHYrs3Nsve
- Clone repo from github
- Create virtual environment and install dependancies:
- Create env:
python3.10 -m venv env
- Start virtual environment:
source env/bin/activate - Install requirements:
pip install -r requirements.txt
- Create env:
- Run
python ./main.pyto start the server- At this step the website should be accessible at
localhost:8080
- At this step the website should be accessible at
- Run
python ./client.pyonce to create a skeletondev-config.ymlfile - Check
default-config.ymlanddev-config.ymlsettings and validate:- that there is a secret set for the server and,
- that the Spire path matches your OS
- Stop and restart the server (
ctrl-cto stop, thenpython ./main.py) - Stop and restart the client (
ctrl-cto stop, thenpython ./client.py)- Any Spire runs in your save file should now be visible on the website.
- Go to the discord developer site at
https://discord.com/developers/applications - Create a new application and give it a name (accept terms if necessary)
- Within this new app, click on the bot tab and create a new bot
- You'll need to record the token for this bot in order to hook it into the server - if you lose it, you'll need to generate a new one.
- Disabling the "Public Bot" setting prevents random people from adding your bot to servers
- Create an OAuth2 link to add your bot to a server using the OAuth2 URL Generator
- Select relevant permissions/scope, then click copy and paste this into a browser and complete prompts.
- Give your new bot permissions appropriate Privileged Gateway Intents (If these are not set correctly, the discord integration will fail and crash the rest of the app)
- Add the bot token to your
dev-config.ymlfile and setDiscord.enabled: true - Restart the server (
python ./main.py) - Validate functionality by using commands in discord and checking for command list on site
Twitch chat messages can be tested without setting up a full Twitch developer account. All that is required is an oath login token for your account and a chat channel to test commands in.
- Go to
https://twitchapps.com/tmi/while logged in as the account you wish to use to test and copy the oath token - In the
dev-config.yml, update thetwitch:configs:- Paste the oath token into the
oauth_token:line - Choose a channel use to test commands and put that in the
channel:line - Every twitch accout has an associated channel, so you can put your twitch username here and use that if nothing else comes to mind. - Set
enabled:totrue
- Paste the oath token into the
- Restart the server (
python ./main.py) - Navigate to the twitch channel you used and then the chat page
- Validate functionality by using commands in chat and checking for command list on site
To run all unit tests locally, run this command from within the spireblight directory:
python -m unittest discover -v -s test -t .