A moderation tool for Matrix
Go to file
2019-12-04 18:51:03 -07:00
config Add a config option to reduce homeserver load during ban checks 2019-11-06 18:54:59 -07:00
docs Add a moderator's guide to Mjolnir 2019-10-28 20:20:47 -06:00
src Add a protection system with a "first message is an image" demo 2019-12-04 18:51:03 -07:00
synapse_antispam Use background processes, not log contexts 2019-11-13 15:05:16 -07:00
test/commands Test for ban reasons as well in autodetection 2019-11-13 21:46:20 -07:00
.dockerignore Absolute bare minimum for a bot 2019-09-25 20:13:20 -06:00
.gitignore Absolute bare minimum for a bot 2019-09-25 20:13:20 -06:00
Dockerfile Use yarn in the docker image too 2019-10-31 10:55:44 -06:00
LICENSE Initial commit 2019-09-25 19:36:12 -06:00
package.json Update matrix-bot-sdk 2019-12-04 18:46:00 -07:00
README.md Add a description for what Mjolnir's antispam module does 2019-10-31 08:34:58 -06:00
tsconfig.json Make the [un]ban command smarter 2019-11-13 21:38:19 -07:00
tslint.json Fix tlsint 2019-09-27 13:54:34 -06:00
yarn.lock Update matrix-bot-sdk 2019-12-04 18:46:00 -07:00

mjolnir

A moderation tool for Matrix. Visit #mjolnir:matrix.org for more information.

Features

TODO: Describe what all this means.

Phase 1:

  • Ban users
  • ACL servers
  • Update lists with new bans/ACLs

Phase 2:

  • Pantalaimon support
  • No-op mode (for verifying behaviour)
  • Redact messages on ban (optionally)
  • More useful spam in management room
  • Command to import ACLs, etc from rooms
  • Vet rooms on startup option
  • Command to actually unban users (instead of leaving them stuck)
  • Support multiple lists

Phase 3:

  • Synapse antispam module
  • Room upgrade handling (both protected+list rooms)
  • Support community-defined scopes? (ie: no hardcoded config)
  • Riot hooks (independent of mjolnir?)

Docker (preferred)

Mjolnir is on Docker Hub as matrixdotorg/mjolnir but can be built yourself with docker build -t mjolnir ..

git clone https://github.com/matrix-org/mjolnir.git
cd mjolnir

# Copy and edit the config. It is not recommended to change the data path.
mkdir -p /etc/mjolnir
cp config/default.yaml /etc/mjolnir/production.yaml
nano /etc/mjolnir/production.yaml

docker run --rm -it -v /etc/mjolnir:/data matrixdotorg/mjolnir:latest

Build it

This bot requires yarn and Node 10.

git clone https://github.com/matrix-org/mjolnir.git
cd mjolnir

yarn install
yarn build

# Copy and edit the config. It *is* recommended to change the data path.
cp config/default.yaml config/development.yaml
nano config/development.yaml

node lib/index.js

Synapse Antispam Module

Using the bot to manage your rooms is great, however if you want to use your ban lists (or someone else's) on your server to affect all of your users then an antispam module is needed. Primarily meant to block invites from undesired homeservers/users, Mjolnir's antispam module is a way to interpret ban lists and apply them to your entire homeserver.

First, install the module to your Synapse python environment:

pip install -e git+https://github.com/matrix-org/mjolnir.git#egg=mjolnir&subdirectory=synapse_antispam

Note: Where your python environment is depends on your installation method. Visit #synapse:matrix.org if you're not sure.

Then add the following to your homeserver.yaml:

spam_checker:
  module: mjolnir.AntiSpam
  config:
    # Prevent servers/users in the ban lists from inviting users on this
    # server to rooms. Default true.
    block_invites: true
    # Flag messages sent by servers/users in the ban lists as spam. Currently
    # this means that spammy messages will appear as empty to users. Default
    # false.
    block_messages: false
    # The room IDs of the ban lists to honour. Unlike other parts of Mjolnir,
    # this list cannot be room aliases or permalinks. This server is expected
    # to already be joined to the room - Mjolnir will not automatically join
    # these rooms.
    ban_lists:
      - "!roomid:example.org"

Be sure to change the configuration to match your setup. Your server is expected to already be participating in the ban lists - if it is not, you will need to have a user on your homeserver join. The antispam module will not join the rooms for you.

If you change the configuration, you will need to restart Synapse. You'll also need to restart Synapse to install the plugin.

Development

TODO. It's a TypeScript project with a linter.