stormworkschatgpt v2.1.0
Stormworks Chatbot
This is a Node.js server script that allows a chatbot to communicate with players in the game Stormworks. The script uses HTTP to receive messages from the Stormworks server through GET requests. The received messages are then sent to OpenAI's API for processing using the GPT-3.5 language model. The model generates a response that is sent back to the Stormworks server and displayed in the in-game chat.
The conversation history is stored in an array called conversationLog
, which keeps track of the role of the participant (user or assistant) and the message content. The server listens on port 3000 for incoming HTTP GET requests from the Stormworks server, and if the requested URL matches /127.0.0.1
, the response is sent back to the Stormworks server and displayed in the in-game chat. If the requested URL does not match /127.0.0.1
, a 404 Not Found error message is sent.
The script uses the dotenv
package to load environmental variables from a .env
file, including the OpenAI API access token used for authentication.
Installation
- Subscribe to the addon on the Steam Workshop
- Install Node.js
https://nodejs.org/en/download
- Install the required dependencies using
npm i stormworkschatgpt
- Create a
.env
file and add the following variable with your OpenAI API key:
OPENAI_ACCESS_TOKEN=your_api_key_here
Feel free to contact me on discord if you need any extra help: Foll#8000 Temporary Api key may be granted if asked nicely
Usage
- Start the server using
npm start
- In Stormworks, start a server with the addon enabled
- Now open Stormworks chat and send a message
- The chatbot will respond with a message generated by the OpenAI GPT-3.5 model
Commands
The following commands can be used in-game to interact with the chatbot:
?pm [text]
- Sends a private message to the chatbot. Replace[text]
with the message you want to send.?cao
- Toggles Admin-only mode.?cpmo
- Toggles private messages only mode.?ctr [number]
- Changes the timeout retry time. Replace[number]
with the desired retry time in seconds.
Dependencies
http
- Node.js HTTP module for creating the serverurl
- Node.js module for parsing URL stringsdotenv
- loads environmental variables from a.env
fileopenai
- a Node.js client for OpenAI's API
License
This project is licensed under the ISC License - see the LICENSE file for details.