Files

286 lines
8.0 KiB
Markdown
Raw Permalink Normal View History

2026-03-12 21:45:01 +00:00
# Minecraft Update Bot
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
Version 1.0.0 - Automatically detects new Minecraft releases (Java and Bedrock editions) and posts announcements to a subreddit.
2026-03-11 23:24:42 +00:00
## Features
2026-03-12 21:45:01 +00:00
Core functionality:
- Polls the official Minecraft launcher manifest for new Java Edition releases
- Detects Minecraft Bedrock Edition updates via minecraft.wiki scraping
- Posts new releases to a configured subreddit automatically
- Maintains a database of posted versions to prevent duplicate posts
- Supports multiple release types (releases, snapshots, beta versions)
- Configurable check interval for polling
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
Advanced features:
- Customizable post templates via subreddit wiki configuration
- Different post formats for different release types
- Moderator chat commands for config reload and manual reposting
- Automatic bot update notifications via modmail
- Docker and Docker Compose deployment ready
- Persistent version tracking across container restarts
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
## Quick Start
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
### Docker (Recommended)
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
1. Copy the environment template:
```bash
copy .env.example .env
```
2. Edit `.env` with your Reddit credentials:
```
REDDIT_CLIENT_ID=your_id
REDDIT_CLIENT_SECRET=your_secret
REDDIT_USERNAME=your_username
REDDIT_PASSWORD=your_password
SUBREDDIT=your_subreddit
```
3. Start the bot:
```bash
docker-compose up -d
```
4. View logs:
```bash
docker-compose logs -f
```
2026-03-11 23:24:42 +00:00
See [DOCKER.md](DOCKER.md) for detailed Docker setup instructions.
2026-03-12 21:45:01 +00:00
### Manual Setup
1. Install dependencies:
```bash
pip install -r requirements.txt
```
2. Create a Reddit application at https://www.reddit.com/prefs/apps (select "Script" type)
3. Configure environment variables or edit config.py:
```bash
set REDDIT_CLIENT_ID=your_client_id
set REDDIT_CLIENT_SECRET=your_client_secret
set REDDIT_USERNAME=your_username
set REDDIT_PASSWORD=your_password
set SUBREDDIT=your_subreddit
python main.py
```
## Configuration
### Environment Variables
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
Required variables:
- REDDIT_CLIENT_ID - Your Reddit OAuth app client ID
- REDDIT_CLIENT_SECRET - Your Reddit OAuth app secret
- REDDIT_USERNAME - Reddit account username
- REDDIT_PASSWORD - Reddit account password
- SUBREDDIT - Target subreddit name
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
Optional variables:
- REDDIT_RELEASE_TYPES - Comma-separated types: release,snapshot (default: release)
- REDDIT_CHECK_BEDROCK - Enable Bedrock detection: true or false (default: false)
- REDDIT_CHECK_INTERVAL - Seconds between checks (default: 3600)
- REDDIT_WIKI_PAGE_NAME - Wiki page for post templates (default: minecraft_update_bot)
- REDDIT_USER_AGENT - API user agent string (default: MinecraftUpdateBot/1.0)
### Wiki Configuration
Post templates are defined in a subreddit wiki page (default name: minecraft_update_bot).
Create entries for each release type with title and body templates:
2026-03-11 23:24:42 +00:00
```yaml
release:
2026-03-12 21:45:01 +00:00
title: "Minecraft {version} Released"
2026-03-11 23:24:42 +00:00
body: |
2026-03-12 21:45:01 +00:00
New version available at minecraft.net
Released: {release_date}
2026-03-11 23:24:42 +00:00
snapshot:
title: "Minecraft {version} Snapshot"
body: |
2026-03-12 21:45:01 +00:00
Test build available in launcher
Released: {release_date}
bedrock-windows:
title: "Bedrock Edition {version} Available"
body: |
Download from Microsoft Store
Released: {release_date}
2026-03-11 23:24:42 +00:00
```
2026-03-12 21:45:01 +00:00
Available placeholders: {version}, {release_date}, {type}
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
See [WIKI_CONFIG.md](WIKI_CONFIG.md) for complete wiki configuration details.
2026-03-11 23:29:13 +00:00
2026-03-12 21:45:01 +00:00
## Moderator Chat Commands
2026-03-11 23:29:13 +00:00
2026-03-12 21:45:01 +00:00
Moderators can control the bot via Reddit chat messages:
2026-03-11 23:29:13 +00:00
2026-03-12 21:45:01 +00:00
**reload-config**
- Reloads wiki configuration without restarting the bot
- Usage: Send a chat message containing "reload-config"
- Response: Bot replies with success or failure status
2026-03-11 23:29:13 +00:00
2026-03-12 21:45:01 +00:00
**repost-latest**
- Reposts the latest releases (bypasses duplicate check)
- Usage: Send a chat message containing "repost-latest"
- Response: Bot replies with number of versions reposted
2026-03-11 23:29:13 +00:00
2026-03-12 21:45:01 +00:00
## Bedrock Edition Support
2026-03-11 23:29:13 +00:00
2026-03-12 21:45:01 +00:00
The bot can track Minecraft Bedrock Edition (Windows) releases by scraping the official minecraft.wiki version history page.
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
Enable with Docker:
```env
REDDIT_CHECK_BEDROCK=true
```
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
Or environment variable:
2026-03-11 23:24:42 +00:00
```bash
2026-03-12 21:45:01 +00:00
set REDDIT_CHECK_BEDROCK=true
python main.py
2026-03-11 23:24:42 +00:00
```
2026-03-12 21:45:01 +00:00
Note: Bedrock versions use the new format (26.x, 27.x, etc.) and are detected from the wiki page. Java Edition will eventually use the same versioning scheme.
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
## Release Types
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
Supported Java Edition release types:
- release - Final Java Edition releases
- snapshot - Development snapshots
- old_beta - Legacy beta versions
- old_alpha - Legacy alpha versions
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
Supported Bedrock Edition types:
- bedrock-windows - Windows Bedrock releases
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
## Database and Persistence
Posted versions are tracked in DB/posted_versions.json. This prevents duplicate posts when the bot restarts.
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
With Docker, data persists in a named volume (minecraft-bot-db).
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
To reset the database and repost all versions:
- Docker: `docker volume rm minecraft-bot-db` then restart
- Manual: Delete DB/posted_versions.json
## Logs
Docker logs:
2026-03-11 23:24:42 +00:00
```bash
2026-03-12 21:45:01 +00:00
docker-compose logs -f
2026-03-11 23:24:42 +00:00
```
2026-03-12 21:45:01 +00:00
Watch for status messages with [BOT], [CHAT], [BEDROCK_CHECKER] prefixes.
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
## Files Overview
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
- main.py - Bot orchestration and update checking
- config.py - Configuration loader
- minecraft_checker.py - Java Edition version checker
- bedrock_checker.py - Bedrock Edition version checker via wiki scraping
- wiki_config.py - Wiki page configuration manager
- update_checker.py - Bot update notifications
- requirements.txt - Python dependencies
- Dockerfile - Container image definition
- docker-compose.yml - Docker Compose configuration
- DB/ - Version tracking database (auto-created)
2026-03-11 23:24:42 +00:00
# Check every 10 minutes (for testing)
CHECK_INTERVAL = 600
```
### 5. Run the Bot
```bash
python main.py
```
You should see output like:
```
[BOT] Starting Minecraft Update Bot...
[BOT] ✓ Successfully connected to Reddit
[BOT] Started update checker (checking every 3600 seconds)
[BOT] ✓ Bot is running
```
## Automatic Update Notifications
The bot includes an update checker that periodically polls for new versions and notifies your subreddit's modteam via modmail when updates are available.
**How it works:**
- Checks `https://updts.slfhstd.uk` every hour for new versions
- Sends modmail to your subreddit's modteam if an update is found
- Limits notifications to once per 24 hours to avoid spam
- No configuration needed - it runs automatically!
**What you'll see:**
```
[UPDATE_CHECKER] Started for MinecraftUpdateBot v1.0
[UPDATE_CHECKER] Update found: 1.0 -> 1.1
[UPDATE_CHECKER] Sent update notification to r/your_subreddit
```
The modteam will receive a message with the new version number and changelog link.
## How It Works
1. **Initialization:** Bot connects to Reddit and loads posted versions from `DB/posted_versions.json`
2. **Check Loop:** Every CHECK_INTERVAL seconds, it:
- Fetches the latest Minecraft versions from Mojang's launcher manifest
- Checks if any are new (not in `DB/posted_versions.json`)
- Posts to subreddit if new versions found
- Saves the posted version IDs
3. **Background:** Runs in background thread, checking continuously
## Database
Posted versions are stored in `DB/posted_versions.json`:
```json
{
"posted": [
"1.20.1",
"1.21",
"1.21.1"
]
}
```
To reset (post all new versions again), delete or clear this file.
## Troubleshooting
### Connection Issues
- Check your credentials in `config.py` or environment variables
- Verify your Reddit app is configured correctly
- Make sure your Reddit account can post to the subreddit
### "No New Releases"
- The bot only posts once per version
- Check `DB/posted_versions.json` to see what's been posted
- Delete a version from the file to repost it
### Test with Snapshots
Change `RELEASE_TYPES = ["snapshot"]` and `CHECK_INTERVAL = 60` to test quickly.
## Files
- `main.py` - Main bot script
- `config.py` - Configuration
- `minecraft_checker.py` - Fetches version data from Mojang
- `test_setup.py` - Validates your setup
- `Dockerfile` - Docker image definition
- `docker-compose.yml` - Docker Compose configuration
- `DB/` - Database folder (created automatically)
- `requirements.txt` - Python dependencies
## License
MIT