Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kookiiestudios/palcon-discord

A Python-based Discord bot for PalWorld server administration via RCON
https://github.com/kookiiestudios/palcon-discord

discord discord-bot discord-py palworld palworld-dedicated-server palworld-rcon palworld-tool rcon-client

Last synced: 2 months ago
JSON representation

A Python-based Discord bot for PalWorld server administration via RCON

Awesome Lists containing this project

README

        

# PalCON Discord
A Python-based Discord bot for PalWorld server administration via RCON.

This is an experimental project for a PalWorld remote console via Discord chat bot.
Control and monitor your Pal World Servers remotely using this Discord Bot.

See Gallery below to view some of the features the bot provides.

## Gallery

![Info](https://github.com/KOOKIIEStudios/PalCON-Discord/assets/58405975/a3a75e93-7b67-408b-8b53-93470dba9a0f)

![OnlineCommand](https://github.com/KOOKIIEStudios/PalCON-Discord/assets/58405975/149e93ac-3b33-4eaa-8f5f-9d179394074f)

![Save](https://github.com/KOOKIIEStudios/PalCON-Discord/assets/58405975/7d518b99-067a-4452-a5d9-4cd02d755b90)

![ShutdownSlashCommand](https://github.com/KOOKIIEStudios/PalCON-Discord/assets/58405975/efde4aec-a07d-48f1-80be-894548c5267c)

![Shutdown](https://github.com/KOOKIIEStudios/PalCON-Discord/assets/58405975/e1127f4d-46bf-40f3-bb07-9047dae4d50f)

## Tech Stack
This project **requires** Python 3.11+. This is a pain point for Linux users, as Ubuntu Jammy (we have not checked other distros) currently only officially supports 3.10. We've included instructions for users who are on Ubuntu in the following section.

We initially wanted to use [Richard Neumann's RCON client implementation](https://pypi.org/project/rcon/),
but since Palworld's RCON server doesn't follow specifications properly, said library wasn't working for Palworld.
We have currently switched to [tama's implementation](https://github.com/ttk1/py-rcon), which is technically for Minecraft, but is working for us. One caveat (based on issue [#6](https://github.com/KOOKIIEStudios/PalCON-Discord/issues/6)) being that it makes assumptions about encoding, which causes packet read errors when players have non-latin characters in their IGN (not an issue for Minecraft which only allows latin characters).

## Environment Installation
1. *(Windows)* Download [Python](https://www.python.org/downloads/) and **SET IT TO PATH DURING INSTALLATION**.
![image](https://github.com/KOOKIIEStudios/PalCON-Discord/assets/58405975/abe48ef4-01bb-45d7-81ba-d9b6a38846e0)
- Note: If you install using a package manager like Chocolatey, this will be done for you automatically
- Instructions for Linux can be found in the following sub-section
2. Clone this repository
3. Create a file `config.toml` at the root of the project, using the provided [`config_example.toml`](https://github.com/KOOKIIEStudios/PalCON-Discord/blob/main/config_example.toml) as a guide
- For Discord bot token, see the following section for instructions for setting up your own Discord bot
- For IP address, use the public IP of your game server if the Discord bot is not on the same machine; otherwise `localhost` is fine
- For port and password, see the RCON server set-up section below
4. *(UNIX-like)* Use `setup.sh` to set up your virtual environment
- Note: Script files require permissions; e.g.: `chmod +x setup.sh start.sh`
- If you're on Windows, running the `start.bat` file will automatically set up your virtual environment!
5. Use `start.bat`/`start.sh` to run the Discord Bot!
- Log files are saved to `/logs` and rotated at midnight.
- Log files are automatically excluded from git

### Installing Python 3.11 on Ubuntu Jammy
*Credits: Adapted from [an article Rehan Haider](https://cloudbytes.dev/snippets/upgrade-python-to-latest-version-on-ubuntu-linux)*

This is only a temporary measure until Ubuntu officially adds support for Python 3.11+.

1. Update your system: `sudo apt update && sudo apt upgrade -y`
2. Add deadsnakes as third party repository: `sudo add-apt-repository ppa:deadsnakes/ppa`
3. Fetch package list: `sudo apt update`
4. Install Python 3.11 `sudo apt install python3.11`
5. Re-install the Python interface for APT
- `sudo apt remove --purge python3-apt`
- `sudo apt autoclean`
- `sudo apt install python3-apt`
6. Manually install distutils: `sudo apt install python3.11-distutils`
7. Manually install pip
- `cd` to a temporary location
- Download the installation script: `curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py`
- Run the installation script: `sudo python3.11 get-pip.py`
8. Manually install venv: `sudo apt install python3.11-venv`
9. `nano setup.sh` and `nano start.sh` to replace all instances of `python3` with `python3.11`

### Updating PalCON-Discord
We don't provide release versions, nor package the contents of this repository,
so you can update to the latest version by simply performing `git pull`.

## Discord Bot Setup
1. Create your Discord Bot using the [Discord Developer Portal](https://discord.com/developers/applications)
2. Click on New Application at the top right of the web page.
- Insert a Name and click `Create` and click on your new Application.

![New Application](https://github.com/KOOKIIEStudios/PalCON-Discord/assets/58405975/10bb1f8f-7ba1-4507-95eb-15a6d3495fcf)

3. Click on the `Bot` Section of the Discord Application:

![Bot](https://github.com/KOOKIIEStudios/PalCON-Discord/assets/58405975/82d8a083-89fb-489b-8621-9eaa16017464)

4. Copy your discord bot token and put it into the `config.toml` that you've created.
5. Ensure your discord bot has these settings appropriately marked.

![Discord Bot Settings](https://github.com/KOOKIIEStudios/PalCON-Discord/assets/58405975/5e797761-0a66-4c27-9408-abe00d34cb56)

6. Invite the Discord Bot with the following scopes: bot & applications.commands

![Permissions](https://github.com/KOOKIIEStudios/PalCON-Discord/assets/58405975/68f28ebb-5b80-4507-aa6b-76ebf832464d)

> [!TIP]
Use a [Discord Permissions Calculator](https://discord.com/developers/applications/1201282683205062676/oauth2/url-generator) to make your life easier!

> [!IMPORTANT]
Do note that the slash commands may take up to an hour to propagate for ALL servers the bot is on.

## RCON Server Set-up
1. Open the Palworld configuration file using the appropriate path
- The following are relative paths to Steam/SteamCMD's install directory:
- Windows: `steamapps/common/PalServer/Pal/Saved/Config/WindowsServer/PalWorldSettings.ini`
- Linux: `steamapps/common/PalServer/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini`
2. Scroll all the way to the right of the second line
3. Set the RCON port using the `RCONPort` variable
- e.g. `RCONPort=255575`
4. Turn on RCON: `RCONEnabled=True`
5. Set the administrator password for toggling admin mode (this also doubles as the RCON password)
- e.g. `AdminPassword="insertpasswordhere"`
6. Modify firewall rules for the RCON port
- e.g. `sudo ufw allow 255575/tcp`
- **MAKE SURE YOU'RE AWARE OF THE SECURITY RISKS OF DOING SO**
7. Port-forward the RCON port
- Refer to your router's instructions for more details