- Python 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
CI / precommit (pull_request) Successful in 37s
CI / test (3.12) (pull_request) Successful in 1m41s
CI / test (3.13) (pull_request) Successful in 1m41s
CI / test (3.15) (pull_request) Successful in 1m57s
CI / test (3.14) (pull_request) Successful in 2m4s
CI / release (pull_request) Has been skipped
CI / precommit (push) Successful in 39s
CI / test (3.13) (push) Successful in 1m35s
CI / test (3.12) (push) Successful in 1m35s
CI / test (3.15) (push) Successful in 2m30s
CI / test (3.14) (push) Successful in 2m32s
CI / release (push) Has been skipped
|
||
| .forgejo/workflows | ||
| .vscode | ||
| jarvis_core | ||
| tests | ||
| .flake8 | ||
| .gitattributes | ||
| .gitignore | ||
| .pre-commit-config.yaml | ||
| LICENSE | ||
| PRIVACY.md | ||
| pyproject.toml | ||
| README.md | ||
| requirements.precommit.txt | ||
| TERMS.md | ||
| uv.lock | ||
jarvis-core
Core functionality of JARVIS, shared by jarvis-bot and jarvis-tasks.
Versions
jarvis-bot, jarvis-tasks and jarvis-core are released together and share a version number: 3.x of each work with 3.x of the others. A change that needs matching releases of the other two bumps the major version of all three.
Modules
jarvis_core.db
Database connection (connect(), built on Beanie and PyMongo's async client) and the
Beanie document models. Discord IDs are stored as BSON int64.
jarvis_core.db.migrations
One-off migration for databases written by jarvis-core 1.x (see below).
jarvis_core.filters
Ready-made regular expressions for content such as invites, custom emotes, URLs and email addresses
jarvis_core.util.wordfilters
Parsing and matching of server word filters, which are regular expressions typed in by server admins. A pattern that
takes longer than MATCH_TIMEOUT on one message counts as not matching. The rules for which patterns are accepted at
all (length, repeat counts, nesting, flags) are enforced by jarvis-bot and jarvis-webui before a pattern is compiled.
jarvis_core.util.roles
DANGEROUS_PERMISSIONS, the permissions a role must not carry if the bot hands it out, and unassignable_reason().
jarvis-bot and jarvis-webui keep their own copies of the list in step with it.
jarvis_core.log
Pre-configured Rich logger
jarvis_core.util
Quality of life utilities. jarvis_core.util.http provides public_session() and
fetch(), which refuse to connect to non-public addresses; use them for any request
made on behalf of a user.
Command-line tools
Installing jarvis-core adds three commands. Each requires --uri (the MongoDB connection string), and none needs a running bot.
| Command | What it does |
|---|---|
jarvis-migrate |
One-off migration from 1.x data (see below). --dry-run reports without changing anything |
jarvis-settings-cleanup |
Reports duplicate server settings. With --apply it keeps one document of each and moves the rest to the Setting_duplicates collection |
jarvis-stats |
Reports totals from the bot's statistics (--days N, --json). Read-only |
When MongoDB needs a login, put it in the URI, as in the examples below. With the root account the bot's compose stack
creates, add ?authSource=admin.
Development
Requires Python 3.11+ and uv.
uv sync
uv run pytest
Database tests need a real MongoDB and are skipped otherwise. Every collection in the test database is dropped before and after each test, so point it at a scratch database:
export JARVIS_TEST_MONGO_URI="mongodb://user:pass@localhost:27017/?authSource=admin"
export JARVIS_TEST_MONGO_DB="jarvis_test"
uv run pytest
Upgrading from 1.x
jarvis-core 1.x stored Discord IDs as strings, which no query could match. 2.0 stores them as integers, so existing data must be migrated once, before deploying a bot or tasks build that depends on 2.0. Back up the database first.
uv run jarvis-migrate --uri "mongodb://user:pass@host:27017/?authSource=admin" --database jarvis --dry-run
uv run jarvis-migrate --uri "mongodb://user:pass@host:27017/?authSource=admin" --database jarvis
The migration is idempotent. Besides the ID conversion it rewrites the legacy "perma"
ban type, normalizes ban discriminators, and backfills Ban.expires_at for temporary
bans. Locks created before Lock.guild existed keep guild unset.