Skip to main content

slimbots

Shared plumbing for slim-m bot templates in this repo.

This is not a typed model of slim-m's API. There is no Channel class, no Message object, no cache, no event hierarchy - the kind of thing a discord.js-shaped SDK would give you for a few hundred endpoints. slim-m's entire bot surface is: log in with a token, call REST, hold one websocket, track a per-scope seq. That is what this package covers:

  • authentication (Authorization: Bearer, a real User-Agent, GET /me)
  • a REST helper, Client.call, for any route a template needs
  • an idempotent send that keeps the message id fixed across a retry, and retries only a genuinely uncertain failure - a network error, a 5xx, or a 429 - never a rejected 4xx
  • the websocket connect and hello handshake (Connection)
  • the reconnect loop with exponential backoff, and treating a 401 as terminal rather than retryable (run_forever)
  • a seq cursor in sqlite and the /sync catch-up call (cursor)
  • refusing to carry a token over plain ws:// to anything but a loopback address (socket_url)

It deliberately does not give you a typed route client, a cache, or an event-object hierarchy. See docs/bots/building-bots.md in slim-m for the protocol this wraps, and bot-ping/ in this repo for the same protocol written out with nothing hidden - it stays free of this package on purpose, so there is always one template that shows the whole thing in one file.

Hand-written, not generated

slim-m's wire contract is schema/openapi.yaml, and crates/slimm-server/tests/openapi_contract.rs already fails CI on drift, so a generated client would stay honest automatically. This package is hand-written anyway. What it wraps is not route-shaped: auth, a socket, and a retry policy, not a set of typed request/response pairs. A generator produces that badly, and slim-m already prefers hand-written DTOs and models on both the server and the client for the same reason. If somebody wants a fully typed route client later, generating one from openapi.yaml is a reasonable project - it just is not this one.

Installing

The distribution is named slim-m on PyPI; the import stays slimbots.

pip install slim-m

To run against unreleased changes, install from git instead:

pip install "slim-m @ git+https://github.com/NC1107/slim-bots.git@main#subdirectory=slimbots"

Each template's requirements.txt pins one of those two lines.

Releasing

.github/workflows/publish.yml builds and uploads on a published GitHub release, using PyPI trusted publishing - it exchanges the workflow's own OIDC identity for an upload token, so there is no API token stored in this repo. The publisher on PyPI must name this repository, publish.yml, and the pypi environment, or the exchange is refused.

Bump version in pyproject.toml, then publish a release.

Tests

pip install -e ".[dev]"
pytest

Covers the retry policy (which errors retry, which do not, and that the message id and content never change across a retry), the reconnect loop's backoff and its terminal handling of a 401, and socket_url's loopback-only refusal of plaintext ws://.

Release files for slim-m 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slim-m 0.1.0
File Size Uploaded
slim_m-0.1.0.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for slim-m 0.1.0
File Interpreter ABI Platform
slim_m-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.6 kB

Release files / slim_m-0.1.0.tar.gz

Download URL slim_m-0.1.0.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ef4d71aae4c6c85e37ffc493116d5f9cca3d6430533a6f45a7851d2ae5a76b0f
BLAKE2b-256 checksum
How to use checksums
90dcfe751109d1e0e36368b63d1903478643e990471914a32e16b47b0d34322b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.

Transparency log

Release files / slim_m-0.1.0-py3-none-any.whl

Download URL slim_m-0.1.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce6aba1c7516898ca716ef68e4457c8582e25457fa96718cbd98a1b1e72045d0
BLAKE2b-256 checksum
How to use checksums
8b467049bc8d5cce99dac463a3f014bc5ed106c3eed890e918452acca41de136
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page