Apps Home
|
Create an App
SpamFilter
Author:
katycrimesdev
Description
Source Code
Launch App
Current Users
Created by:
Katycrimesdev
//Settings cb.settings_choices = [ { name: "phrase1", type: "str", minLength: 10, MaxLength: 100, defaultValue: "Free real sex ! This site ~ sexgirls.me", label: "Phrase One (will automatically kick and ban users who use these phrases)", }, { name: "pct1", type: "int", minValue: 0, MaxValue: 100, defaultValue: 0, label: "Similarity (How closely does a chat message need to match the phrase for the user to get banned, where 0 is only the exact phrase and 100 will also ban users whose messages have at least 3 words in sequence from the phrase) " }, { name: "phrase2", type: "str", minLength: 10, MaxLength: 100, defaultValue: "🍓", label: "Phrase Three ", allowNull: true, }, { name: "pct2", type: "int", minValue: 0, MaxValue: 100, default: 0, label: "Similarity (Phrase Two)", }, { name: "phrase3", type: "str", minLength: 10, MaxLength: 100, label: "Phrase Three ", allowNull: true, }, { name: "pct3", type: "int", minValue: 0, MaxValue: 100, default: 0, label: "Similarity (Phrase Three)" }, { name: "phrase4", type: "str", minLength: 10, MaxLength: 100, label: "Phrase Four ", }, { name: "pct4", type: "int", minValue: 0, MaxValue: 100, default: 0, label: "Similarity (Phrase Four)" }, { name: "phrase5", type: "str", minLength: 10, MaxLength: 100, label: "Phrase Five", }, { name: "pct5", type: "int", minValue: 0, MaxValue: 100, default: 0, label: "Similarity (Phrase Five)" }, { name: "phrase6", type: "str", minLength: 1, maxLength: 100, label: "Phrase Six", }, { name: "pct6", type: "int", minValue: 0, MaxValue: 100, default: 0, label: "Similarity (Phrase Six)" }, ]; //Handlers cb.onMessage(function (message) { for (let i = 0; i < 7; i++) { let phrase = cb.settings[`phrase${i}`] let similarity = cb.settings[`pct${i}`] // let isTrue = isSpam(message['m'], phrase, similarity) if(isSpam(message['m'], phrase, similarity)) { message['X-Spam'] = true; message['m'] = `I was a spam message but now i'm a heart emoji: <3` } } return message }) var isSpam = function (message, phrase, similarity) { let phraseArray let percentage = (similarity/2 + 50) / 100 if(typeof phrase === 'string') { phraseArray = phrase.split(' ') let wordLimit = Math.floor(phraseArray.length * percentage) let wordCount = 0; for (let i = 0; i < wordLimit; i++) { if(message.includes(phraseArray[i])) { wordCount++ if(wordCount >= wordLimit) { return true } } } } return false }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.