{"id":35532739,"url":"https://github.com/wasita/magic-garden","last_synced_at":"2026-01-13T21:03:34.847Z","repository":{"id":328268829,"uuid":"1114043196","full_name":"wasita/magic-garden","owner":"wasita","description":"a bot written for the magic garden discord activity game, for auto-purchasing seeds when user is afk","archived":false,"fork":false,"pushed_at":"2026-01-07T15:44:21.000Z","size":2381,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-09T02:02:30.485Z","etag":null,"topics":["automation","bot","magic-garden","magic-garden-discord-game"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wasita.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-10T20:22:49.000Z","updated_at":"2026-01-07T15:44:25.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/wasita/magic-garden","commit_stats":null,"previous_names":["wasita/magic-garden"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/wasita/magic-garden","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wasita%2Fmagic-garden","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wasita%2Fmagic-garden/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wasita%2Fmagic-garden/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wasita%2Fmagic-garden/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wasita","download_url":"https://codeload.github.com/wasita/magic-garden/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wasita%2Fmagic-garden/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28399508,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","bot","magic-garden","magic-garden-discord-game"],"created_at":"2026-01-04T02:20:15.345Z","updated_at":"2026-01-13T21:03:34.842Z","avatar_url":"https://github.com/wasita.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Magic Garden Auto-Buyer Bot\n\nAutomatically monitors and purchases seeds and eggs in the Magic Garden Discord game.\n\n## Features\n\n- **OCR-based detection** - Finds items by reading text (no fragile image templates)\n- **Smart shop navigation** - Teleports to shop, scrolls through all pages, loops continuously\n- **Green button detection** - Uses color detection to find buy buttons reliably\n- **Fuzzy text matching** - Handles OCR errors like \"arrot\" → \"Carrot\"\n- **Stock verification** - Only clicks items that show \"STOCK\" (ignores popups)\n- **Configurable targets** - Choose which seeds/eggs to buy\n- **Shop mode selection** - Scan seed shop, egg shop, or both\n- **Cross-platform** - Works on macOS and Windows\n- **GUI and headless modes** - Run with interface or AFK in terminal\n\n## Setup\n\n### Prerequisites\n\n- [uv](https://docs.astral.sh/uv/) (recommended) or Python 3.11+\n- Magic Garden game (Discord activity)\n- **Windows only:** Tesseract OCR (see below)\n- **Windows only:** pydirectinput (for game input - installed automatically)\n\n### macOS Installation\n\n```bash\n# Install uv\ncurl -LsSf https://astral.sh/uv/install.sh | sh\n\n# Clone and setup\ngit clone \u003cyour-repo-url\u003e\ncd magic-garden\nuv sync\n```\n\n### Windows Installation\n\n#### Step 1: Install Tesseract OCR\n\n1. Download the installer from: https://github.com/UB-Mannheim/tesseract/wiki\n   - Get the latest 64-bit version (e.g., `tesseract-ocr-w64-setup-5.3.3.exe`)\n\n2. Run the installer:\n   - Install to default path: `C:\\Program Files\\Tesseract-OCR`\n   - **Important:** Check \"Add to PATH\" during installation\n\n3. Verify installation:\n   ```cmd\n   tesseract --version\n   ```\n\n4. If Tesseract is not in PATH, you'll need to set it manually. Add this to the top of `main.py`:\n   ```python\n   import pytesseract\n   pytesseract.pytesseract.tesseract_cmd = r'C:\\Program Files\\Tesseract-OCR\\tesseract.exe'\n   ```\n\n#### Step 2: Install Python Dependencies\n\n**Using uv (recommended):**\n```powershell\n# Install uv\npowershell -ExecutionPolicy ByPass -c \"irm https://astral.sh/uv/install.ps1 | iex\"\n\n# Clone and setup\ngit clone \u003cyour-repo-url\u003e\ncd magic-garden\nuv sync\n```\n\n**Using pip:**\n```cmd\ncd magic-garden\npython -m venv .venv\n.venv\\Scripts\\activate\npip install -r requirements-windows.txt\n```\n\n## Configuration\n\nBefore running, set up your game region and preferences in `config.json`:\n\n### Setting the Game Region\n\nRun the region capture tool:\n```bash\nuv run python main.py --set-region\n```\n\nFollow the prompts to click the top-left and bottom-right corners of your game window.\n\n### Config Options\n\nEdit `config.json`:\n\n```json\n{\n    \"scan_interval\": 1.0,\n    \"click_delay\": 0.3,\n    \"confidence_threshold\": 0.6,\n    \"shop_mode\": \"seed\",\n    \"monitor_region\": [799, 479, 882, 766],\n    \"ocr_targets\": [\n        \"Mythical Egg\",\n        \"Bamboo Seed\",\n        \"Sunflower Seed\",\n        \"Starweaver Pod\",\n        \"Dawnbinder Pod\",\n        \"Moonbinder Pod\"\n    ],\n    \"use_ocr\": true,\n    \"startup_delay\": 3\n}\n```\n\n| Setting | Description | Default |\n|---------|-------------|---------|\n| `scan_interval` | Seconds between shop cycles | 1.0 |\n| `click_delay` | Delay after each buy click (seconds) | 0.3 |\n| `confidence_threshold` | Template match sensitivity (0-1) | 0.6 |\n| `shop_mode` | Which shops to scan: `\"seed\"`, `\"egg\"`, or `\"both\"` | `\"seed\"` |\n| `monitor_region` | Game window region `[x, y, width, height]` | - |\n| `ocr_targets` | List of item names to buy | - |\n| `use_ocr` | Use OCR text detection (recommended) | true |\n| `startup_delay` | Seconds to wait before starting (focus game) | 3 |\n\n## Usage\n\n### Headless Mode (Recommended for AFK)\n\n```bash\nuv run python main.py --headless\n```\n\nThe bot will:\n1. Wait 3 seconds (focus your game window)\n2. Press Shift+1 to teleport to shop\n3. Press Space to open seed shop\n4. Scroll through all pages, buying configured items\n5. Loop back to step 2\n\nPress `Ctrl+C` to stop.\n\n### GUI Mode\n\n```bash\nuv run python main.py\n```\n\nControls:\n- **F6**: Start/Pause\n- **F7**: Stop\n- **Mouse to corner**: Emergency stop (pyautogui failsafe)\n\n### Other Commands\n\n```bash\n# Set game region interactively\nuv run python main.py --set-region\n```\n\n## Building Standalone Executable\n\nYou can package the bot as a standalone `.exe` that users can run without installing Python.\n\n### Prerequisites for Building\n\n1. Install PyInstaller:\n   ```bash\n   pip install pyinstaller\n   ```\n\n2. **Windows:** Ensure Tesseract is installed at `C:\\Program Files\\Tesseract-OCR`\n   - The build will automatically bundle Tesseract into the executable\n\n### Build\n\n```bash\npyinstaller magic-garden.spec\n```\n\nThe executable will be in the `dist/` folder as `MagicGardenBot.exe`.\n\n### What Gets Bundled\n\n- Python runtime\n- All dependencies (OpenCV, pytesseract, EasyOCR, PyTorch)\n- Tesseract OCR (Windows) - no separate install needed\n- Default config and templates\n\n**Notes:**\n- Executable size is large (~500MB+) due to EasyOCR/PyTorch\n- First run may be slow as EasyOCR downloads language models\n- Users just double-click to run - no Python or Tesseract install required\n\n### Creating a Release\n\nGitHub Actions automatically builds and publishes releases when you push a version tag:\n\n```bash\n# Tag your commit with a version\ngit tag v1.0.0\n\n# Push the tag to trigger the build\ngit push origin v1.0.0\n```\n\nThis will:\n1. Build `MagicGardenBot.exe` with all dependencies bundled\n2. Create a GitHub Release with the executable attached\n\nUsers can download the `.exe` directly from the [Releases](../../releases) page.\n\n## How It Works\n\n1. **Shop Navigation** - Teleports to shop (Shift+1), opens seed/egg shop (Space)\n2. **Screen Capture** - Captures the game region defined in config\n3. **OCR Detection** - Uses pytesseract to read text on screen\n4. **Stock Filter** - Only considers items with \"STOCK\" text on the same line\n5. **Fuzzy Matching** - Matches partial text to handle OCR errors (e.g., \"amboo\" → \"Bamboo\")\n6. **Click Item** - Clicks on the item to open the buy accordion\n7. **Green Button Detection** - Finds buy buttons using HSV color matching\n8. **Buy Loop** - Clicks buy button repeatedly until it turns grey (sold out)\n9. **Re-scan Page** - After buying, re-scans the page for remaining items (handles layout shifts)\n10. **Scroll \u0026 Repeat** - Scrolls down, continues scanning until end of shop, then loops\n\n## Debugging\n\nWhen debug mode is enabled, the bot saves diagnostic images to the `debug/` folder:\n- `debug/screenshot.png` - Current screen capture\n- `debug/green_mask.png` - HSV color mask showing detected green regions\n- `debug/buttons_annotated.png` - Screenshot with detected buttons highlighted\n\nThese help diagnose issues with button detection or region setup.\n\n## Troubleshooting\n\n**Bot not detecting items:**\n- Run `--set-region` to recapture game window bounds\n- Check that `ocr_targets` in config.json matches exact item names\n- Check debug output for OCR results and matched text\n\n**Green buy button not detected:**\n- Check `debug/green_mask.png` to see what green regions are detected\n- The button must be wide (aspect ratio \u003e 1.3) to avoid matching seed icons\n- Ensure the game region covers the buy button area\n\n**Clicking wrong things:**\n- The bot filters for items with \"STOCK\" on the same line - popups shouldn't trigger\n- If false positives persist, check the debug output for what text is being matched\n\n**Tesseract not found (Windows):**\n- Ensure Tesseract is installed and in PATH\n- Or add the path manually in code (see Windows installation above)\n\n**macOS permissions:**\n- Grant accessibility permissions: System Settings \u003e Privacy \u0026 Security \u003e Accessibility\n- Add Terminal (or your IDE) to the allowed apps\n\n**Bot clicking but not buying:**\n- Check `debug/buttons_annotated.png` to see if button is detected\n- Increase `click_delay` in config.json if clicks are too fast\n- Ensure the game window is focused and not obstructed\n\n## Disclaimer\n\nUse at your own risk. Automation may violate the game's terms of service.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwasita%2Fmagic-garden","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwasita%2Fmagic-garden","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwasita%2Fmagic-garden/lists"}