- Python 99.9%
- Dockerfile 0.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
CI / precommit (pull_request) Successful in 41s
CI / test (3.12) (pull_request) Successful in 10m1s
CI / test (3.13) (pull_request) Successful in 15m51s
CI / test (3.14) (pull_request) Successful in 8m7s
CI / test (3.15) (pull_request) Successful in 8m2s
CI / image (pull_request) Has been skipped
CI / precommit (push) Successful in 28s
CI / test (3.12) (push) Successful in 7m58s
CI / test (3.14) (push) Successful in 8m3s
CI / test (3.15) (push) Successful in 8m5s
CI / test (3.13) (push) Successful in 13m37s
CI / image (push) Successful in 8s
|
||
| .forgejo/workflows | ||
| jarvis | ||
| tests | ||
| .dockerignore | ||
| .flake8 | ||
| .gitattributes | ||
| .gitignore | ||
| .pre-commit-config.yaml | ||
| compose.env | ||
| compose.yaml | ||
| Dockerfile | ||
| jarvis.png | ||
| jarvis.svg | ||
| jarvis_small.png | ||
| LICENSE | ||
| PRIVACY.md | ||
| pyproject.toml | ||
| README.md | ||
| requirements.precommit.txt | ||
| run.py | ||
| sample.env | ||
| schema.yaml | ||
| TERMS.md | ||
| uv.lock | ||
Just Another Rather Very Intelligent System
Welcome to the JARVIS Initiative, an open-source multi-purpose bot
Features
JARVIS currently offers:
- 👩💼 Administration:
verify,ban/unban,kick,purge,mute/unmuteand more! - 🚓 Moderation:
lock/unlock,lockdown,warn,autoreact, and also more! - 🔧 Utilities:
remindme,rolegiver,temprole,image, and so many more! - 🏷️ Tags: Custom
tags! Useful for custom messages without the hassle!
Contributing
Before creating an issue, please ensure that it hasn't already been reported/suggested. If you have a question, please join the community Discord before opening an issue.
If you wish to contribute to the JARVIS codebase or documentation, join the Discord! The recognized developers there will help you get started.
Community
Join the Stark R&D Department Discord server to be kept up-to-date on code updates and issues.
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.
Requirements
To run with Docker Compose (recommended): Docker with the Compose plugin. The compose file brings its own MongoDB
(mongo:9.0) and Redis (redis:8.10).
To run without Docker:
- MongoDB 7.0 or higher
- Redis
- Python 3.12 or higher
- interactions.py 6.0 (currently a release candidate)
- uv for installing dependencies
Run with Docker Compose
compose.yaml runs bot, tasks, webui, MongoDB (mongo) and Redis (cache).
-
Copy the template and fill it in:
cp compose.env .envSet
TOKEN,ERAPI,MONGO_PASSWORDandREDIS_PASSWORD. Compose refuses to start whileMONGO_USERNAME,MONGO_PASSWORDorREDIS_PASSWORDis empty. -
Start the stack:
docker compose up -d docker compose psThe
webuiservice needsWEBUI_CLIENT_ID,WEBUI_CLIENT_SECRETandWEBUI_PUBLIC_URL, and stops with an error without them. If you do not want the website yet, start only the rest:docker compose up -d bot tasksTo add the website later, follow
docs/DEPLOY.mdin the jarvis-webui repository.
Services wait for their dependencies: bot and webui start once mongo and cache report healthy, and tasks
starts once mongo does.
Settings in .env
| Variable | Default | Meaning |
|---|---|---|
TOKEN |
none | Discord bot token. Required |
ERAPI |
none | exchangerate-api.org API key, for currency conversion. Required by the bot |
MONGO_USERNAME, MONGO_PASSWORD |
jarvis, none |
The MongoDB root account. Required. See the note below |
MONGO_AUTH_SOURCE |
admin |
The database that holds that account. Keep admin: the root account is created there |
MONGO_HOST, MONGO_PORT |
mongo, 27017 |
Where the apps find MongoDB |
MONGO_DATABASE |
empty | Database name. Empty means jarvis (ENVIRONMENT=production) or jarvis_dev (ENVIRONMENT=develop) |
REDIS_PASSWORD |
none | Password for Redis. Required. Applied on every start |
REDIS_HOST |
redis://cache |
Redis address. A bare host name also works |
REDIS_USERNAME |
not set | Leave empty. The compose Redis has no named users |
ENVIRONMENT |
production |
production or develop |
LOG_LEVEL |
INFO |
Log level |
SYNC |
true |
Whether the bot syncs its slash commands with Discord on start. The code default is false; compose.env sets true |
JARVIS_VERSION |
latest |
Image tag for jarvis-bot, jarvis-tasks and jarvis-webui. Set it (for example 3.2.0) to stay on one release |
JARVIS_LOG_FILE |
logs/jarvis.log |
Where the bot writes its log file |
WEBUI_* |
none | Website settings. See the jarvis-webui README |
WEBUI_FORWARDED_ALLOW_IPS |
127.0.0.1 |
Set this to your reverse proxy's address when it runs in Docker. See below |
If you run a reverse proxy in front of webui, set WEBUI_FORWARDED_ALLOW_IPS to the address the proxy connects from
(docker network inspect <network> shows the gateway and subnet). The default, 127.0.0.1, is wrong inside Docker:
the website then ignores the proxy's X-Forwarded-For and X-Forwarded-Proto headers, so client IP addresses and
https detection are wrong.
Other optional bot settings are listed in sample.env: PHISHLIST_CHANNEL, ERROR_CHANNEL, PASTE_SITE,
ADMIN_IDS, WEBSITE_URL and OWNER_PREFIX.
MongoDB credentials are set once. MONGO_USERNAME and MONGO_PASSWORD become the MongoDB root account only when
the mongo-data volume is created. Changing them later in .env does not change the account inside an existing
volume, and the apps will then fail to sign in. To change a password on a running database, change it in MongoDB, then
update .env.
How the containers are set up
- Pinned images:
mongo:9.0,redis:8.10. The app images use${JARVIS_VERSION:-latest}. - MongoDB and Redis sit on an internal
backendnetwork with no route out. Onlybot,tasksandwebuican reach them. Nothing publishes the database ports. bot,tasksandwebuidrop all Linux capabilities, setno-new-privileges, use a read-only root filesystem with atmpfsfor/tmp, and run as user ID 10001 (not root).webuilistens on127.0.0.1:8080only. Put a TLS reverse proxy in front of it.taskshas 20 seconds to stop. Jobs already running get 8 seconds to finish on shutdown.
Logs
The bot writes logs/jarvis.log (inside the container, /app/logs/jarvis.log) as well as to the console. The file is
rotated at 10 MB and 5 old files are kept. The bot-logs volume holds it, and it is the only place the bot can write.
docker compose logs -f bot # console output
docker compose exec bot tail -n 50 /app/logs/jarvis.log
If the log file cannot be written, the bot prints a message and keeps running with console logging only. Set
JARVIS_LOG_FILE to change the path. In the container it must be somewhere writable, such as under /app/logs.
Update to a new release
docker compose pull
docker compose up -d
Run the same version of bot, tasks and webui. Back up the mongo-data volume before an upgrade.
Upgrade an existing deployment
From MongoDB 8 to 9. The compose file now pins mongo:9.0. A data volume written by MongoDB 8 must go through
MongoDB's own upgrade procedure, including its featureCompatibilityVersion setting. Do this before you start the new
image. Follow MongoDB's upgrade documentation for 9.0, and take a
backup first. This repository does not provide the steps.
From a database without a password. If your mongo-data volume was created before the stack used passwords,
MONGO_USERNAME and MONGO_PASSWORD do not create a user in it, because they are used only when a volume is created.
Create the user yourself with mongosh, in the admin database, with the same name and password you put in .env,
and give it the root role. See MongoDB's documentation on creating a user. The other way is to start with a new
volume and restore a backup into it.
Redis. REDIS_PASSWORD is required and is checked on every connection. Set it in .env before you upgrade.
From jarvis-core 1.x. Discord IDs are stored as integers since jarvis-core 2.0. Run uv run jarvis-migrate once,
before you start the bot. See the jarvis-core README.
Run without Docker
uv sync --no-dev
cp sample.env .env # fill in TOKEN, ERAPI and the database settings
uv run python run.py
Use sample.env for this, not compose.env. It points at localhost instead of the compose service names.
Discord IDs are stored as integers since jarvis-core 2.0. When upgrading a database that was written by an older
version, run uv run jarvis-migrate once, before starting the bot.
Owner commands
Set OWNER_PREFIX (for example j!) to turn on the owner-only text commands: echo, tail, log, sysinfo and
crash. Only the bot's owner can use them. Without OWNER_PREFIX they are off.
tail [count]sends the lastcountlines of the log (1 to 1000, default 10).logsends the log file, or its last part if it is larger than 8 MiB.
tail and log send their output to the owner's direct messages, never to the channel where you typed the command,
because the log can contain user IDs, message content and errors. If your DMs are closed to the bot, it replies in the
channel that it could not send the log. Open your DMs to it and try again.
Rules for word filters
These apply to /filter and to the Filters page on the website. A filter is a list of patterns, one per line. A
pattern is a regular expression, matched without regard to upper or lower case.
A server can have at most 100 patterns across all its filters. The bot only checks the first 100 on each message.
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.
The bot also test-compiles each pattern in a separate, limited process. A pattern that takes too long or too much memory to compile is refused too, even if it passes the rules above. These limits exist because a few short patterns can keep the bot busy for seconds and use hundreds of megabytes of memory while compiling, which would slow every server. If your pattern is refused, make it simpler: use a smaller repeat, or fewer nested groups.
Roles the bot hands out
Some features give roles to members: the verified and unverified roles, rolegiver groups and role menus, and
temporary roles (/temprole, which can come back when a member rejoins).
- No dangerous permissions. The bot will not hand out a role that carries any of these permissions: Administrator, Manage Server, Manage Roles, Manage Channels, Manage Webhooks, Manage Messages, Kick Members, Ban Members, Moderate Members, Mention Everyone, Manage Nicknames, Manage Threads, Mute Members, Deafen Members, Move Members, Manage Expressions, Manage Events, View Audit Log, Pin Messages, Bypass Slowmode, Create Expressions, Create Events and Priority Speaker. This applies to the verified and unverified roles, rolegiver groups and role menus, and to a temporary role the bot gives back when a member rejoins. The check runs each time the bot gives the role, so editing a role later does not get around it.
- Other roles are refused too. Roles managed by an integration,
@everyone, and roles above the bot's highest role cannot be handed out. You also cannot choose a role that is not below your own highest role. - Choosing these roles needs Manage Roles. To set the verified or unverified role, or to add a role to a rolegiver group, you need the Manage Roles permission. Manage Server alone is not enough. Administrators and the server owner pass.
- Hierarchy is respected. Ban, kick, mute and warn, and giving someone a temporary role, work only on members whose highest role is below yours. For ban, kick and mute the bot's highest role must also be above theirs. The server owner is exempt from the first rule, and can never be the target.
Development
uv sync
JARVIS_TEST_MONGO_URI=mongodb://localhost:27017 JARVIS_TEST_MONGO_DB=jarvis_test uv run pytest
The tests use a real MongoDB and wipe the collections of JARVIS_TEST_MONGO_DB, so point it at a throwaway database.
JARVIS Features
Core Features
- Reminders!
- Set a reminder using human wording
- Repeat daily, weekly or monthly with one click, or use cron for anything else!
- Choose to get it as a DM right in the form
- Copy reminders that other users make so that you can also be reminded of it
- Server, User, and Role info!
- List all the emotes in the server!
- Check the bot status and see the logo!
- Install the bot to your own account to use the utility commands (
/pw,/timestamp,/calc,/dev,/avatar,/pigpen,/lmgtfy,/rc) in DMs, group chats and servers the bot is not in! - Secure password generation!
- Timestamp conversions!
Admin Features
- Track administrative actions taken against users!
- Bans, mutes, and more!
- Custom warnings
- Moderation cases
- Warn for pinging too many people/specific roles!
- Raid and spam alerts: a channel of your choice hears about joins at raid speed, someone posting in channel after channel, or many people posting the same thing, with buttons to mute, kick, ban or dismiss. Thresholds can be tuned per server with
/settings set alert_options. JARVIS only alerts; it never locks down or acts on its own - Warning escalation: mute, kick or ban automatically when a member reaches a number of active warnings
- Members can report a message to the moderators with the Report Message menu
- Discord AutoMod actions show up in the activity log next to the bot's own filter hits
- Server lockdowns to help with raids/spam, with channels and categories you can leave open
- Custom filters to prevent certain messages/phrases!
- Automated purging of channels, and
/purgefilters (user, bots, text, links, attachments, message range) - Verification system
Extra Features
- Calculator!
- Calculate basic math expressions
- Convert to and from many different units
- All conversions supported by the Microsoft calculator are supported!
- Live currency conversions
- Developer Tools!
- Hash using any Python-supported hash function!
- You can even hash URLs and uploads!
- Base-n encoding and decoding!
- Unique ID generation via ULIDs, UUIDs, and ObjectIDs!
- Hash using any Python-supported hash function!
- Image processing!
- Shrink an image to fit a certain size! Useful for making emotes
- Pinboard!
- Run out of pins? Use the pinboard!
- Dedicated channel for pinning messages
- Optionally pin automatically once a message gets enough reactions
- Rolegiver!
- Advanced self-assigned roles
- Group together roles for better organization!
- Add several roles to a group at once with
/rolegiver bulk - Pick-one groups, groups that need a role first, and role menus that stay in a channel for anyone to use
- Tags!
- Custom text responses from the bot
- Editing can be done by the author or a moderator!
- Aliases, search, and a most-used list