|
| 1 | +# Secret Lair Drop Monitor |
| 2 | + |
| 3 | +Monitors the [Secret Lair](https://secretlair.wizards.com/us/) store and [Chaos Vault](https://secretlair.wizards.com/us/chaosvault) for new product drops. Sends notifications to a Discord channel via webhook when new items appear. |
| 4 | + |
| 5 | +## What it monitors |
| 6 | + |
| 7 | +- **Main store** (`/us/`) — Featured drops and homepage products |
| 8 | +- **Chaos Vault** (`/us/chaosvault`) — Detects when the vault opens/closes and alerts immediately |
| 9 | +- **Shop All** (`/us/shopall`) — Catches products that may not be on the homepage (optional, enabled by default) |
| 10 | + |
| 11 | +## Features |
| 12 | + |
| 13 | +- Detects new product additions by tracking product IDs |
| 14 | +- Special "CHAOS VAULT IS OPEN" alert when the vault transitions from closed to active |
| 15 | +- Rich Discord embeds with product name, price, and direct link |
| 16 | +- Persists state across restarts (won't re-notify on reboot) |
| 17 | +- First run silently catalogues existing products (no spam on initial deploy) |
| 18 | +- Rate-limit aware for Discord API |
| 19 | + |
| 20 | +## Setup |
| 21 | + |
| 22 | +### 1. Create a Discord Webhook |
| 23 | + |
| 24 | +In your Discord server: **Server Settings > Integrations > Webhooks > New Webhook** |
| 25 | + |
| 26 | +Pick the channel you want alerts in, copy the webhook URL. |
| 27 | + |
| 28 | +### 2. Configure |
| 29 | + |
| 30 | +```bash |
| 31 | +cp .env.example .env |
| 32 | +``` |
| 33 | + |
| 34 | +Edit `.env` and set your webhook URL: |
| 35 | + |
| 36 | +``` |
| 37 | +DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/1234567890/aBcDeFgHiJkLmNoPqRsT |
| 38 | +``` |
| 39 | + |
| 40 | +### 3. Deploy |
| 41 | + |
| 42 | +```bash |
| 43 | +docker compose up -d |
| 44 | +``` |
| 45 | + |
| 46 | +Check logs: |
| 47 | +```bash |
| 48 | +docker compose logs -f |
| 49 | +``` |
| 50 | + |
| 51 | +## Configuration |
| 52 | + |
| 53 | +All config is via environment variables (set in `.env`): |
| 54 | + |
| 55 | +| Variable | Default | Description | |
| 56 | +|---|---|---| |
| 57 | +| `DISCORD_WEBHOOK_URL` | *(required)* | Discord webhook URL | |
| 58 | +| `POLL_INTERVAL_SECONDS` | `180` | Seconds between checks | |
| 59 | +| `MONITOR_SHOP_ALL` | `true` | Also monitor `/us/shopall` | |
| 60 | +| `NOTIFY_ON_START` | `false` | Notify for existing products on first run | |
| 61 | +| `LOG_LEVEL` | `INFO` | Log verbosity | |
| 62 | + |
| 63 | +## How It Works |
| 64 | + |
| 65 | +1. On startup, fetches all monitored pages and parses product links from the HTML |
| 66 | +2. Product IDs (the numeric ID in `/us/product/1249999`) are the unique key |
| 67 | +3. First run stores all current products silently (no notification flood) |
| 68 | +4. Subsequent checks compare against known state — new IDs trigger Discord alerts |
| 69 | +5. The Chaos Vault page is checked for whether it has any product listings. When products appear, a special high-visibility alert fires. |
| 70 | +6. State is written to `state.json` after every cycle |
| 71 | + |
| 72 | +## Troubleshooting |
| 73 | + |
| 74 | +**No notifications on first run** — This is by design. Set `NOTIFY_ON_START=true` if you want alerts for existing products. |
| 75 | + |
| 76 | +**Products not detected** — The scraper looks for `/us/product/{id}` links in the HTML. If Wizards changes their URL structure or moves to fully client-rendered content, the regex patterns may need updating. Check logs at `LOG_LEVEL=DEBUG`. |
| 77 | + |
| 78 | +**Rate limited** — The monitor handles Discord 429 responses automatically. If the site itself rate-limits you, increase `POLL_INTERVAL_SECONDS`. |
| 79 | + |
| 80 | +**State reset** — Delete the `data/` directory to start fresh. The next run will re-catalogue everything. |
0 commit comments