From: Matthieu Pignolet Date: Thu, 30 Jan 2025 15:03:29 +0000 (+0400) Subject: fix wrong sanitization X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=3ba26023d0d8b2b033a02a731cb5985923ee73e7;p=matthieu%2Fgru.git fix wrong sanitization --- diff --git a/discordjs/src/index.mjs b/discordjs/src/index.mjs index f0a4bae..589d75a 100644 --- a/discordjs/src/index.mjs +++ b/discordjs/src/index.mjs @@ -7,13 +7,14 @@ const SYMBOL_FOR_CREATE = Symbol.for("CREATE"); const SYMBOL_FOR_UPDATE = Symbol.for("UPDATE"); // Create a new client instance -const client = new Client({ intents: - [ - GatewayIntentBits.Guilds, - GatewayIntentBits.MessageContent, - GatewayIntentBits.GuildMessages, - GatewayIntentBits.DirectMessages - ] +const client = new Client({ + intents: + [ + GatewayIntentBits.Guilds, + GatewayIntentBits.MessageContent, + GatewayIntentBits.GuildMessages, + GatewayIntentBits.DirectMessages + ] }); // `autofeur_db` service @@ -40,13 +41,13 @@ export const completeWord = (grapheme) => { */ const sanitizeWord = (sentence) => { let lastWord = sentence - .trim() - .split(" ") - .slice(-1)[0] .replaceAll(/(?:https?|ftp):\/\/[\n\S]+/g, "") .replaceAll(/\:([a-z]|[A-Z])+\:/g, "") .replaceAll(/(\?|\!|\.|\,|\;)/g, "") - .replaceAll(/([^A-z])/g, ""); + .replaceAll(/([^A-z])/g, "") + .trim() + .split(" ") + .slice(-1)[0]; return lastWord; }; const anyTrivialCharRegex = /([a-z]|[A-Z])+/g; @@ -74,11 +75,11 @@ const messageAction = async (message, ctx) => { .messages .fetch({ limit: 2, - cache : false + cache: false })) .last() .createdTimestamp; - + let shouldReplyByTimestamp = currentTimestamp - lastMessageTimestamp >= 3600000; let shouldReplyByCounter = messageReplyCounter >= Math.floor(Math.random() * 75) + 35; @@ -107,7 +108,7 @@ const messageAction = async (message, ctx) => { messageReplyCounter = oldCounter; } } - + if (message.content.includes("@everyone") && !ignoredChannels.includes(message.channelId)) { message.reply("https://cdn.mpgn.dev/pascontent-gabe.gif"); }