Skip to main content

OSRS Bot Development SDK with game-native structure

Project description

ShadowLib

A Python SDK for Old School RuneScape (OSRS) bot development with an intuitive structure that mirrors the game's interface.

Features

  • Game-Native Structure: Directory layout based on OSRS client interface (world, tabs, interfaces)
  • Type-Safe: Full type hints for better IDE support and fewer runtime errors
  • Well-Tested: Comprehensive test coverage with pytest
  • Clean Code: Enforced coding standards with Ruff and custom naming convention checker
  • Easy to Use: Intuitive API that matches how players think about the game

Installation

From Source

git clone https://github.com/shadowbot/shadowlib.git
cd shadowlib
pip install -e ".[dev]"

For Development

# Install with development dependencies
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

Quick Start

from shadowlib import Client

# Create and connect to the client
client = Client()
client.connect()

# Check connection status
if client.isConnected():
    print("Connected to OSRS client!")

# Your bot logic here...

# Disconnect when done
client.disconnect()

Project Structure

shadowlib/
├── world/              # Game viewport entities (NPCs, objects, players, ground items)
├── tabs/               # Side panel tabs (inventory, equipment, skills, prayers)
├── interfaces/         # Overlay windows (bank, GE, shop, dialogue)
├── navigation/         # Movement systems (walking, teleports, webwalking)
├── interactions/       # Interaction systems (menu, clicking, hovering)
├── input/              # OS-level input (mouse, keyboard)
├── types/              # Type definitions, enums, models
├── utilities/          # Helper functions (timing, calculations, geometry)
├── resources/          # Game data (varps, objects, items, NPCs)
└── _internal/          # Bridge implementation (transport, protocol, cache)

Placement Rules

  1. Visible in the 3D worldworld/
  2. Side-panel tabtabs/
  3. Overlay windowinterfaces/
  4. Pathing/movementnavigation/
  5. Interaction primitivesinteractions/

Development

Code Style

This project uses camelCase for function names (e.g., getFoo(), doSomething()), following the convention:

# ✅ Correct
def getPlayerName():
    pass

def isInventoryFull():
    pass

# ❌ Incorrect
def get_player_name():
    pass

def is_inventory_full():
    pass

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=shadowlib

# Run specific test file
pytest tests/test_client.py

# Run tests matching a pattern
pytest -k "test_client"

Linting and Formatting

# Run Ruff linter
ruff check .

# Auto-fix issues
ruff check --fix .

# Format code
ruff format .

# Check naming conventions
python check_naming.py

Pre-commit Hooks

The project uses pre-commit hooks to ensure code quality:

# Install hooks
pre-commit install

# Run manually
pre-commit run --all-files

Naming Conventions

  • Functions/Methods: camelCase (e.g., getItem, moveToPosition)
  • Classes: PascalCase (e.g., Client, QueryBuilder)
  • Constants: UPPER_CASE (e.g., MAX_HEALTH, DEFAULT_TIMEOUT)
  • Private functions: _camelCase (e.g., _internalHelper)
  • Dunder methods: __method__ (e.g., __init__, __repr__)

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes following the code style
  4. Run tests and linting
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Code Quality Checklist

Before submitting a PR, ensure:

  • All tests pass (pytest)
  • Code follows naming conventions (python check_naming.py)
  • Linting passes (ruff check .)
  • Code is formatted (ruff format .)
  • New features have tests
  • Documentation is updated

Architecture Decision Records (ADRs)

See docs/adr/ for architectural decisions, including:

  • ADR-003: OSRS-Native SDK Structure

License

MIT License - see LICENSE file for details

Acknowledgments

  • Inspired by OSBot, TRiBot, and other OSRS botting frameworks
  • Built with love for the OSRS botting community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shadowlib-2.0.1.tar.gz (138.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shadowlib-2.0.1-py3-none-any.whl (158.3 kB view details)

Uploaded Python 3

File details

Details for the file shadowlib-2.0.1.tar.gz.

File metadata

  • Download URL: shadowlib-2.0.1.tar.gz
  • Upload date:
  • Size: 138.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for shadowlib-2.0.1.tar.gz
Algorithm Hash digest
SHA256 6d6cf22c9794118276f67021245b05695ed30679eb0daec26c558146a682c182
MD5 f77cfb6a2f33d8d7ca0fd275729d5419
BLAKE2b-256 fa7fb4610f8d3466c40824e70613ff4861f4ab2074d981dc7a76b1641e7d4e9b

See more details on using hashes here.

File details

Details for the file shadowlib-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: shadowlib-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 158.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for shadowlib-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6f766b7313491a2a670b7ae5f87297be412941e9d8b035376404586e1cbd49a8
MD5 5224922b77139bbc65d8d5aa1df7d073
BLAKE2b-256 893d4777eb458910501543998adf16ee33c2bd0c620270c202527aa4f71c9273

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page