Factorio server manager and Discord bridge.
ChatWire runs alongside a Linux Factorio dedicated server and handles:
- Discord slash commands and chat bridging
- Factorio process launch, stop, restart, update, and reboot workflows
- Config generation and reloads
- Player database and ban list maintenance
- Mod and Factorio update checks
- Multi-instance deployments with shared parent-level files and directories
Recent lifecycle work centralized start, stop, restart, map change, map reset, update, and ChatWire reboot handling behind a single controller with progress-aware timeouts and stronger process health detection.
- Linux
- Go
1.25.0or newer to build from source - A Discord application with bot token, application ID, guild ID, and channel access
- Factorio account credentials for update and server management features
On first launch ChatWire generates default config files and supporting directories. It must be able to create files in its own directory and in the parent directory.
Common generated files and directories:
cw-local-config.json../cw-global-config.jsoncw.lock../playerdb.json../map-gen-json/./log/./audit-log/../www/public_html/archive/
git clone https://github.com/Distortions81/M45-ChatWire.git
cd M45-ChatWire
go buildThis produces the ChatWire binary in the current directory.
- Build the binary with
go build. - Run
./ChatWireonce to generatecw-local-config.jsonand../cw-global-config.json. - Edit those config files with your Discord credentials, Factorio credentials, and server paths.
- Register slash commands with
./ChatWire -regCommands. - Start the service with
./ChatWire.
If you need to regenerate config files, delete cw-local-config.json and ../cw-global-config.json, then start ChatWire again.
The project expects a parent "base" directory layout so multiple Factorio servers can share common files.
Example:
~/factServers/
cw-a/
ChatWire
factorio/
bin/x64/factorio
That layout is only a default convention. Adjust paths in the generated config files for your environment.
| Flag | Description |
|---|---|
-cleanBans |
Clean and minimize the player database, including bans, then exit. |
-cleanDB |
Clean and minimize the player database, then exit. |
-deregCommands |
Deregister Discord commands and quit. |
-localTest |
Disable public/auth mode for testing. |
-noAutoLaunch |
Disable Factorio auto-launch. |
-noDiscord |
Disable Discord integration. |
-proxy |
HTTP caching proxy URL. Format: http://example.domain/path |
-regCommands |
Register Discord commands. |
-runtimeSelfTest |
Run runtime self-test cases, then exit. Example: start,restart,stop,change-map,update-check,chatwire-reboot |
-runtimeSelfTestTimeout |
Per-step timeout for runtime self-tests. Default: 5m |
- Visit https://discord.com/developers/applications and create a new application.
- Under Bot, add a bot user.
- Enable the privileged intents ChatWire relies on: Presence, Server Members, and Message Content.
- Grant the bot the permissions it needs in your server, including viewing channels, managing channels and roles, sending messages, embedding links, attaching files, reading message history, deleting leaked messages, and using application commands.
- Copy the bot token and the application ID.
- In Discord, enable Developer Mode and copy your guild ID.
- Copy a channel ID, or leave
ChatChannelblank incw-local-config.jsonand let ChatWire create one on first run.
After adding or changing slash commands, run ./ChatWire -regCommands again.
SIGUSR1queues a ChatWire reboot once no players are online.SIGUSR2reloadscw-local-config.jsonand../cw-global-config.json.
ChatWire watches the player database and ban list for file changes. Config reloads are triggered through /chatwire action reload-config or SIGUSR2.
For multi-instance environments, see example-files/reload-config.sh.
The moderator slash command /ip-ban manages UFW deny rules for public IPv4 addresses.
action=banadds a deny ruleaction=unbanremoves a deny ruleaction=listshows current IPv4 deny entries
This requires:
- UFW installed at
/usr/sbin/ufw - The ChatWire service user allowed to run
sudo ufwwithout a password
Example sudoers entry:
chatwire ALL=(root) NOPASSWD: /usr/sbin/ufw
Defaults!/usr/sbin/ufw !requiretty
Replace chatwire with the actual service user on your host.
The example-files/ directory includes:
- sample
systemdunits - helper scripts for start, stop, reboot, cleanup, and config reload
- sample local and global config files
Copy them and adjust paths for your deployment.
Run the standard checks before committing:
go fmt ./...
go vet ./...
go test ./...Some integration tests connect to Discord. Set CW_TEST_TOKEN, CW_TEST_GUILD, and CW_TEST_APP to enable them.
-noDiscordallows Factorio lifecycle management without connecting the bot.-noAutoLaunchprevents ChatWire from starting Factorio automatically on startup.-runtimeSelfTestis intended for exercising lifecycle actions in a live-like environment and exits when the requested cases finish.
