// import LanguageDetect from 'languagedetect'
//
// const lngDetector = new LanguageDetect();

/**
 * This function determines whether a given message can be classified as spam.
 *
 * A message is classified as spam based on the following criteria:
 *   1. The message contains a URL i.e., it includes `https://`.
 *   2. The message is not written in the German language.
 *   3. The message contains the domain name dreikoenige.berlin
 *   4. The message contains the dollar sign
 *
 * Returns a boolean value indicating whether the message is spam (`true`) or not (`false`).
 */
export const isSpam = (message: string): boolean => {

  const trimmed = message.trim();
  if (trimmed.length < 10 || trimmed.split(/\s+/).length < 5) {
    return true;
  }

  if (message.includes('dreikoenige.berlin')) {
    return true;
  }

  // if (message.includes('https://') || message.includes('http://') || message.includes('$') || message.includes('www')) {
  //     const language = lngDetector.detect(message.substring(0, 400))[0][0];
  //     return language !== 'german';
  // }

  if (message.includes('https://') || message.includes('http://') || message.includes('$') || message.includes('www')) {
      return true;
  }

  return false;
}