Update System¶
Overview¶
The PigPig Bot features a sophisticated update system divided into two parts: a Command-Line Interface (CLI) for manual management and an integrated background service for automatic checks.
Update CLI (update.py)¶
A lightweight wrapper for the update architecture, allowing administrators to manage versions from the terminal.
Usage¶
| Command | Action |
|---|---|
python update.py -c |
Check the current version against GitHub. |
python update.py -l |
Download and install the latest stable version. |
python update.py -b |
Install the latest beta version. |
python update.py -v <version> |
Install a specific version/tag. |
Internal Architecture (addons/update/)¶
The system is built on several specialized modules:
manager.py: Coordinates the update process and interacts with the bot instance.checker.py: Queries the GitHub API to compare local and remote versions.downloader.py: Handles secure downloading and extraction of update packages.security.py: ValidatesBOT_OWNER_IDpermissions before allowing updates.notifier.py: Provides interactive Discord UI (buttons) for initiating updates.
Update Process Flow¶
- Detection:
VersionCheckeridentifies a new release on GitHub. - Permission Check:
UpdatePermissionCheckerensures the user has administrative rights. - Download:
UpdateDownloaderfetches the ZIP archive to a temporary directory. - Installation:
UpdateManagerextracts the files, preserving the.envanddata/folders. - Completion: The bot logs the success and requires a restart to apply changes.
Configuration¶
Settings for the update system are managed in base_configs/update.yaml:
- Repository: starpig1129/ai-discord-bot-PigPig
- Branch: main (default) or beta.
- Auto-check: Enable/disable background checks on startup.
Always ensure you have a backup of your data before performing a major version update.