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

Convert mentions to usernames.

parent 9f85f410
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -276,19 +276,22 @@ export class DiscordBot {
});
});
if (msg.content !== null && msg.content !== "") {
const markdown = marked(msg.content);
if (markdown !== msg.content) {
// Markdown message
// Replace mentions.
const content = msg.content.replace(/<@[0-9]*>/g, (item) => {
const id = item.substr(2, item.length - 3);
const member = msg.guild.members.get(id);
if (member) {
return member.user.username;
} else {
return `@_discord_${id}:${this.config.bridge.domain}`;
}
});
intent.sendMessage(room, {
body: msg.content,
body: content,
msgtype: "m.text",
formatted_body: markdown,
formatted_body: marked(content),
format: "org.matrix.custom.html",
});
} else {
// Plain text
intent.sendText(room, msg.content);
}
}
});
}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter