Skip to content
Extraits de code Groupes Projets
Valider 8da5a4e7 rédigé par TurBoss's avatar TurBoss
Parcourir les fichiers

Allow to disable join / leave echos

parent 820899c2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -27,6 +27,8 @@ bridge:
# Disable sending of read receipts for Matrix events which have been
# successfully bridged to Discord.
disableReadReceipts: false
# Disable Join Leave echos from matrix
disableJoinLeaveNotifications: false
# Authentication configuration for the discord bot.
auth:
clientID: "12345"
......
......@@ -54,6 +54,7 @@ class DiscordBridgeConfigBridge {
public disableReadReceipts: boolean;
public disableEveryoneMention: boolean = false;
public disableHereMention: boolean = false;
public disableJoinLeaveNotifications: boolean = false;
}
export class DiscordBridgeConfigDatabase {
......
......@@ -85,13 +85,21 @@ export class MatrixEventProcessor {
const membership = event.content!.membership;
if (membership === "join"
&& event.unsigned.prev_content === undefined) {
msg += `joined the room`;
if (!this.config.bridge.disableJoinLeaveNotifications) {
msg += `joined the room`;
} else {
return
}
} else if (membership === "invite") {
msg += `invited \`${event.state_key}\` to the room`;
} else if (membership === "leave" && event.state_key !== event.sender) {
msg += `kicked \`${event.state_key}\` from the room`;
} else if (membership === "leave") {
msg += `left the room`;
if (!this.config.bridge.disableJoinLeaveNotifications) {
msg += `left the room`;
} else {
return
}
} else if (membership === "ban") {
msg += `banned \`${event.state_key}\` from the room`;
}
......@@ -302,7 +310,7 @@ export class MatrixEventProcessor {
const mxClient = this.bridge.getClientFactory().getClientAs();
avatarUrl = mxClient.mxcUrlToHttp(profile.avatar_url, DISCORD_AVATAR_WIDTH, DISCORD_AVATAR_HEIGHT);
}
}
}disablePresence
embed.setAuthor(
displayName.substr(0, MAX_NAME_LENGTH),
avatarUrl,
......
......@@ -31,6 +31,7 @@ describe("DiscordBridgeConfig.ApplyConfig", () => {
disableDiscordMentions: false,
disableTypingNotifications: true,
enableSelfServiceBridging: false,
disableJoinLeaveNotifications: true,
homeserverUrl: "blah",
},
logging: {
......@@ -42,6 +43,7 @@ describe("DiscordBridgeConfig.ApplyConfig", () => {
expect(config.bridge.disableDiscordMentions).to.be.false;
expect(config.bridge.disableDeletionForwarding).to.be.true;
expect(config.bridge.enableSelfServiceBridging).to.be.false;
expect(config.brdge.disableJoinLeaveNotifications).to.be.true
expect(config.logging.console, "warn");
});
it("should merge logging.files correctly", () => {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter