<commit_before>-- name_restrictions mod by ShadowNinja
-- License: WTFPL

----------------------------
-- Restriction exemptions --
----------------------------
-- For legitimate player names that are caught by the filters.

local exemptions = {}
local temp = minetest.setting_get("name_restrictions.exemptions")
temp = temp and temp:split() or {}
for _, allowed_name in pairs(temp) do
	exemptions[allowed_name] = true
end
temp = nil
-- Exempt server owner
exemptions[minetest.setting_get("name")] = true
exemptions["singleplayer"] = true

local disallowed_names = {}
local file = io.open(minetest.get_worldpath("name_restrictions") .. "/forbidden_names.txt", "r")
if file then
	for line in file:lines() do
		local low_line = line:lower()
		disallowed_names[low_line] = true
	end
	file:close()
end

---------------------
-- Simple matching --
---------------------

local disallowed = {
	["^guest[0-9]+"] = "Guest accounts are disallowed on this server." ..
	                   " Please choose a proper name and try again.",
	["[4a]dm[1il]n"] = "Misleading name." ..<commit_msg>[name_restrictions] Add other guest patterns<commit_after>-- name_restrictions mod by ShadowNinja
-- License: WTFPL

----------------------------
-- Restriction exemptions --
----------------------------
-- For legitimate player names that are caught by the filters.

local exemptions = {}
local temp = minetest.setting_get("name_restrictions.exemptions")
temp = temp and temp:split() or {}
for _, allowed_name in pairs(temp) do
	exemptions[allowed_name] = true
end
temp = nil
-- Exempt server owner
exemptions[minetest.setting_get("name")] = true
exemptions["singleplayer"] = true

local disallowed_names = {}
local file = io.open(minetest.get_worldpath("name_restrictions") .. "/forbidden_names.txt", "r")
if file then
	for line in file:lines() do
		local low_line = line:lower()
		disallowed_names[low_line] = true
	end
	file:close()
end

---------------------
-- Simple matching --
---------------------

local disallowed = {
	["^guest[0-9]+"] = "Guest accounts are disallowed on this server." ..
	                   " Please choose a proper name and try again.",
	["^sadie[0-9]+"] = "Guest accounts are disallowed on this server." ..
			   " Please choose a proper name (and client) and try again.",
	["^player[0-9]+"] = "Guest accounts are disallowed on this server." ..
			   " Please choose a proper name (and client) and try again.",
	["[4a]dm[1il]n"] = "Misleading name." ..
{'fraction_non_alphanumeric': 0.19983753046303818, 'fraction_numerical': 0.00487408610885459, 'mean_word_length': 2.76030534351145, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1532690', 'n_tokens_mistral': 757, 'n_tokens_neox': 731, 'n_words': 224}