Update: Major code refactor for modular extensibility #2

Merged
k.eaven merged 7 commits from development into main 2026-10-24 15:33:41 +00:00
Owner

Summary

This PR contains a major refactor of the Pterodactyl Discord Bot from a monolithic pterodisbot.py into a modular structure with 10 separate modules.

Changes

Modular Refactor

  • Split pterodisbot.py (1586 lines) into 10 modules:
    • config.py - Configuration management with Pelican Panel support (pacc_/papp_ prefixes)
    • api.py - PanelAPI client for Pterodactyl/Pelican
    • models.py - Pydantic data models (requires pydantic>=2.14.1)
    • metrics.py - Server metrics tracking and graph generation
    • embeds.py - Discord embed lifecycle management
    • views.py - Discord UI components (buttons, dropdowns)
    • bot.py - Main bot class, commands, events
    • main.py - New entry point
    • logging_config.py - Logging configuration
    • exceptions.py - Custom exception classes

CI/CD Updates

  • Updated .gitea/workflows/ci-cd.yml with new module targets for coverage, linting (flake8, pylint, black, isort, mypy), security scanning
  • Added Pelican Panel test keys to test configs

Config Generation

  • Added generate_config.py with smart logic:
    • Generates config.ini from environment variables if missing
    • Uses existing config if it matches environment variables
    • Regenerates if differs (environment variables always take priority)

Docker Updates

  • Updated dockerfile to use Python 3.12, new entry point via entrypoint.sh
  • entrypoint.sh runs config generation then starts bot via main.py

Dependencies

  • Added pydantic>=2.14.1 to requirements.txt

Tests

  • All 33 tests pass with updated imports and fixed mock fixtures

Testing

  • All tests pass locally (33 passed, 10 warnings)
  • Config generation verified: creates from scratch, preserves matching, regenerates on mismatch with env priority
  • Docker entrypoint chain verified: entrypoint.sh -> generate_config.py -> main.py
## Summary This PR contains a major refactor of the Pterodactyl Discord Bot from a monolithic `pterodisbot.py` into a modular structure with 10 separate modules. ### Changes **Modular Refactor** - Split `pterodisbot.py` (1586 lines) into 10 modules: - `config.py` - Configuration management with Pelican Panel support (pacc_/papp_ prefixes) - `api.py` - PanelAPI client for Pterodactyl/Pelican - `models.py` - Pydantic data models (requires pydantic>=2.14.1) - `metrics.py` - Server metrics tracking and graph generation - `embeds.py` - Discord embed lifecycle management - `views.py` - Discord UI components (buttons, dropdowns) - `bot.py` - Main bot class, commands, events - `main.py` - New entry point - `logging_config.py` - Logging configuration - `exceptions.py` - Custom exception classes **CI/CD Updates** - Updated `.gitea/workflows/ci-cd.yml` with new module targets for coverage, linting (flake8, pylint, black, isort, mypy), security scanning - Added Pelican Panel test keys to test configs **Config Generation** - Added `generate_config.py` with smart logic: - Generates config.ini from environment variables if missing - Uses existing config if it matches environment variables - Regenerates if differs (environment variables always take priority) **Docker Updates** - Updated `dockerfile` to use Python 3.12, new entry point via `entrypoint.sh` - `entrypoint.sh` runs config generation then starts bot via `main.py` **Dependencies** - Added `pydantic>=2.14.1` to `requirements.txt` **Tests** - All 33 tests pass with updated imports and fixed mock fixtures ### Testing - All tests pass locally (33 passed, 10 warnings) - Config generation verified: creates from scratch, preserves matching, regenerates on mismatch with env priority - Docker entrypoint chain verified: entrypoint.sh -> generate_config.py -> main.py
k.eaven added 7 commits 2026-10-24 15:29:59 +00:00
Update: Major code refactor for modular extensibility
CI/CD Pipeline / Unit Tests (Python 3.11) (push) Successful in 29s
CI/CD Pipeline / Unit Tests (Python 3.12) (push) Successful in 30s
CI/CD Pipeline / Code Quality & Linting (push) Successful in 23s
CI/CD Pipeline / Unit Tests (Python 3.13) (push) Successful in 27s
CI/CD Pipeline / Integration Tests (push) Successful in 21s
CI/CD Pipeline / Security Scanning (push) Successful in 2m16s
CI/CD Pipeline / Generate Test Report (push) Successful in 4s
CI/CD Pipeline / Build Docker Image (push) Successful in 44s
CI/CD Pipeline / CI/CD Pipeline Status (push) Successful in 2s
346e6d9604
Update CI/CD workflow for modular code structure: update test targets, linting targets, coverage modules, and add Pelican Panel test keys
CI/CD Pipeline / Unit Tests (Python 3.11) (push) Successful in 40s
CI/CD Pipeline / Unit Tests (Python 3.12) (push) Successful in 40s
CI/CD Pipeline / Unit Tests (Python 3.13) (push) Successful in 43s
CI/CD Pipeline / Code Quality & Linting (push) Successful in 25s
CI/CD Pipeline / Security Scanning (push) Successful in 38s
CI/CD Pipeline / Integration Tests (push) Successful in 32s
CI/CD Pipeline / Generate Test Report (push) Successful in 4s
CI/CD Pipeline / Build Docker Image (push) Successful in 27s
CI/CD Pipeline / CI/CD Pipeline Status (push) Successful in 1s
0adc7f44e8
Add pydantic to requirements.txt for Docker container
CI/CD Pipeline / Unit Tests (Python 3.11) (push) Successful in 31s
CI/CD Pipeline / Unit Tests (Python 3.12) (push) Successful in 34s
CI/CD Pipeline / Unit Tests (Python 3.13) (push) Successful in 34s
CI/CD Pipeline / Code Quality & Linting (push) Successful in 30s
CI/CD Pipeline / Security Scanning (push) Successful in 31s
CI/CD Pipeline / Integration Tests (push) Successful in 30s
CI/CD Pipeline / Generate Test Report (push) Successful in 3s
CI/CD Pipeline / Build Docker Image (push) Successful in 7m24s
CI/CD Pipeline / CI/CD Pipeline Status (push) Successful in 2s
316416bcbe
Fix: Auto-generate config.ini from environment variables with priority logic
CI/CD Pipeline / Unit Tests (Python 3.11) (push) Successful in 26s
CI/CD Pipeline / Unit Tests (Python 3.12) (push) Successful in 33s
CI/CD Pipeline / Unit Tests (Python 3.13) (push) Successful in 33s
CI/CD Pipeline / Code Quality & Linting (push) Successful in 33s
CI/CD Pipeline / Security Scanning (push) Successful in 30s
CI/CD Pipeline / Integration Tests (push) Successful in 31s
CI/CD Pipeline / Generate Test Report (push) Successful in 4s
CI/CD Pipeline / Build Docker Image (push) Successful in 44s
CI/CD Pipeline / CI/CD Pipeline Status (push) Successful in 1s
451e202832
Fix: Update entrypoint.sh to use main.py instead of pterodisbot.py
CI/CD Pipeline / Unit Tests (Python 3.12) (push) Successful in 39s
CI/CD Pipeline / Unit Tests (Python 3.11) (push) Successful in 39s
CI/CD Pipeline / Unit Tests (Python 3.13) (push) Successful in 47s
CI/CD Pipeline / Code Quality & Linting (push) Successful in 22s
CI/CD Pipeline / Security Scanning (push) Successful in 28s
CI/CD Pipeline / Integration Tests (push) Successful in 32s
CI/CD Pipeline / Generate Test Report (push) Successful in 3s
CI/CD Pipeline / Build Docker Image (push) Successful in 51s
CI/CD Pipeline / CI/CD Pipeline Status (push) Successful in 1s
8105f11c32
Redirect program entrypoint via shell script in image
CI/CD Pipeline / Unit Tests (Python 3.12) (push) Successful in 38s
CI/CD Pipeline / Unit Tests (Python 3.13) (push) Successful in 47s
CI/CD Pipeline / Code Quality & Linting (push) Successful in 35s
CI/CD Pipeline / Security Scanning (push) Successful in 32s
CI/CD Pipeline / Unit Tests (Python 3.11) (push) Successful in 23s
CI/CD Pipeline / Integration Tests (push) Successful in 27s
CI/CD Pipeline / Generate Test Report (push) Successful in 4s
CI/CD Pipeline / Build Docker Image (push) Successful in 55s
CI/CD Pipeline / CI/CD Pipeline Status (push) Successful in 2s
CI/CD Pipeline / Unit Tests (Python 3.11) (pull_request) Successful in 31s
CI/CD Pipeline / Unit Tests (Python 3.13) (pull_request) Successful in 33s
CI/CD Pipeline / Unit Tests (Python 3.12) (pull_request) Successful in 33s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 26s
CI/CD Pipeline / Code Quality & Linting (pull_request) Successful in 33s
CI/CD Pipeline / Security Scanning (pull_request) Successful in 33s
CI/CD Pipeline / Build Docker Image (pull_request) Skipped
CI/CD Pipeline / Generate Test Report (pull_request) Successful in 3s
CI/CD Pipeline / CI/CD Pipeline Status (pull_request) Successful in 2s
49848286d7
k.eaven merged commit 92104fb4bf into main 2026-10-24 15:33:41 +00:00
Sign in to join this conversation.