This bot gathers player statistics, sends broadcast messages, and uses an RCON-API integration to communicate with players. The bot now loads broadcast messages from a TXT file and sends them based on the specified interval. Follow the steps below to install and run the bot.
Execute the following commands after downloading:
- Copy the
.env.dist
file to.env
and enter your values. - Run the command
pip install python-dotenv
. - Copy
broad-stats.service.dist
to/etc/systemd/system/broad-stats.service
- Activate and start the service with
sudo systemctl enable broad-stats.service
andsudo systemctl start broad-stats.service
.
Before installing the bot, make sure you have the following:
- Python 3.8+ installed
- pip (Python package installer)
- A valid API token for the bot's integration
- Access to the RCON API for your game server
- Git installed on your machine
First, clone this repository to your local machine:
git clone https://github.com/hackletloose/hall-braod-stats.git
cd hall-broad-stats
It is recommended to use a virtual environment to manage dependencies:
python3 -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate
Install the required Python packages using pip:
pip install -r requirements.txt
Create a .env
file in the root directory with the following content:
API_TOKEN=your_api_token_here
BASE_URL=https://your-api-base-url.com
LOGGING_ENABLED=true
MESSAGE_FILE=messages.txt
Replace your_api_token_here
with your actual API token, and https://your-api-base-url.com
with the correct URL for your server. The MESSAGE_FILE
points to the text file containing broadcast messages.
The messages.txt
file is used to send pre-set messages through the bot. Each line in the file should have the format:
<time_in_seconds> <message>
For example:
7 Welcome to the server! Please follow the server rules.
60 Join our Discord for VIP access!
Start the bot using the following command:
python broad-stats.py
The bot will now:
- Fetch player statistics from the API.
- Send regular broadcast messages based on the
messages.txt
file. - Rank players in various categories (kills, defense, etc.).
If logging is enabled, you will see log messages printed to the console. To enable/disable logging, modify the LOGGING_ENABLED
variable in the .env
file.
- Error accessing API: Check if the
API_TOKEN
andBASE_URL
are correct in the.env
file. - No player data: Ensure the server is running and accessible via the API.
- Module not found: Ensure all dependencies are installed using the command
pip install -r requirements.txt
.