# Installation Guide

## Requirements

- Python 3.9 or newer
- pip (comes with Python)
- A free CurseForge API key

---

## Step 1 — Install Python

Verify Python is installed:

```bash
python3 --version
# Should show: Python 3.9.x or newer
```

If not installed, download from [python.org](https://www.python.org/downloads/).

---

## Step 2 — Install Modpack Version Checker

### Option A: pip (recommended)

```bash
pip install modpack-version-checker
```

### Option B: Install with scheduler support

```bash
pip install "modpack-version-checker[scheduler]"
```

This adds APScheduler for the `modpack-checker schedule` background daemon command.

### Option C: Install from source

```bash
git clone https://git.firefrostgaming.com/firefrost/firefrost-services.git
cd firefrost-services/services/modpack-version-checker
pip install -e ".[scheduler]"
```

---

## Step 3 — Get a CurseForge API Key (free)

1. Go to [console.curseforge.com](https://console.curseforge.com)
2. Log in or create a free account
3. Click **Create API Key**
4. Copy the key

---

## Step 4 — Configure

```bash
modpack-checker config set-key YOUR_API_KEY_HERE
```

The key is stored in `~/.config/modpack-checker/config.json`.

---

## Step 5 (Optional) — Set Up Discord Notifications

1. In your Discord server, go to **Channel Settings → Integrations → Webhooks**
2. Click **New Webhook** and copy the URL
3. Run:

```bash
modpack-checker config set-webhook https://discord.com/api/webhooks/YOUR_WEBHOOK_URL
```

A test message will be sent to confirm it works.

---

## Step 6 — Add Your First Modpack

Find your modpack's CurseForge project ID:
Visit the modpack page on CurseForge and look for the **Project ID** number in the right sidebar (e.g. `238222` for All The Mods 9).

```bash
modpack-checker add 238222    # All The Mods 9
modpack-checker add 361392    # RLCraft
```

---

## Step 7 — Check for Updates

```bash
modpack-checker check
```

---

## Background Scheduler (Optional)

Run continuous checks automatically:

```bash
# Check every 6 hours (default)
modpack-checker schedule

# Check every 12 hours
modpack-checker schedule --hours 12
```

To run as a Linux systemd service, create `/etc/systemd/system/modpack-checker.service`:

```ini
[Unit]
Description=Modpack Version Checker
After=network.target

[Service]
Type=simple
User=YOUR_USERNAME
ExecStart=/usr/local/bin/modpack-checker schedule --hours 6
Restart=on-failure

[Install]
WantedBy=multi-user.target
```

Then:
```bash
sudo systemctl enable --now modpack-checker
```

---

## Uninstall

```bash
pip uninstall modpack-version-checker

# Remove config and database (optional)
rm -rf ~/.config/modpack-checker/
```

---

## Troubleshooting

**`modpack-checker: command not found`**
- Make sure pip's script directory is in your PATH
- Try: `python3 -m modpack_checker.cli`

**`Invalid API key`**
- Double-check the key at [console.curseforge.com](https://console.curseforge.com)
- Ensure there are no extra spaces when setting it

**`Connection failed`**
- Check your internet connection
- CurseForge API may be temporarily down; try again in a few minutes

**`Modpack shows Unknown`**
- Verify the project ID is correct by checking the CurseForge page
- Some older modpacks have no files listed via the API
