2019-09-25 21:36:12 -04:00
|
|
|
# mjolnir
|
2019-09-25 22:13:20 -04:00
|
|
|
|
2019-10-08 11:28:06 -04:00
|
|
|
A moderation tool for Matrix. Visit [#mjolnir:matrix.org](https://matrix.to/#/#mjolnir:matrix.org)
|
|
|
|
for more information.
|
2019-09-25 22:13:20 -04:00
|
|
|
|
|
|
|
## Features
|
|
|
|
|
|
|
|
TODO: Describe what all this means.
|
|
|
|
|
|
|
|
Phase 1:
|
2019-09-27 21:54:13 -04:00
|
|
|
* [x] Ban users
|
2019-09-27 17:44:28 -04:00
|
|
|
* [x] ACL servers
|
|
|
|
* [x] Update lists with new bans/ACLs
|
2019-09-25 22:13:20 -04:00
|
|
|
|
|
|
|
Phase 2:
|
2019-10-03 00:20:37 -04:00
|
|
|
* [x] Pantalaimon support
|
2019-10-09 09:51:30 -04:00
|
|
|
* [x] No-op mode (for verifying behaviour)
|
2019-10-09 10:53:37 -04:00
|
|
|
* [x] Redact messages on ban (optionally)
|
2019-10-04 22:59:30 -04:00
|
|
|
* [x] More useful spam in management room
|
2019-10-10 06:30:52 -04:00
|
|
|
* [x] Command to import ACLs, etc from rooms
|
2019-10-04 23:22:34 -04:00
|
|
|
* [x] Vet rooms on startup option
|
2019-10-10 07:37:42 -04:00
|
|
|
* [x] Command to actually unban users (instead of leaving them stuck)
|
2019-10-08 12:57:03 -04:00
|
|
|
* [x] Support multiple lists
|
2019-09-27 22:05:01 -04:00
|
|
|
|
|
|
|
Phase 3:
|
2019-10-25 23:06:31 -04:00
|
|
|
* [x] Synapse antispam module
|
2019-10-04 23:02:37 -04:00
|
|
|
* [ ] Room upgrade handling (both protected+list rooms)
|
2019-09-27 22:05:01 -04:00
|
|
|
* [ ] Support community-defined scopes? (ie: no hardcoded config)
|
|
|
|
* [ ] Riot hooks (independent of mjolnir?)
|
2019-09-25 22:13:20 -04:00
|
|
|
|
|
|
|
## Docker (preferred)
|
|
|
|
|
2019-10-08 11:28:06 -04:00
|
|
|
Mjolnir is on Docker Hub as [matrixdotorg/mjolnir](https://hub.docker.com/r/matrixdotorg/mjolnir)
|
|
|
|
but can be built yourself with `docker build -t mjolnir .`.
|
2019-09-25 22:13:20 -04:00
|
|
|
|
|
|
|
```bash
|
|
|
|
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
|
|
|
|
|
2019-10-08 11:28:06 -04:00
|
|
|
docker run --rm -it -v /etc/mjolnir:/data matrixdotorg/mjolnir:latest
|
2019-09-25 22:13:20 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
## Build it
|
|
|
|
|
|
|
|
This bot requires `yarn` and Node 10.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
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
|
|
|
|
```
|
|
|
|
|
2019-10-25 15:32:05 -04:00
|
|
|
## Synapse Antispam Module
|
|
|
|
|
2019-10-31 10:34:58 -04:00
|
|
|
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.
|
|
|
|
|
2019-10-25 15:32:05 -04:00
|
|
|
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](https://matrix.to/#/#synapse:matrix.org) if you're not sure.
|
|
|
|
|
|
|
|
Then add the following to your `homeserver.yaml`:
|
|
|
|
```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.
|
|
|
|
|
2019-09-25 22:13:20 -04:00
|
|
|
## Development
|
|
|
|
|
|
|
|
TODO. It's a TypeScript project with a linter.
|