- Python 78.7%
- HTML 17.4%
- CSS 2.6%
- JavaScript 1.2%
- Dockerfile 0.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
CI / precommit (pull_request) Successful in 33s
CI / test (3.13) (pull_request) Successful in 12m14s
CI / test (3.12) (pull_request) Successful in 12m20s
CI / test (3.15) (pull_request) Successful in 19m55s
CI / test (3.14) (pull_request) Successful in 20m2s
CI / image (pull_request) Has been skipped
CI / precommit (push) Successful in 27s
CI / test (3.12) (push) Successful in 9m2s
CI / test (3.15) (push) Successful in 8m45s
CI / test (3.13) (push) Successful in 14m35s
CI / test (3.14) (push) Successful in 14m31s
CI / image (push) Successful in 25s
|
||
| .forgejo/workflows | ||
| docs | ||
| tests | ||
| webui | ||
| .dockerignore | ||
| .flake8 | ||
| .gitattributes | ||
| .gitignore | ||
| .pre-commit-config.yaml | ||
| compose.example.yaml | ||
| Dockerfile | ||
| LICENSE | ||
| PRIVACY.md | ||
| pyproject.toml | ||
| README.md | ||
| run.py | ||
| sample.env | ||
| TERMS.md | ||
| uv.lock | ||
JARVIS web UI
The dashboard for jarvis-bot: sign in with Discord, manage your reminders and data, and manage the servers you look after. It runs alongside the bot and jarvis-tasks against the same MongoDB.
The design and roadmap are in docs/PLAN.md.
Versions
jarvis-bot, jarvis-tasks, jarvis-core and jarvis-webui share a version number: 3.x of each work with 3.x of the others.
What it does today
| Public | Landing page with the invite link, features, privacy policy and terms (rendered from PRIVACY.md / TERMS.md) |
| Sign in | Discord OAuth2 (identify guilds); the access token is dropped right after sign-in |
| You | Servers you share with the bot; set, edit and delete reminders (DM delivery) and your default timezone; appeal a ban where the server allows it; download or delete your data |
| Server managers | Settings (log channels, reports, verified roles, invites, mass-mention, notifications, ignored channels, lockdown exclusions) with a download of the whole configuration as JSON, escalation rules, saved reasons, moderator activity (who took which actions), and an audit trail of what was changed on the website |
| Moderators | Member search and a page per member; action log; Cases (open, note, close, reopen, download as CSV); Appeals (read; deciding needs Ban Members; approving unbans through the bot); warn, kick, mute, unmute, ban and unban from Actions, carried out by the bot; the server's own Statistics; the list of saved reasons; scheduled Announcements (see what is waiting or was posted, and cancel; created in Discord with /announce, needs Manage Messages) |
| Everyone in a server | Tags: browse, search, create, and edit your own (or anyone's with Manage Messages) | | Message managers | Keyword Filters with a regex tester; Automation: autopurge, autoreact, role-ping protection, pinboards | | Channel managers | Tools: purge (with filters), lock and unlock, lockdown (typed confirmation, never automatic), post role menus | | Role managers | Roles: rolegiver groups (pick-one, required role, up to 15 roles) with posted menus kept up to date by the bot; temporary roles (read-only) |
Slow pages (member pages, action log, cases, audit trail, statistics) answer at once with a "Loading data..." placeholder and fill in when their data is ready; see webui/lazy.py. They need JavaScript.
Actions are queued in MongoDB (web_requests) and the bot carries them out within a couple of seconds, so the web
UI needs the matching bot version running. Not built yet: giving temporary roles from the website, and deleting a pinboard (use /pinboard delete). See the phases in the
plan. Raid and spam alerts are configured as a setting (alerts) and are posted by the bot.
Run it
The full walk-through, with reverse-proxy examples and a checklist, is in docs/DEPLOY.md. The short version:
The webui service is already in the compose.yaml of jarvis-bot, next
to bot, tasks, MongoDB and Redis, and uses the same .env. If your compose file does not have it, copy it from
compose.example.yaml. The example expects the cache and mongo services and the backend
network from that file.
-
In the Discord developer portal, open the bot's application, go to OAuth2 and add
<WEBUI_PUBLIC_URL>/callbackas a redirect. Copy the client secret. -
Put these in
.env(see sample.env):Variable WEBUI_CLIENT_IDThe application ID of the bot. Use the dev bot's in the dev deployment and the prod bot's in prod WEBUI_CLIENT_SECRETThe OAuth2 client secret TOKENThe bot token (lookups only) WEBUI_PUBLIC_URLWhere users reach the site, e.g. https://jarvis.example.comWEBUI_INVITE_PERMISSIONSOptional. Leave blank and the invite link uses the application's Default Install Settings from the developer portal; set an integer to override WEBUI_OFFLINEOptional. trueshows "Systems Offline, Waiting for Initialization" (HTTP 503) on every page except/healthz, without touching MongoDB or DiscordWEBUI_SESSION_DAYSOptional, default 7 WEBUI_ADMIN_IDSOptional. Comma-separated Discord user IDs of whoever runs this instance. They get the Admin pages ( /admin) in read-only form: overview, servers, queue, data health, users, logs, statistics and the audit trail. Everyone else gets a 404 there. Empty (the default) turns the pages offWEBUI_ADMIN_WRITE_IDSOptional. IDs of operators who may also change things from the Admin pages (maintenance mode, feature switches, leaving or blocking servers, erasing a person's data, cleaning up duplicate settings). They can look too, so they need not be in WEBUI_ADMIN_IDS. Keep this list shortWEBUI_EXPECTED_COPIESOptional, default 0. How many copies of the website you run (for example 3 under Swarm). The admin pages raise an alert when fewer are reporting, and for any copy that has gone quiet. 0 only watches copies that are still listed WEBUI_ADMIN_SESSION_HOURSOptional, default 12. The Admin pages ask for a fresh sign-in through Discord once a session is older than this WEBUI_STATS_DATABASEOptional. The database holding the bot's statistics ( Stat,StaticStat). By default the same database as the bot (MONGO_DATABASE, elsejarvis_devorjarvis), which is where the bot writes them. Only the 2.x bot used a separatestatipydatabaseWEBUI_SOURCE_URLOptional. Where the footer's "Source code" link goes (default: this repository) WEBUI_FORWARDED_ALLOW_IPSOptional, default 127.0.0.1. Set this when the site runs in Docker behind a reverse proxy. It is the reverse proxy's address (comma-separated, or a CIDR range): only requests from there may setX-Forwarded-ForandX-Forwarded-Proto. In Docker the proxy reaches the container from the network's gateway or the proxy container's address, not127.0.0.1. Left at the default, the site ignores those headers, so client IP addresses and https detection are wrong. Set it to the proxy's address (for example172.18.0.1or172.18.0.0/16). Never*unless nothing but the proxy can reach the portWEBUI_HOST,WEBUI_PORTOptional, default 0.0.0.0and8080. Where the site listens inside its container. The compose file publishes 8080, so leave themLOG_LEVELOptional, default INFOMONGO_*,ENVIRONMENTSame as the bot ( ENVIRONMENT=developusesjarvis_dev). With the compose stack's MongoDB, setMONGO_USERNAME,MONGO_PASSWORDandMONGO_AUTH_SOURCE=admin; the compose file creates that account when its data volume is first madeREDIS_HOST,REDIS_USERNAME,REDIS_PASSWORDOptional in the code, same as the bot. The compose file's Redis needs REDIS_PASSWORDand is atredis://cache. Rate limits (member search, filter tester) are shared through it, so every instance counts together and restarts do not reset them. Without it they are kept in each instance's memory. If it is down, requests are allowed rather than blockedRun one instance per bot (dev and prod), each with its own client ID, secret, token, URL and database.
-
docker compose up -d webui. It listens on port 8080, published on127.0.0.1only; put a TLS-terminating reverse proxy in front of it./healthzanswersok.
The container runs as user ID 10001 with a read-only root filesystem, no extra capabilities and no-new-privileges,
and needs no writable disk. It waits for MongoDB and Redis to be healthy, and the image checks /healthz itself.
Use the same JARVIS_VERSION as the bot and tasks.
Word filter rules
The Filters page and the bot's /filter command follow the same rules, because a pattern is a regular expression
that runs on every message. A filter is a list of patterns, one per line, up to 3000 characters. A server can have at
most 100 patterns across all its filters.
A pattern is refused if it:
- is longer than 200 characters;
- repeats something more than 100 times with
{n},{n,},{,m}or{n,m}; - nests repeated groups more than 2 deep, such as
((a+)+)+; - multiplies repeats inside repeats past 1000 in all, such as
((a{10}){10}){10}; - uses fuzzy matching, such as
{e<=1}; - uses an inline flag other than
i,mands, such as(?x); - contains a comment,
(?#...); - is not a valid regular expression.
Each pattern is also test-compiled in a separate, limited process. One that takes too long or too much memory to compile is refused, even if it passes the rules above. The reason is shown next to the field. To fix it, make the pattern simpler: a smaller repeat, or fewer nested groups.
Roles
On the Roles page, and wherever you choose a role the bot will hand out, a role is refused if it:
- carries a dangerous permission (Administrator, Manage Server, Manage Roles, Manage Channels, Manage Messages, Kick
Members, Ban Members, Moderate Members, Mention Everyone, and the others in the bot's
DANGEROUS_PERMISSIONS); - is managed by an integration;
- is at or above the bot's highest role;
- is at or above your own highest role (unless you own the server).
You need the Manage Roles permission to choose such roles (administrators and the server owner pass). Moderation actions follow the role hierarchy: you can only act on members whose highest role is below yours.
Develop
uv sync
cp sample.env .env # fill it in
uv run python run.py
Tests use a real MongoDB and a fake Discord:
JARVIS_TEST_MONGO_URI=mongodb://localhost:27017 uv run pytest
Every collection in the test database is dropped, so give it a database of its own (JARVIS_TEST_MONGO_DB).
Layout
| Path | |
|---|---|
webui/app.py |
Application factory, security headers, error pages |
webui/auth.py |
Sign in and out |
webui/deps.py, webui/perms.py |
Sessions, CSRF, and working out what someone may do in a server |
webui/discord.py |
Small Discord REST client with caching |
webui/routes/ |
Pages |
webui/templates/, webui/static/ |
The HUD theme (htmx and fonts are vendored; nothing loads from third parties) |