Add a no-op mode

This commit is contained in:
Travis Ralston 2019-10-09 14:51:30 +01:00
parent 7501e3123a
commit adec9f58a6
5 changed files with 14 additions and 3 deletions

View File

@ -14,7 +14,7 @@ Phase 1:
Phase 2:
* [x] Pantalaimon support
* [ ] No-op mode (for verifying behaviour)
* [x] No-op mode (for verifying behaviour)
* [ ] Redact messages on ban (optionally)
* [x] More useful spam in management room
* [ ] Command to import ACLs, etc from rooms

View File

@ -42,6 +42,11 @@ syncOnStartup: true
# resets, etc) before Mjolnir is needed.
verifyPermissionsOnStartup: true
# If true, Mjolnir won't actually ban users or apply server ACLs, but will
# think it has. This is useful to see what it does in a scenario where the
# bot might not be trusted fully, yet. Default false (do bans/ACLs).
noop: false
# A list of rooms to protect (matrix.to URLs)
protectedRooms:
- "https://matrix.to/#/#yourroom:example.org"

View File

@ -51,7 +51,9 @@ export async function applyServerAcls(lists: BanList[], roomIds: string[], mjoln
await mjolnir.client.sendNotice(mjolnir.managementRoomId, `Applying ACL in ${roomId}`);
}
if (!config.noop) {
await mjolnir.client.sendStateEvent(roomId, "m.room.server_acl", "", finalAcl);
}
} catch (e) {
errors.push({roomId, errorMessage: e.message || (e.body ? e.body.error : '<no message>')});
}

View File

@ -58,7 +58,10 @@ export async function applyUserBans(lists: BanList[], roomIds: string[], mjolnir
await mjolnir.client.sendNotice(mjolnir.managementRoomId, `Banning ${member['state_key']} in ${roomId} for: ${userRule.reason}`);
}
if (!config.noop) {
await mjolnir.client.banUser(member['state_key'], roomId, userRule.reason);
}
banned = true;
break;
}

View File

@ -30,6 +30,7 @@ interface IConfig {
verboseLogging: boolean;
syncOnStartup: boolean;
verifyPermissionsOnStartup: boolean;
noop: boolean;
protectedRooms: string[]; // matrix.to urls
}