diff --git a/config/config.sample.yaml b/config/config.sample.yaml index f995e948abd86c94b06869face19ea5b84b99fc2..f5ae4d3c2b73a82febca444bd727fae13fb8972b 100644 --- a/config/config.sample.yaml +++ b/config/config.sample.yaml @@ -3,6 +3,7 @@ bridge: homeserverUrl: "http://localhost:8008" disablePresence: false disableTypingNotifications: false + disableDiscordMentions: false auth: clientID: "12345" # Get from discord secret: "blah" diff --git a/config/config.schema.yaml b/config/config.schema.yaml index f515f8bf98754aa32d0e7de1cbf72131d1ea0e38..4b4e1d90f93b5f81b84ebfacb5ad851d1af54f1d 100644 --- a/config/config.schema.yaml +++ b/config/config.schema.yaml @@ -14,6 +14,8 @@ properties: type: "boolean" disableTypingNotifications: type: "boolean" + disableDiscordMentions: + type: "boolean" auth: type: "object" required: ["botToken"] diff --git a/src/bot.ts b/src/bot.ts index 2b7622cc1c0d03d895d9c89af33ed32b3a5ad07a..fbdf291ecde591f852062b45acd3dab857094987 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -145,6 +145,11 @@ export class DiscordBot { } public MatrixEventToEmbed(event: any, profile: any, channel: Discord.TextChannel): Discord.RichEmbed { + const body = this.config.bridge.disableDiscordMentions ? event.content.body : + this.msgProcessor.FindMentionsInPlainBody( + event.content.body, + channel.members.array(), + ); if (profile) { profile.displayname = profile.displayname || event.sender; if (profile.avatar_url) { @@ -157,11 +162,11 @@ export class DiscordBot { icon_url: profile.avatar_url, url: `https://matrix.to/#/${event.sender}`, }, - description: this.msgProcessor.FindMentionsInPlainBody(event.content.body, channel.members.array()), + description: body, }); } return new Discord.RichEmbed({ - description: this.msgProcessor.FindMentionsInPlainBody(event.content.body, channel.members.array()), + description: body, }); } diff --git a/src/config.ts b/src/config.ts index 959f1448e7e56258c1538deccfd19b1dd8aac776..e0ec7a2abeda2ab59c16fa83f8f49b69474b99c9 100644 --- a/src/config.ts +++ b/src/config.ts @@ -12,6 +12,7 @@ class DiscordBridgeConfigBridge { public homeserverUrl: string; public disablePresence: boolean; public disableTypingNotifications: boolean; + public disableDiscordMentions: boolean; } class DiscordBridgeConfigDatabase {