fix wrong sanitization

This commit is contained in:
matthieu 2025-01-30 19:03:29 +04:00
parent 3d5c4980a1
commit 3ba26023d0

View file

@ -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");
}