Skip to content
Extraits de code Groupes Projets
Valider c5223e9f rédigé par Will Hunt's avatar Will Hunt
Parcourir les fichiers

Fix emoji sizes

parent 3ed5037e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -6,6 +6,7 @@ import * as escapeStringRegexp from "escape-string-regexp"; ...@@ -6,6 +6,7 @@ import * as escapeStringRegexp from "escape-string-regexp";
const USER_REGEX = /<@!?([0-9]*)>/g; const USER_REGEX = /<@!?([0-9]*)>/g;
const CHANNEL_REGEX = /<#?([0-9]*)>/g; const CHANNEL_REGEX = /<#?([0-9]*)>/g;
const EMOJI_SIZE = "1em";
const EMOJI_REGEX = /<:\w+:?([0-9]*)>/g; const EMOJI_REGEX = /<:\w+:?([0-9]*)>/g;
const MATRIX_TO_LINK = "https://matrix.to/#/"; const MATRIX_TO_LINK = "https://matrix.to/#/";
...@@ -93,7 +94,7 @@ export class MessageProcessor { ...@@ -93,7 +94,7 @@ export class MessageProcessor {
const id = results[1]; const id = results[1];
try { try {
const mxcUrl = await this.bot.GetGuildEmoji(msg.guild, id); const mxcUrl = await this.bot.GetGuildEmoji(msg.guild, id);
content = content.replace(results[0], `![${id}](${mxcUrl})`); content = content.replace(results[0], `<img alt="${id}" src="${mxcUrl}" style="height: ${EMOJI_SIZE};"/>`);
} catch (ex) { } catch (ex) {
log.warn("MessageProcessor", log.warn("MessageProcessor",
`Could not insert emoji ${id} for msg ${msg.id} in guild ${msg.guild.id}: ${ex}`, `Could not insert emoji ${id} for msg ${msg.id} in guild ${msg.guild.id}: ${ex}`,
......
...@@ -111,7 +111,7 @@ describe("MessageProcessor", () => { ...@@ -111,7 +111,7 @@ describe("MessageProcessor", () => {
const msg = new Discord.Message(channel, null, null); const msg = new Discord.Message(channel, null, null);
let content = "Hello <:hello:3333333>"; let content = "Hello <:hello:3333333>";
content = await processor.ReplaceEmoji(content, msg); content = await processor.ReplaceEmoji(content, msg);
Chai.assert.equal(content, "Hello ![3333333](mxc://image)"); Chai.assert.equal(content, "Hello <img alt=\"3333333\" src=\"mxc://image\" style=\"height: 1em;\"/>");
}); });
}); });
describe("FindMentionsInPlainBody", () => { describe("FindMentionsInPlainBody", () => {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment