initial
This commit is contained in:
@@ -0,0 +1,212 @@
|
||||
# Minecraft Update Bot 🎮
|
||||
|
||||
Automatically detects new Minecraft releases and posts them to a subreddit.
|
||||
|
||||
## Features
|
||||
|
||||
- ✅ Checks Minecraft launcher manifest for new releases
|
||||
- ✅ Posts to Reddit whenever a new version is detected
|
||||
- ✅ Tracks posted versions to avoid duplicates
|
||||
- ✅ Runs continuously with configurable check interval
|
||||
- ✅ Supports multiple release types (releases, snapshots, etc.)
|
||||
- ✅ Docker & Docker Compose ready
|
||||
- ✅ **Customizable post templates via subreddit wiki**
|
||||
- ✅ **Different post formats for different release types**
|
||||
- ✅ **Auto-update notifications** - Gets alerted when new bot versions are available
|
||||
|
||||
## Quick Start - Docker (Recommended)
|
||||
|
||||
```bash
|
||||
# Copy and edit environment file
|
||||
copy .env.example .env
|
||||
# Edit .env with your Reddit credentials
|
||||
|
||||
# Start the bot
|
||||
docker-compose up -d
|
||||
|
||||
# View logs
|
||||
docker-compose logs -f
|
||||
```
|
||||
|
||||
See [DOCKER.md](DOCKER.md) for detailed Docker setup instructions.
|
||||
|
||||
## Customizing Posts with Wiki Configuration
|
||||
|
||||
The bot loads post templates from your subreddit's wiki page `minecraft_update_bot`. This allows you to:
|
||||
- Create different post formats for releases vs. snapshots
|
||||
- Customize titles and bodies without restarting
|
||||
- Support legacy version types with custom messages
|
||||
|
||||
**Quick Setup:**
|
||||
1. Create a wiki page named `minecraft_update_bot` on your subreddit
|
||||
2. Add YAML configuration with your templates (see example below)
|
||||
3. Bot auto-loads every 30 minutes
|
||||
|
||||
**Simple Example:**
|
||||
```yaml
|
||||
release:
|
||||
title: "Minecraft {version} Released!"
|
||||
body: |
|
||||
# Minecraft {version}
|
||||
Available now! Get it at [minecraft.net](https://minecraft.net)
|
||||
**Released:** {release_date}
|
||||
|
||||
snapshot:
|
||||
title: "Minecraft {version} Snapshot"
|
||||
body: |
|
||||
# New Snapshot Available
|
||||
Test {version} before the official release!
|
||||
```
|
||||
|
||||
👉 See [WIKI_CONFIG.md](WIKI_CONFIG.md) for complete setup and examples.
|
||||
|
||||
## Manual Setup
|
||||
|
||||
### 1. Install Dependencies
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### 2. Create Reddit Application
|
||||
|
||||
1. Go to [https://www.reddit.com/prefs/apps](https://www.reddit.com/prefs/apps)
|
||||
2. Click "Create an app" or "Create another app"
|
||||
3. Fill in the form:
|
||||
- **Name:** MinecraftUpdateBot
|
||||
- **App type:** Script
|
||||
- **Redirect URI:** http://localhost:8080
|
||||
4. Copy the credentials
|
||||
|
||||
### 3. Configure the Bot
|
||||
|
||||
Edit `config.py` and fill in your credentials:
|
||||
|
||||
```python
|
||||
REDDIT_CLIENT_ID = "YOUR_CLIENT_ID" # From app page
|
||||
REDDIT_CLIENT_SECRET = "YOUR_CLIENT_SECRET" # From app page
|
||||
REDDIT_USERNAME = "YOUR_USERNAME" # Your Reddit username
|
||||
REDDIT_PASSWORD = "YOUR_PASSWORD" # Your Reddit password
|
||||
SUBREDDIT = "YOUR_SUBREDDIT" # Subreddit to post to
|
||||
```
|
||||
|
||||
Or use environment variables (Docker-friendly):
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
### 4. Customize (Optional)
|
||||
|
||||
In `config.py`:
|
||||
- **RELEASE_TYPES:** Change `["release"]` to include snapshots or other types
|
||||
- Options: `"release"`, `"snapshot"`, `"old_beta"`, `"old_alpha"`
|
||||
- **CHECK_INTERVAL:** How often to check for updates (in seconds)
|
||||
- Default: 3600 (1 hour)
|
||||
- **POST_TEMPLATE:** Customize the post format
|
||||
|
||||
Examples:
|
||||
```python
|
||||
# Check for both releases and snapshots
|
||||
RELEASE_TYPES = ["release", "snapshot"]
|
||||
|
||||
# Check every 30 minutes
|
||||
CHECK_INTERVAL = 1800
|
||||
|
||||
# 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
|
||||
Reference in New Issue
Block a user