diff --git a/src/matrixmessageprocessor.ts b/src/matrixmessageprocessor.ts index 1cdeff18b0611de1188f7273c89e56dddfad21b6..80459a0c37a8d8bd6c57cc82241197ff08c1e215 100644 --- a/src/matrixmessageprocessor.ts +++ b/src/matrixmessageprocessor.ts @@ -190,7 +190,9 @@ export class MatrixMessageProcessor { } if (!emoji) { - return await this.escapeDiscord(name); + const content = await this.escapeDiscord(name); + const url = this.params && this.params.mxClient ? this.params.mxClient.mxcUrlToHttp(attrs.src) : attrs.src; + return attrs.src ? `[${content}](${url})` : content; } return `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`; } diff --git a/test/test_matrixmessageprocessor.ts b/test/test_matrixmessageprocessor.ts index af6253c67219f8cca1f64d07dec3a33fcb1b6c35..6241f55d12187b2f4dad434d999c383e5f888f49 100644 --- a/test/test_matrixmessageprocessor.ts +++ b/test/test_matrixmessageprocessor.ts @@ -334,14 +334,14 @@ code const result = await mp.FormatMessage(msg, guild as any); expect(result).is.equal("<:test_emoji:123456>"); }); - it("ignores unknown mxc urls", async () => { + it("parses unknown mxc urls", async () => { const mp = new MatrixMessageProcessor(bot); const guild = new MockGuild("1234"); const emoji = new MockEmoji("123456", "test_emoji"); guild.emojis.set("123456", emoji); const msg = getHtmlMessage("<img alt=\"yay\" src=\"mxc://unreal_emote:localhost\">"); const result = await mp.FormatMessage(msg, guild as any); - expect(result).is.equal("yay"); + expect(result).is.equal("[yay](mxc://unreal_emote:localhost)"); }); it("ignores with no alt / title, too", async () => { const mp = new MatrixMessageProcessor(bot);