Add an option to sync rooms on startup

This commit is contained in:
Travis Ralston 2019-10-04 21:02:37 -06:00
parent e69f0e6940
commit 5e081e2246
4 changed files with 13 additions and 2 deletions

View File

@ -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?)

View File

@ -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

View File

@ -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() {

View File

@ -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