import detector from "./detector.js";
import { cleanMessageContent } from "../utils/strings.js";

/*check the regex for "quoi"
trigger if it's at the end of the sentence (tu fais quoi)
trigger if it's followed by 1 to 3 words (c'est quoi ça)
skip if in the middle of a long sentence (je sais pas quoi faire demain) 
*/

const answers = [
  ...Array(10).fill('feur'),
  '# feur',
  '||coubeh|| feur'
];

export default class BasicDetector extends detector {
  detect(message) {
    return /(?:^|\b)quoi\b ?\??(\s\S+){0,3}$/i.test(cleanMessageContent(message));
  }

  // randomize answer 
  createSpecificReply(message) {
    if (this.detect(message)) {
      return Promise.resolve(answers[Math.floor(Math.random() * answers.length)]);
    }
    return Promise.resolve(null);
  }
}