diff --git a/README.md b/README.md index 2eea357..e4677f2 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,11 @@ Phase 2: * [x] More useful spam in management room * [ ] Command to import ACLs, etc from rooms * [ ] Vet rooms on startup option -* [ ] Room upgrade handling (both protected+list rooms) * [ ] Command to actually unban users (instead of leaving them stuck) 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?) diff --git a/config/default.yaml b/config/default.yaml index 7c864fd..3a567ce 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -33,6 +33,10 @@ managementRoom: "#moderators:example.org" # Set to false to make the management room a bit quieter. verboseLogging: true +# Set to false to disable synchronizing the ban lists on startup. If true, this +# is the same as running !mjolnir sync immediately after startup. +syncOnStartup: true + # The room ID or alias where the bot's own personal ban list is kept. This is # where the commands to manage a ban list end up being routed to. Note that # this room is NOT automatically added to the banLists list below - you will diff --git a/src/Mjolnir.ts b/src/Mjolnir.ts index 12da537..26037b1 100644 --- a/src/Mjolnir.ts +++ b/src/Mjolnir.ts @@ -20,6 +20,7 @@ import { applyServerAcls } from "./actions/ApplyAcl"; import { RoomUpdateError } from "./models/RoomUpdateError"; import { COMMAND_PREFIX, handleCommand } from "./commands/CommandHandler"; import { applyUserBans } from "./actions/ApplyBan"; +import config from "./config"; export class Mjolnir { @@ -64,7 +65,12 @@ export class Mjolnir { } public start() { - return this.client.start(); + return this.client.start().then(() => { + if (config.syncOnStartup) { + this.client.sendNotice(this.managementRoomId, "Syncing lists..."); + return this.syncLists(); + } + }); } public async syncLists() { diff --git a/src/config.ts b/src/config.ts index ae06943..4d7d44c 100644 --- a/src/config.ts +++ b/src/config.ts @@ -28,6 +28,7 @@ interface IConfig { autojoin: boolean; managementRoom: string; verboseLogging: boolean; + syncOnStartup: boolean; publishedBanListRoom: string; protectedRooms: string[]; // matrix.to urls banLists: string[]; // matrix.to urls