rename string into clean & add settings

This commit is contained in:
Lou 2025-11-25 18:27:54 +01:00
parent 4d309e2e9e
commit 65e09de7e2
10 changed files with 24 additions and 10 deletions

View file

@ -1,5 +1,5 @@
import detector from "./detector.js"; import detector from "./detector.js";
import { cleanMessageContent } from "../utils/strings.js"; import { cleanMessageContent } from "../utils/clean.js";
/*check the regex for "quoi" /*check the regex for "quoi"
trigger if it's at the end of the sentence (tu fais quoi) trigger if it's at the end of the sentence (tu fais quoi)

View file

@ -1,3 +1,5 @@
import { getSetting } from '../utils/settings.js';
export const TriggerState = { export const TriggerState = {
untriggered: 0, untriggered: 0,
replied: 1, replied: 1,

View file

@ -1,5 +1,5 @@
import detector from "./detector.js"; import detector from "./detector.js";
import { cleanMessageContent } from "../utils/strings.js"; import { cleanMessageContent } from "../utils/clean.js";
/*check if someone reply to a "quoi" with a "feur" or "quoifeur" /*check if someone reply to a "quoi" with a "feur" or "quoifeur"
send praise send praise

View file

@ -1,5 +1,5 @@
import detector from "./detector.js"; import detector from "./detector.js";
import { cleanMessageContent } from "../utils/strings.js"; import { cleanMessageContent } from "../utils/clean.js";
//check if the bot is pinged by someone //check if the bot is pinged by someone

View file

@ -1,5 +1,5 @@
import detector from "./detector.js"; import detector from "./detector.js";
import { cleanMessageContent } from "../utils/strings.js"; import { cleanMessageContent } from "../utils/clean.js";
/*check if someone reply to a "quoi" with a "quoicoubeh" or "coubeh" /*check if someone reply to a "quoi" with a "quoicoubeh" or "coubeh"
send roasts send roasts

View file

@ -1,5 +1,5 @@
import detector from "./detector.js"; import detector from "./detector.js";
import { cleanMessageContent } from "../utils/strings.js"; import { cleanMessageContent } from "../utils/clean.js";
const suffixes = [ const suffixes = [
", je crois", ", je crois",

View file

@ -2,7 +2,7 @@ import detector from "./detector.js";
import compromise from 'fr-compromise'; import compromise from 'fr-compromise';
import conj from 'conjugation-fr'; import conj from 'conjugation-fr';
import { toInfinitive } from "../data/index.js"; import { toInfinitive } from "../data/index.js";
import { cleanMessageContent } from "../utils/strings.js"; import { cleanMessageContent } from "../utils/clean.js";
/*check the pronoun / subject of the question to answer properly by conjugating /*check the pronoun / subject of the question to answer properly by conjugating
exemple : tu fais quoi ? je fais feur exemple : tu fais quoi ? je fais feur

View file

@ -5,8 +5,7 @@ import firstDetector from './detectors/allDetector.js';
const client = new Client({ const client = new Client({
makeCache: Options.cacheWithLimits({ makeCache: Options.cacheWithLimits({
MessageManager: 0, // Très bien pour la RAM MessageManager: 0, //opti de RAM
// Ajoute ceci pour économiser encore plus :
UserManager: 0, UserManager: 0,
GuildMemberManager: 0, GuildMemberManager: 0,
ThreadManager: 0, ThreadManager: 0,

View file

@ -6,10 +6,10 @@
*/ */
export function cleanMessageContent(message) { export function cleanMessageContent(message) {
// Sécurité si le message est vide ou bizarre // securite si le message est vide ou bizarre
if (!message) return ""; if (!message) return "";
// On privilégie cleanContent qui est plus propre pour la lecture humaine // privilegier cleanContent pour la lecture humaine
const text = message.cleanContent || message.content || ""; const text = message.cleanContent || message.content || "";
return text.trim(); return text.trim();

13
utils/settings.js Normal file
View file

@ -0,0 +1,13 @@
const defaultSettings = {
quoiAnswerPercentage: 100,
feurAnswerPercentage: 100,
mentionAnswerPercentage: 100,
quoicoubehAnswerPercentage: 100,
ignoredRoleId: null, // ajouter ID au besoin
forcedAnswerRoleId: null // ajouter ID au besoin
};
export function getSetting(guildId, key) {
// brancher une BDD plus tard
return defaultSettings[key] ?? null;
}