No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
zevaryx 0c864d70d2
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
chore: bump version to 3.2.1
2026-11-17 19:16:37 +00:00
.forgejo/workflows ci: publish with a PACKAGE_USER secret, and say so when the secrets are missing 2026-11-05 21:08:41 -07:00
.vscode [feat] Heavy testing of core 2024-03-19 16:21:17 -06:00
jarvis_core fix(roles): match the bot's wider list of permissions self-service roles may not grant 2026-11-17 11:02:45 +00:00
tests fix(roles): match the bot's wider list of permissions self-service roles may not grant 2026-11-17 11:02:45 +00:00
.flake8 v0.18.0, match ipy5 branch of JARVIS 2023-08-27 14:08:30 -06:00
.gitattributes chore: normalise line endings to LF 2026-11-03 10:23:48 -07:00
.gitignore Add database models, configuration management 2022-02-06 21:33:15 -07:00
.pre-commit-config.yaml build(pre-commit): update hooks to their latest releases 2026-11-02 14:00:26 -07:00
LICENSE chore: normalise line endings to LF 2026-11-03 10:23:48 -07:00
PRIVACY.md docs: describe scheduled announcements, the Remind Me and Save Message menus, and moderation recorded from Discord in the privacy policy 2026-11-06 20:26:36 -07:00
pyproject.toml chore: bump version to 3.2.1 2026-11-17 19:16:37 +00:00
README.md docs: document word-filter and role helpers and the command-line tools 2026-11-17 11:54:18 +00:00
requirements.precommit.txt build(pre-commit): update hooks to their latest releases 2026-11-02 14:00:26 -07:00
TERMS.md chore: normalise line endings to LF 2026-11-03 10:23:48 -07:00
uv.lock chore: bump version to 3.2.1 2026-11-17 19:16:37 +00:00

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.