diff --git a/src/messageprocessor.ts b/src/messageprocessor.ts index 283b4011257866a0602f36947217beec7b4944b0..578823643ced24d35ab8c56ce0f0892f2d3a0efe 100644 --- a/src/messageprocessor.ts +++ b/src/messageprocessor.ts @@ -6,6 +6,7 @@ import * as escapeStringRegexp from "escape-string-regexp"; const USER_REGEX = /<@!?([0-9]*)>/g; const CHANNEL_REGEX = /<#?([0-9]*)>/g; +const EMOJI_SIZE = "1em"; const EMOJI_REGEX = /<:\w+:?([0-9]*)>/g; const MATRIX_TO_LINK = "https://matrix.to/#/"; @@ -93,7 +94,8 @@ export class MessageProcessor { const id = results[1]; try { const mxcUrl = await this.bot.GetGuildEmoji(msg.guild, id); - content = content.replace(results[0], ``); + content = content.replace(results[0], + `<img alt="${id}" src="${mxcUrl}" style="height: ${EMOJI_SIZE};"/>`); } catch (ex) { log.warn("MessageProcessor", `Could not insert emoji ${id} for msg ${msg.id} in guild ${msg.guild.id}: ${ex}`, diff --git a/test/test_messageprocessor.ts b/test/test_messageprocessor.ts index bc756796a806e92f38b339886c03834ee6909ca1..9a678ad5dd83aa16e1a50724bb858899776d41ae 100644 --- a/test/test_messageprocessor.ts +++ b/test/test_messageprocessor.ts @@ -111,7 +111,7 @@ describe("MessageProcessor", () => { const msg = new Discord.Message(channel, null, null); let content = "Hello <:hello:3333333>"; content = await processor.ReplaceEmoji(content, msg); - Chai.assert.equal(content, "Hello "); + Chai.assert.equal(content, "Hello <img alt=\"3333333\" src=\"mxc://image\" style=\"height: 1em;\"/>"); }); }); describe("FindMentionsInPlainBody", () => {