diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml new file mode 100644 index 0000000..b5e8cfd --- /dev/null +++ b/.github/workflows/claude-code-review.yml @@ -0,0 +1,44 @@ +name: Claude Code Review + +on: + pull_request: + types: [opened, synchronize, ready_for_review, reopened] + # Optional: Only run on specific file changes + # paths: + # - "src/**/*.ts" + # - "src/**/*.tsx" + # - "src/**/*.js" + # - "src/**/*.jsx" + +jobs: + claude-review: + # Optional: Filter by PR author + # if: | + # github.event.pull_request.user.login == 'external-contributor' || + # github.event.pull_request.user.login == 'new-developer' || + # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' + + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + issues: read + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Run Claude Code Review + id: claude-review + uses: anthropics/claude-code-action@v1 + with: + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + plugin_marketplaces: 'https://github.com/anthropics/claude-code.git' + plugins: 'code-review@claude-code-plugins' + prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}' + # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md + # or https://code.claude.com/docs/en/cli-reference for available options + diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml new file mode 100644 index 0000000..d300267 --- /dev/null +++ b/.github/workflows/claude.yml @@ -0,0 +1,50 @@ +name: Claude Code + +on: + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] + issues: + types: [opened, assigned] + pull_request_review: + types: [submitted] + +jobs: + claude: + if: | + (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || + (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + issues: read + id-token: write + actions: read # Required for Claude to read CI results on PRs + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Run Claude Code + id: claude + uses: anthropics/claude-code-action@v1 + with: + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + + # This is an optional setting that allows Claude to read CI results on PRs + additional_permissions: | + actions: read + + # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it. + # prompt: 'Update the pull request description to include a summary of changes.' + + # Optional: Add claude_args to customize behavior and configuration + # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md + # or https://code.claude.com/docs/en/cli-reference for available options + # claude_args: '--allowed-tools Bash(gh pr:*)' + diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..1026a58 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,53 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Overview + +`rbrapi` is an unofficial Python client library for the Rocket Bot Royale game API (built on Nakama backend at `https://dev-nakama.winterpixel.io/v2`). Version `0.7`, requires Python `>=3.8`, single dependency: `requests`. + +## Commands + +**Lint/format check (CI uses this):** +```bash +ruff format --check rbrapi +``` + +**Auto-format:** +```bash +ruff format rbrapi +``` + +**Build for distribution:** +```bash +python -m pip install build +python -m build +``` + +There is no test suite configured. + +## Architecture + +The library exposes a single `RocketBotRoyale` class (`rbrapi/__init__.py`) that authenticates on instantiation and wraps all API calls. + +**Module responsibilities:** +- `rbrapi/__init__.py` — Main client class. Defines `BASE_URL`, `BASE_HEADERS` (with hardcoded game credentials), and `CLIENT_VERSION = "9999999999"` (intentional, bypasses version checks). All public methods map to Nakama REST or RPC endpoints. +- `rbrapi/session.py` — Thread-local `requests.Session` cache with a 600-second TTL. `make_request()` handles POST/GET, JSON/form-data payloads, and raises custom exceptions on non-2xx responses. +- `rbrapi/types.py` — Response types. `APIResponse` base class provides JSON serialization. Typed response objects (`AuthenticateResponse`, `AccountResponse`, `LootBoxResponses`, etc.) and `TypedDict` definitions for nested structures (`UserStats`, `UserMetadata`, `Wallet`, etc.). +- `rbrapi/errors.py` — Six custom exceptions, one per API operation that can fail (`AuthenticationError`, `SignUpError`, `CollectTimedBonusError`, `FriendRequestError`, `LootBoxError`, `UnknownUserError`). + +**Request flow:** +``` +RocketBotRoyale(email, password) + └─> authenticate() ──> make_request() ──> thread-local requests.Session (TTL 600s) + +client.buy_crate() / account() / etc. + └─> make_request() ──> Response parsed into types.py objects +``` + +**RPC calls** (e.g., `collect_timed_bonus`, `send_friend_request`, `buy_crate`) POST to `/rpc/` as `application/x-www-form-urlencoded` with a JSON-encoded body string as the form value. + +## CI/CD + +- **`ruff.yml`**: Runs `ruff format --check rbrapi` on every push/PR. +- **`pypi.yml`**: Publishes to PyPI automatically when `rbrapi/__init__.py` changes on `main`. diff --git a/pyproject.toml b/pyproject.toml index 0e34285..f06daa6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] -name = "rbrapi" -version = "0.7" +name = "rbr-api-fork" +version = "0.7.1" authors = [ { name="VWH", email="vwhe@proton.me" }, @@ -29,11 +29,11 @@ dependencies = [ ] [project.urls] -Homepage = "https://github.com/rocket-bot-royale/api" -Issues = "https://github.com/rocket-bot-royale/api/issues" +Homepage = "https://github.com/arenaslucas/rbr-api" +Issues = "https://github.com/arenaslucas/rbr-api/issues" [tool.setuptools] include-package-data = false [tool.setuptools.packages.find] -exclude = ["examples"] \ No newline at end of file +exclude = ["examples"] diff --git a/rbrapi/__init__.py b/rbrapi/__init__.py index ac2b2f8..187d19e 100644 --- a/rbrapi/__init__.py +++ b/rbrapi/__init__.py @@ -1,6 +1,6 @@ from __future__ import annotations -__version__ = "0.7" +__version__ = "0.7.1" from json import loads from typing import Optional, Self diff --git a/rbrapi/types.py b/rbrapi/types.py index ebad76f..cd269af 100644 --- a/rbrapi/types.py +++ b/rbrapi/types.py @@ -161,6 +161,7 @@ class AccountResponse(APIResponse): wallet: Wallet email: str devices: list[dict[str, str]] + custom_id: str | None # Optional field, new in API def __init__( self: Self, @@ -169,9 +170,21 @@ def __init__( wallet: str, email: str, devices: list[dict[str, str]], + custom_id: str | None = None, ) -> None: - user["metadata"] = loads(user["metadata"]) - super().__init__(user=user, wallet=loads(wallet), email=email, devices=devices) + # Safely load user["metadata"] and wallet JSON + if isinstance(user.get("metadata"), str): + user["metadata"] = loads(user["metadata"]) + if isinstance(wallet, str): + wallet = loads(wallet) + + super().__init__( + user=user, + wallet=wallet, + email=email, + devices=devices, + custom_id=custom_id, # include new key + ) class LootBoxResponses(APIResponse):