Restricted word list

How would I go about making a restricted word list better? I am starting on a huge table but realize that this method is very un-clean and open to bypassing. If at all possible I would also like to check for variants of the same word such as (Facepunch, facepunch, FACEPUNCH, etc) all returning the same thing but only needing one variant in a table.

So far I have started off with

--- Restricted Usernames ---
local restricted = {}

But this is going to get quite large and is unwanted. Any suggestions?

I have just thought of putting all restricted words in a .txt file named restricted.txt and placing in DATA, then in lua read the file line by line and match each string w/ some filtering. This would clean up my lua by a lot :smiley: But now the question comes to catching variants of the same word. I could just grab a restricted word list from an open IRC and call it finished but I want this to be tailored to my server needs.

Use CheckPassword hook and check if the name is equal (or has) to the restricted names then kick them if it matches else, let them through.

To compare 2 strings regardless of case, it would be easier to convert both strings to either to all UPPERCASE or lowercase.

Typed on a phone so I wouldnt use this directly, just the concept.

local Restricted = {
"username", "password", "whatever" -- All lowercase

local function CheckAllowed(str)
 for k, v in pairs(Restricted) do -- loop through our table
      local str2 = string.lower(str) -- Lowercase the thing we are checking, so we compare lowercase to lowercase
      if str2 == v then  -- If the lowercase Str matches anything restricted then
          -- do whatever

I have a system for this. You can even set how far off the name can be ( as in how many % of the bad word exists in the word being checked )…

Using JSON FlatFile:

Using NewLine FlatFile:

Hopefully these tutorials and information helps. As always, to view the Lua from any of my tutorials to enable copy/pasting ( HTML doesn’t copy/paste well in terms of HTML / CSS Highlighted Lua ), remove .html from the url.

When users connect, you may want to explode by " " and go through each word. The percent system is how much of the banned word takes up the checked word. Example: ess from chess would return 60% or from the returned value of 0.6… Each word is compared to each banned word. I don’t think I set the system up so each word can have its own percentage to exist, but I may add it sometime in the future for my admin system.

Hey just got home from worked, these are all great responses and work wonders! Thanks Facepunch :smiley: