A Discord bot for HumanitZ dedicated game servers. Provides real-time server status monitoring, bidirectional chat bridge, and player tracking — all powered by RCON.
- 📊 Live Server Status Embed — Auto-updating Discord message showing server name, player count, season/weather, AI stats (zombies, bandits, animals), death count (configurable time window), game time, FPS, and system resources (CPU/RAM/disk/network)
- 💬 Bidirectional Chat Bridge — Relay messages between in-game chat and a Discord channel in real time, with echo prevention and @mention sanitization
- 📈 Player Count Chart — 24-hour (configurable) history chart with Discord-themed dark styling
- 👥 Player Online Duration — Shows how long each player has been connected, parsed from server logs
- 🗄️ SQLite Database — Persistent storage for player count history, chat logs, and player session events with automatic data pruning
- 🌐 Internationalization — English and Traditional Chinese (繁體中文) UI support
- 📝 Daily Rotated Logs — Configurable log retention with daily rotation
src/humanitz_bot/
├── __main__.py # Entry point, logging setup, signal handling
├── bot.py # Discord bot initialization, cog loading
├── config.py # Settings from .env with validation
├── rcon_client.py # Source RCON protocol (optimized for HumanitZ)
├── cogs/
│ ├── server_status.py # Status embed auto-update loop (30s default)
│ └── chat_bridge.py # Chat bridge polling loop (5s default)
├── services/
│ ├── database.py # SQLite with WAL mode + thread safety
│ ├── rcon_service.py # Async RCON wrapper with auto-reconnect
│ ├── chart_service.py # Matplotlib chart generation
│ ├── player_tracker.py# Online duration from PlayerConnectedLog.txt
│ └── system_stats.py # CPU, memory, disk, network via psutil
└── utils/
├── chat_parser.py # fetchchat markup parser + dedup differ
├── formatters.py # Progress bars, duration, emoji maps
└── i18n.py # en + zh-TW translations
- Python 3.12+
- uv — Fast Python package manager
- A HumanitZ dedicated server with RCON enabled
- A Discord Bot Token (create one here)
Note: Windows is supported but has not been tested in production. If you encounter any issues, please open an issue.
git clone https://github.com/Minidoracat/humanitz-bot.git
cd humanitz-botuv synccp .env.example .envEdit .env and fill in your values:
| Variable | Required | Description |
|---|---|---|
DISCORD_TOKEN |
✅ | Bot token from Discord Developer Portal |
STATUS_CHANNEL_ID |
✅ | Channel for the status embed |
CHAT_CHANNEL_ID |
✅ | Channel for the chat bridge |
RCON_PASSWORD |
✅ | RCON password (from GameServerSettings.ini) |
RCON_HOST |
RCON address (default: 127.0.0.1) |
|
RCON_PORT |
RCON port (default: 8888) |
|
STATUS_MESSAGE_ID |
Pin the status embed to a specific message (leave blank to auto-create) | |
MAX_PLAYERS |
Max player count from GameServerSettings.ini (default: 50) |
|
SHOW_SYSTEM_STATS |
Show host system stats in embed (default: true; set false for remote setups) |
|
SHOW_CONNECT_INFO |
Show server IP:Port in the status embed (default: false) |
|
SERVER_CONNECT_INFO |
Public server address for direct connect (format: IP:Port) |
|
SHOW_DEATH_COUNT |
Show player death count in embed (default: true) |
|
DEATH_COUNT_HOURS |
Time window in hours for death count (default: 24) |
|
LOCALE |
en or zh-TW (default: en) |
|
PLAYER_LOG_PATH |
Path to PlayerConnectedLog.txt |
See .env.example for all options with detailed descriptions. A Traditional Chinese version is also available.
uv run python -m humanitz_botcp .env.example .env # edit .env first
docker compose up -dNote: System stats (CPU, memory, disk) will reflect the container's resources, not the host machine.
Make sure RCON is enabled in your GameServerSettings.ini:
RCONEnabled=true
RConPort=8888
RCONPass=your_password_hereThe bot requires these permissions (intents):
- Message Content — Read messages for chat bridge
- Send Messages — Send chat and status messages
- Embed Links — Display status embed
- Attach Files — Upload player count chart
Enable Message Content Intent in Discord Developer Portal → Bot → Privileged Gateway Intents.
HumanitZ uses a modified Source RCON protocol with some quirks:
- Response
request_idis always0(non-standard) - Does not respond to empty commands (end-marker technique unusable)
- Auth flow: server sends
RESPONSE_VALUE(type=0) thenAUTH_RESPONSE(type=2) - ~3 second response delay per command
The bot handles all of these automatically.
| Path | Content | Tracked by Git |
|---|---|---|
data/humanitz_bot.db |
SQLite database (player counts, chat logs, sessions) | ❌ |
data/status_state.json |
Persisted status message ID for restart resilience | ❌ |
tmp/player_chart.png |
Latest player count chart (overwritten each cycle) | ❌ |
logs/bot.log |
Application logs (daily rotation) | ❌ |
All runtime data is excluded from git via .gitignore.
