From 43deebeb695e62828c6842f60c8683079c930990 Mon Sep 17 00:00:00 2001 From: Will Hunt <will@half-shot.uk> Date: Sun, 10 Jun 2018 19:06:01 +0100 Subject: [PATCH] Support m.emote again, and add tests --- src/matrixeventprocessor.ts | 19 ++++++++++--------- test/test_matrixeventprocessor.ts | 11 +++++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/matrixeventprocessor.ts b/src/matrixeventprocessor.ts index 9236e9d..749af4b 100644 --- a/src/matrixeventprocessor.ts +++ b/src/matrixeventprocessor.ts @@ -48,6 +48,16 @@ export class MatrixEventProcessor { body = body.replace(new RegExp(`@here`, "g"), "@ here"); } + /* See issue #82 + const isMarkdown = (event.content.format === "org.matrix.custom.html"); + if (!isMarkdown) { + body = "\\" + body; + }*/ + + if (event.content.msgtype === "m.emote") { + body = `*${body}*`; + } + // Handle discord custom emoji body = this.ReplaceDiscordEmoji(body, channel.guild); @@ -64,15 +74,6 @@ export class MatrixEventProcessor { const mxClient = this.bridge.getClientFactory().getClientAs(); avatarUrl = mxClient.mxcUrlToHttp(profile.avatar_url); } - /* See issue #82 - const isMarkdown = (event.content.format === "org.matrix.custom.html"); - if (!isMarkdown) { - body = "\\" + body; - } - if (event.content.msgtype === "m.emote") { - body = `*${body}*`; - } - */ } return new Discord.RichEmbed({ author: { diff --git a/test/test_matrixeventprocessor.ts b/test/test_matrixeventprocessor.ts index 01572ec..f5f61d8 100644 --- a/test/test_matrixeventprocessor.ts +++ b/test/test_matrixeventprocessor.ts @@ -242,6 +242,17 @@ describe("MatrixEventProcessor", () => { }, {avatar_url: "test"}, mockChannelEmojis as any); Chai.assert.equal(evt.description, "I like :lamecake:"); }); + it("Should show emotes with italics.", () => { + const processor = createMatrixEventProcessor(false, false, true); + const evt = processor.EventToEmbed({ + sender: "@test:localhost", + content: { + body: "eats pizza", + msgtype: "m.emote", + }, + }, null, mockChannel as any); + Chai.assert.equal(evt.description, "*eats pizza*"); + }); }); describe("FindMentionsInPlainBody", () => { it("processes mentioned username correctly", async () => { -- GitLab