Okay, so you want profanity filter. Let’s get started.
Filtering can be easy but in reality no
People will separate letters or replace them with modified fonts to bypass detection, and even may send multiple messages in order to form a bad word (this is also includes text art). They can even use other languages and encryption. Which is very annoying and hard to prevent, but I will list some ways that can improve detection.
Remove all non-alphabetic characters
You want to replace all characters except alphabetical ones, as this will remove special characters, numbers, bypassed fonts, and many more. This will improve detection, there is a way around this but it’s still good to do it.
Make entire string lowercased/uppercase
Obvious one, but it will prevent people from using lowercased and uppercased characters in order to bypass the detection.
Use regular expressions
This one is really good one, since we can detect by patterns.
Use artificial intelligence
A modern and growing technology. You can train AI to detect bad stuff almost like a human. This one would be very good but would take time to train.
Filter it out by list of bad words from array
Old good method but easy to bypass.
When and where I should filter string?
There is two ways.
Filter string on server before sending to other clients
Good one, since we can keep database clean out of bad words, however if server gets hacked, hacker can send bad stuff.
Filter string on client before showing it to user
Really good one, since even if hacker hacks into server, or someone bypasses filtering on their client, other clients will still have non-hacked filtering system and theirs will work just fine.
But turns out, you can’t prevent it at all. It’s constant battle.
Also, don’t overfilter, this is coming from someone who pasted google’s entire bad world filter into a mee6 discord bot. Our school server couldn’t tolerate it for more than 5 minutes
Things that happens at my school.
School admins: blocks websites
Developers: makes an exact clone of the websites but better and gets payed $1 from almost everyone
School admins: I will block that too
Developers: Clones the website 100K+ times gets payed $10 from everyone
I was a developer once, but I almost got caught for something WAY worse, selling some stuff while people payed me and I didn’t ask for it. So I stopped.
we had a keyboard with an ‘open calculator’ button, he spammed it 3000 times and on the old CPU’s- after 1000 it gets really laggy. Then itt overheated and blew up
so the technician came in, took it away without blinking. Few weeks later new computers were brought in with nvidia graphics cards. (needed, as it was 3d design)