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

Merge pull request #14 from turt2live/turt2live-patch-1

Escape regex before parsing mentions
parents a265e319 966dbf90
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -9,6 +9,7 @@ import * as Bluebird from "bluebird";
import * as mime from "mime";
import * as marked from "marked";
import * as path from "path";
import * as escapeStringRegexp from "escape-string-regexp";
// Due to messages often arriving before we get a response from the send call,
// messages get delayed from discord.
......@@ -240,7 +241,7 @@ export class DiscordBot {
private HandleMentions(body: string, members: Discord.GuildMember[]): string {
for (const member of members) {
body = body.replace(new RegExp(member.displayName, "g"), `<@!${member.id}>`);
body = body.replace(new RegExp(escapeStringRegexp(member.displayName), "g"), `<@!${member.id}>`);
}
return body;
}
......
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