fix: improve spam detection
This commit is contained in:
parent
f85c50757d
commit
e269bac979
1 changed files with 7 additions and 1 deletions
|
|
@ -6,16 +6,22 @@ import LanguageDetect from 'languagedetect'
|
|||
* 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 => {
|
||||
|
||||
if (message.includes('https://')) {
|
||||
if (message.includes('https://') || message.includes('http://') || message.includes('$')) {
|
||||
const lngDetector = new LanguageDetect();
|
||||
const language = lngDetector.detect(message)[0][0];
|
||||
return language !== 'german';
|
||||
}
|
||||
|
||||
if (message.includes('dreikoenige.berlin')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
Loading…
Reference in a new issue