rename detector

This commit is contained in:
Lou 2025-11-20 21:56:50 +01:00
parent 17a67aaefa
commit 04f43b188d
7 changed files with 13 additions and 13 deletions

View file

@ -1,4 +1,4 @@
import Detector from "./Detector.js"; import detector from "./detector.js";
import { cleanMessageContent } from "../utils/strings.js"; import { cleanMessageContent } from "../utils/strings.js";
/*check the regex for "quoi" /*check the regex for "quoi"
@ -13,7 +13,7 @@ const answers = [
'||coubeh|| feur' '||coubeh|| feur'
]; ];
export default class BasicDetector extends Detector { export default class BasicDetector extends detector {
detect(message) { detect(message) {
return /(?:^|\b)quoi\b ?\??(\s\S+){0,3}$/i.test(cleanMessageContent(message)); return /(?:^|\b)quoi\b ?\??(\s\S+){0,3}$/i.test(cleanMessageContent(message));
} }

View file

@ -17,7 +17,7 @@ export function createTriggersChecklist() {
} }
// Base class for all detectors, using a Chain of Responsibility pattern // Base class for all detectors, using a Chain of Responsibility pattern
export default class Detector { export default class detector {
nextDetector = null; nextDetector = null;
triggerName = 'quoi'; // default value triggerName = 'quoi'; // default value

View file

@ -1,4 +1,4 @@
import Detector from "./Detector.js"; import detector from "./detector.js";
import { cleanMessageContent } from "../utils/strings.js"; import { cleanMessageContent } from "../utils/strings.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"
@ -18,7 +18,7 @@ const answers = [
'https://tenor.com/fr/view/well-played-sir-gif-22047381' 'https://tenor.com/fr/view/well-played-sir-gif-22047381'
]; ];
export default class FeurDetector extends Detector { export default class FeurDetector extends detector {
triggerName = 'feur'; triggerName = 'feur';
detect(message) { detect(message) {

View file

@ -1,4 +1,4 @@
import Detector from "./Detector.js"; import detector from "./detector.js";
import { cleanMessageContent } from "../utils/strings.js"; import { cleanMessageContent } from "../utils/strings.js";
//check if the bot is pinged by someone //check if the bot is pinged by someone
@ -11,7 +11,7 @@ const answers = [
'https://tenor.com/view/casse-fracasse-chabal-destroy-mur-gif-21656168' 'https://tenor.com/view/casse-fracasse-chabal-destroy-mur-gif-21656168'
]; ];
export default class PingDetector extends Detector { export default class PingDetector extends detector {
triggerName = 'mention'; triggerName = 'mention';
//prevent trigger if user is doing a troll on its own //prevent trigger if user is doing a troll on its own

View file

@ -1,4 +1,4 @@
import Detector from "./Detector.js"; import detector from "./detector.js";
import { cleanMessageContent } from "../utils/strings.js"; import { cleanMessageContent } from "../utils/strings.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"
@ -14,7 +14,7 @@ const answers = [
]; ];
export default class QuoicoubehDetector extends Detector { export default class QuoicoubehDetector extends detector {
triggerName = 'quoicoubeh'; triggerName = 'quoicoubeh';
detect(message) { detect(message) {

View file

@ -1,4 +1,4 @@
import Detector from "./Detector.js"; import detector from "./detector.js";
import { cleanMessageContent } from "../utils/strings.js"; import { cleanMessageContent } from "../utils/strings.js";
const suffixes = [ const suffixes = [
@ -6,7 +6,7 @@ const suffixes = [
...Array(10).fill('') ...Array(10).fill('')
]; ];
export default class SuffixPrefixDetector extends Detector { export default class SuffixPrefixDetector extends detector {
async createSpecificReply(message) { async createSpecificReply(message) {
const reference = await message.fetchReference().catch(() => null); const reference = await message.fetchReference().catch(() => null);
const isSelfTarget = (reference && reference.author.id === message.client.user?.id) ?? false; const isSelfTarget = (reference && reference.author.id === message.client.user?.id) ?? false;

View file

@ -1,4 +1,4 @@
import Detector from "./Detector.js"; 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";
@ -15,7 +15,7 @@ const suffixes = [
'', '', '' '', '', ''
]; ];
export default class withPronounDetector extends Detector { export default class withPronounDetector extends detector {
async createSpecificReply(message) { async createSpecificReply(message) {
const reference = await message.fetchReference().catch(() => null); const reference = await message.fetchReference().catch(() => null);
const isSelfTarget = (reference && reference.author.id === message.client.user?.id) ?? false; const isSelfTarget = (reference && reference.author.id === message.client.user?.id) ?? false;