Farmbot Factorio is a discord bot for managing a Factorio server. It utilises pycord for discord interaction, factorio_rcon to talk to the factorio process, and the public factorio API for checking version information. It is developed and tested on Ubuntu 24.04, but should be easy to adapt to other operating systems that utilise systemd.
- Service management with systemd, including example systemd service files.
- Automatic updating of the code (checks to see if anyone is currently on the server first).
- Executing some in-game commands and returning output to Discord.
- Savegame upload and management (Can stop the server and switch between different savegames).
- A JSON configuration file that can store basic user data, and provide a link between ingame users and discord users.
- A basic permissions system to control who can run which discord command. It supports a range of 0-15, where 0 is no permissions and 15 is full admin.
- Create a linux service user for
factorio. - Create a linux service user for
farmbot-factorio, adding to thefactoriogroup (required for updating to work). - Download and extract factorio to
/opt/factorio, ensuring that thefactoriouser and group are the owners. - Download the repository to
/opt/(so the full path will be/opt/farmbot-factorio/), ensuring that thefarmbot-factoriouser and group are the owners. - Create your python venv (
farmbot-factorio-envis the recommended name, as this is already part of the.gitignorefile). - Install requirements as per
requirements.txt. - Use the
config.example.jsonfile to createconfig.jsonwith your settings. (/opt/farmbot-factorio/config.json) - Use the
factorio.example.servicefile to install factorio as a service within systemd (/etc/systemd/system/factorio.service). Also remember to set the rcon password to match what is in yourconfig.jsonfile. - Use the
farmbot-factorio.example.servicefile to install farmbot-factorio as a service within systemd (/etc/systemd/system/farmbot-factorio.service) - Use the
factorio.sudoers.examplefile to allowfarmbot-factorioservice permissions via sudo. (/etc/sudoers.d/factorio) - Use the
update.example.pyfile to create anupdate.pyfile. This is executed as part of systemd starting the service. (Default/opt/factorio/update.py) - Reload daemons in systemd to read the new files (
systemctl daemon-reload)
This is not an exhaustive list of all commands, but a few base features:
- Enabling automatic updates:
- Run
/enableupdatenotificationsin a channel that you want the update notifications to be posted in. - Run
/enableautomaticupdates.
- Run
- Uploading and activiating a new save:
- Run
/uploadnewfactoriosaveand provide the ZIP file. - Run
/activatefactoriostashedsaveto load the save. This will stop the server, re-arrange the save files, and start the server again.
- Run
- Using the whitelist feature in Factorio:
- Ask user to run
/registerfarmbotuserto create themselves a privilege level 1 farmbot user. - Ask user to run
/registerfactoriousernameto add their factorio username to their farmbot user, and add it to the ingame whitelist.
- Ask user to run
- Adjusting a user's permission level
- Once a user has registered, use
/setfarmbotuserpermissionlevel
- Once a user has registered, use
- Mod management
- Switching between Factorio update channels (stable / experimental)