{"id":51537625,"url":"https://github.com/halfguru/ogamebot","last_synced_at":"2026-07-09T10:01:47.557Z","repository":{"id":355525601,"uuid":"177689122","full_name":"halfguru/ogamebot","owner":"halfguru","description":"Open-source OGame automation bot for OGameX","archived":false,"fork":false,"pushed_at":"2026-05-04T04:21:53.000Z","size":823,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-05-04T04:27:07.556Z","etag":null,"topics":["bot","go","ogame","ogamex","solidjs"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/halfguru.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":"AGENTS.md","dco":null,"cla":null}},"created_at":"2019-03-26T01:01:27.000Z","updated_at":"2026-05-04T04:21:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/halfguru/ogamebot","commit_stats":null,"previous_names":["halfguru/ogamebot"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/halfguru/ogamebot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfguru%2Fogamebot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfguru%2Fogamebot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfguru%2Fogamebot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfguru%2Fogamebot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halfguru","download_url":"https://codeload.github.com/halfguru/ogamebot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfguru%2Fogamebot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35295106,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-09T02:00:07.329Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["bot","go","ogame","ogamex","solidjs"],"created_at":"2026-07-09T10:01:46.459Z","updated_at":"2026-07-09T10:01:47.547Z","avatar_url":"https://github.com/halfguru.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OGameX Bot\n\n[![Go Version](https://img.shields.io/badge/Go-1.22+-00ADD8?logo=go)](https://go.dev/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![Dashboard](https://img.shields.io/badge/Dashboard-SolidJS-4F88C7?logo=solid)](https://solidjs.com/)\n[![Database](https://img.shields.io/badge/Database-SQLite-003B57?logo=sqlite)](https://sqlite.org/)\n\nOpen-source OGame automation bot targeting [OGameX](https://github.com/lanedirt/OGameX) — an open-source OGame clone. Handles fleet safety, auto-building, auto-farming, and provides a web dashboard for monitoring. Runs as a single Go binary on Windows.\n\n## Features\n\n- **Fleet Safety** — Detects incoming attacks and auto-saves your fleet with phalanx-safe deploy + recall\n- **Auto-Build** — ROI-based building upgrades across all planets, respects max-level caps\n- **Auto-Farm** — Scans galaxy for inactive players, spies them, attacks when profitable\n- **Web Dashboard** — Real-time empire overview with WebSocket updates, fleet movements, build/activity logs\n- **Anti-Detection** — Randomized request intervals, jitter on all actions, configurable rate limiting\n- **Zero-Ops** — SQLite database, single Go binary, no Docker needed\n\n## Quick Start\n\n### Prerequisites\n\n- [Go 1.22+](https://go.dev/dl/)\n- An OGameX account (e.g., at [main.ogamex.dev](https://main.ogamex.dev))\n\n### 1. Configure\n\n```bash\ncp config.example.yaml config.yaml\n```\n\nEdit `config.yaml` with your OGameX credentials and enable features:\n\n```yaml\nogamex:\n  url: \"https://main.ogamex.dev\"\n  email: \"your@email.com\"\n  password: \"your_password\"\n\nfeatures:\n  defender:\n    enabled: true\n    pollIntervalMs: 30000\n    recallEnabled: true\n  autoBuild:\n    enabled: true\n    pollIntervalMs: 120000\n  autoFarm:\n    enabled: true\n    pollIntervalMs: 300000\n```\n\nSecrets can be loaded from environment variables via `${ENV_VAR}` interpolation:\n\n```bash\nexport OGAMEX_EMAIL=\"your@email.com\"\nexport OGAMEX_PASSWORD=\"your_password\"\n```\n\n### 2. Run\n\n```bash\ngo run ./cmd/bot\n```\n\n### 3. Monitor\n\nOpen http://localhost:3000 for the web dashboard.\n\n### 4. Build Binary\n\n```bash\ngo build -o bot.exe ./cmd/bot\n./bot.exe\n```\n\n## Architecture\n\n```mermaid\ngraph LR\n    subgraph Bot[Bot - Go]\n        Client[OGameX Client\u003cbr/\u003eHTTP + CSRF]\n        subgraph Workers\n            Defender\n            Builder\n            Farmer\n        end\n        SQLite[(SQLite\u003cbr/\u003estate)]\n    end\n\n    Dashboard[Dashboard\u003cbr/\u003eSolidJS]\n\n    Workers --\u003e Client\n    Client --\u003e SQLite\n    Workers -- REST + WS --\u003e Dashboard\n```\n\n- **OGameX Client** — Go HTTP client with Laravel session auth, CSRF token management, HTML/JSON parsing via goquery\n- **Workers** — Defender (fleet-save), Builder (ROI upgrades), Farmer (galaxy scan + attack)\n- **Dashboard** — SolidJS SPA with real-time WebSocket updates\n\n## Project Structure\n\n```\ncmd/bot/main.go              Entrypoint\ninternal/\n  config/                    YAML config loader with env interpolation\n  constants/                 OGame building/ship/mission IDs\n  model/                     Domain types\n  ogamex/                    OGameX HTTP client (session auth + CSRF)\n    client.go                Client struct + interface satisfaction\n    session.go               Login/Logout with CSRF extraction\n    transport.go             HTTP helpers (doGet, doPost, doAJAX)\n    parser.go                HTML/JSON parsing (goquery)\n    planets.go               Planet/resource/building queries\n    fleet.go                 Fleet event queries\n    fleet_dispatch.go        SendFleet + CancelFleet\n    build.go                 BuildBuilding\n    galaxy.go                Galaxy scan\n    espionage.go             Espionage reports\n    global.go                Research, constructions, server info\n  state/                     SQLite database + game state cache\n  defender/                  Fleet safety worker + escape route calculator\n  builder/                   Auto-build worker + ROI calculator\n  farmer/                    Auto-farm worker (scan/spy/attack)\n  colonizer/                 Auto-colonize worker (galaxy scan + dispatch)\n  dashboard/                 REST API + WebSocket hub\npackages/\n  dashboard/                 SolidJS web frontend\n```\n\n## How It Works\n\n### State Manager\n\nThe state manager is the central cache. Every 60 seconds it:\n\n1. Fetches planet list from OGameX\n2. For each planet, fetches resources, buildings, facilities, and planet details (fields, temperature)\n3. Fetches global data: research levels, fleet movements, fleet slots, server speed\n4. Writes everything to SQLite\n\nAll workers read from this cached state instead of hitting OGameX directly. Workers can force a refresh before critical actions (e.g., builder fetches live resources before spending).\n\n### Defender (Fleet Safety)\n\nThe defender protects your fleet from incoming attacks:\n\n1. **Detect** — Polls for hostile fleet events (mission type 1 = attack). If any attack is arriving within the safety margin (default 2 minutes), the endangered planet is flagged.\n2. **Save** — Loads all ships and resources from the endangered planet, calculates a safe deployment destination (own planet, different coords), and sends the fleet on a deploy mission.\n3. **Recall** — After the attack passes, the defender recalls the deployed fleet so it returns home. Deploy-with-recall is phalanx-safe (the recall is invisible to sensor phalanx scans).\n4. **Random delay** — Adds a random reaction delay (30-120s) to avoid bot-like instant responses.\n\nAll fleet-save events are tracked in the `fleet_save_events` SQLite table.\n\n### Builder (Auto-Build)\n\nThe builder upgrades buildings and research using a tiered priority system:\n\n1. **Energy** — If any planet has negative energy, builds Solar Plant or Fusion Reactor first\n2. **Mines** — Calculates ROI score for Metal Mine, Crystal Mine, Deuterium Synthesizer upgrades on every planet. ROI = production gain / resource cost. Picks the highest-ROI upgrade across all planets.\n3. **Infrastructure** — Builds in fixed order: Research Lab → Robotics Factory → Shipyard → Nanite Factory (skips already-maxed or prerequisites-not-met)\n4. **Research** — Starts the next research from a configurable priority list on the planet with the highest-level Research Lab\n5. **Storage** — Builds storage when a resource exceeds 80% capacity\n\nBefore executing any build, the builder fetches **live resources** from OGameX (not cached) to prevent double-spending. A `spent` map tracks resources committed in the same poll cycle across multiple tiers.\n\nMax level caps are configurable globally and per-planet via `maxLevels` and `planetOverrides`.\n\n### Farmer (Auto-Farm)\n\nThe farmer finds and attacks inactive players for resources:\n\n1. **Scan** — Scans configured galaxy ranges for inactive players\n2. **Spy** — Sends espionage probes to inactive targets\n3. **Evaluate** — Parses espionage reports for total lootable resources. Attacks only if profit exceeds `minProfitThreshold` (default 10,000 metal-equivalent)\n4. **Attack** — Sends small/large cargo ships with the minimum needed capacity\n\nRespects fleet slot limits, skips defended targets when configured, and limits attacks per cycle.\n\n### Colonizer (Auto-Colonize)\n\nThe colonizer expands your empire automatically:\n\n1. **Check** — Compares current planet count against `targetPlanetCount` and the Astrophysics tech limit (max colonies = 1 + Astrophysics level)\n2. **Scan** — Scans systems around your home planet for empty positions\n3. **Score** — Ranks empty positions by preference (positions 4-8 have the most fields, 1-3 and 9-15 have fewer)\n4. **Dispatch** — Finds a planet with a Colony Ship and sends it on a colonize mission (mission 7)\n\nRequires: Colony Ship built on one of your planets (Shipyard 4 + Impulse Drive 3). The builder does not yet auto-build ships.\n\n### OGameX Client\n\nThe client handles all communication with OGameX:\n\n- **Session auth** — Logs in via Laravel Fortify, maintains session cookies\n- **CSRF tokens** — Extracts from `\u003cmeta name=\"csrf-token\"\u003e`, auto-refreshes from `newAjaxToken` in JSON responses\n- **Rate limiting** — Configurable min/max delay between requests (default 2-5 seconds)\n- **Re-auth** — Automatically re-authenticates on 401/session expiry\n- **HTML parsing** — Uses goquery to extract game data from OGameX pages (no JSON API for most game state)\n- **Fleet dispatch** — Two-step: check-target → send-fleet, with CSRF token in both requests\n\n### Dashboard\n\nThe SolidJS dashboard connects to the bot via REST + WebSocket:\n\n- **REST API** — `/api/planets`, `/api/resources`, `/api/buildings`, `/api/research`, `/api/build-events`, `/api/fleet-save-events`, `/api/farm-attacks`, `/api/build-plan`\n- **WebSocket** — `/ws` pushes real-time events: build completions, research starts, fleet-save actions, farm attacks, colonization attempts\n- **Static files** — The dashboard is built into `internal/dashboard/static/` and embedded in the Go binary via `embed.FS`\n\n## Configuration\n\nAll settings live in `config.yaml`. Secrets can use `${ENV_VAR}` interpolation.\n\n| Setting | Default | Description |\n|---------|---------|-------------|\n| `ogamex.url` | — | OGameX server URL (required for OGameX mode) |\n| `ogamex.email` | — | OGameX account email |\n| `ogamex.password` | — | OGameX account password |\n| `features.defender.enabled` | `false` | Enable fleet-save on attack detection |\n| `features.defender.recallEnabled` | `true` | Auto-recall fleet after attack passes |\n| `features.defender.safetyMarginMs` | `120000` | Min time before attack to trigger save |\n| `features.autoBuild.enabled` | `false` | Enable ROI-based building upgrades |\n| `features.autoFarm.enabled` | `false` | Enable inactive player farming |\n| `features.colonizer.enabled` | `false` | Enable auto-colonization |\n| `features.colonizer.targetPlanetCount` | `8` | Total planets to colonize |\n| `features.colonizer.preferPositions` | `[4,5,6,7,8]` | Preferred planet positions (most fields) |\n| `features.colonizer.scanRadius` | `50` | Systems to scan around home planet |\n| `dashboard.enabled` | `true` | Enable web dashboard |\n| `dashboard.port` | `3000` | Dashboard HTTP port |\n\n## Development\n\n### Run tests\n\n```bash\ngo test ./...\n```\n\n### Build dashboard\n\nThe SolidJS dashboard must be built before the Go binary so static files get embedded:\n\n```bash\npnpm install\npnpm --filter @ogame-bot/dashboard build\n```\n\nThis outputs to `internal/dashboard/static/` which the Go binary embeds.\n\n### Build bot\n\n```bash\ngo build -o bot.exe ./cmd/bot\n```\n\n### Dev with hot-reload dashboard\n\n```bash\n# Terminal 1: Go bot\ngo run ./cmd/bot\n\n# Terminal 2: Vite dev server (proxies API/WS to :3000)\npnpm --filter @ogame-bot/dashboard dev\n# Open http://localhost:5173\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalfguru%2Fogamebot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalfguru%2Fogamebot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalfguru%2Fogamebot/lists"}