Compare commits

...

5 Commits

Author SHA1 Message Date
VanessaE fec00441e0 add minimum minetest version key for contentdb 2020-06-03 13:00:17 -04:00
ChaosWormz 387d52bc8a only block new registrations 2016-10-10 04:38:44 -04:00
Vanessa Ezekowitz 50348f52fa Add "playerxxxx" matches
also make sure all names match from line-start
reduce digits match to 3-or-more (from 4-)
2016-10-10 04:24:40 -04:00
Vanessa Ezekowitz 211b9e5c82 block "squeakecraft*" usernames 2015-05-03 11:35:48 -04:00
Vanessa Ezekowitz 430e6f9fbe first commit of the actual code 2014-02-26 19:22:42 -05:00
2 changed files with 104 additions and 0 deletions

103
init.lua Normal file
View File

@ -0,0 +1,103 @@
local disallowed = {
["^guest"] = "Temporary 'GuestXXXX' usernames are disallowed on this server. "..
"Please choose a proper username and try again.",
["^player"] = "Temporary 'PlayerXXXX' usernames are disallowed on this server. "..
"Please choose a proper username and try again.",
["^squeakecraft"] = "Temporary 'Squeakecraft' usernames are disallowed on this server. "..
"Please choose a proper username and try again.",
["[4a]dm[1il]n"] = "That is a clearly false, misleading, or otherwise disallowed username. "..
"Please choose a unique username and try again.",
["^[0-9]+$"] = "All-numeric usernames are disallowed on this server. "..
"Please choose a proper username and try again.",
["[0-9].-[0-9].-[0-9]"] = "Too many numbers in your username. "..
"Please try again with less than three digits in your username."
}
-- Original implementation (in Python) by sfan5
local function judge(msg)
local numspeakable = 0
local numnotspeakable = 0
local cn = 0
local lastc = '____'
for c in msg:gmatch(".") do
c = c:lower()
if c:find("[aeiou0-9_-]") then
if cn > 2 and not c:find("[0-9]") then
numnotspeakable = numnotspeakable + 1
elseif not c:find("[0-9]") then
numspeakable = numspeakable + 1
end
cn = 0
else
if (cn == 1) and (lastc == c) and (lastc ~= 's') then
numnotspeakable = numnotspeakable + 1
cn = 0
end
if cn > 2 then
numnotspeakable = numnotspeakable + 1
cn = 0
end
if lastc:find("[aeiou]") then
numspeakable = numspeakable + 1
cn = 0
end
if not ((lastc:find("[aipfom]") and c == "r") or (lastc == "c" and c == "h")) then
cn = cn + 1
end
end
lastc = c
end
if cn > 0 then
numnotspeakable = numnotspeakable + 1
end
return (numspeakable >= numnotspeakable)
end
minetest.register_on_prejoinplayer(function(name, ip)
local lname = name:lower()
for re, reason in pairs(disallowed) do
if lname:find(re) and not minetest.auth_table[name] then
return reason
end
end
if #name < 2 then
return "Too short of a username. "..
"Please pick a name with at least two letters and try again."
end
if not judge(name) and #name > 5 then
return "Your username just plain looks like gibberish. "..
"Please pick something readable and try again."
end
end)
minetest.register_on_prejoinplayer(function(name, ip)
local lname = name:lower()
for iname, data in pairs(minetest.auth_table) do
if iname:lower() == lname and iname ~= name then
return "Sorry, someone else is already using this "
.."name, or maybe you mistyped it? Please "
.."check your typing or pick another name."
end
end
end)
minetest.register_chatcommand("choosecase", {
description = "Choose the casing that a player name should have",
params = "<name>",
privs = {server=true},
func = function(name, params)
local lname = params:lower()
local worldpath = minetest.get_worldpath()
for iname, data in pairs(minetest.auth_table) do
if iname:lower() == lname and iname ~= params then
minetest.auth_table[iname] = nil
assert(not iname:find("/"))
os.remove(worldpath.."/players/"..iname)
end
end
minetest.chat_send_player(name, "Done.")
end,
})

1
mod.conf Normal file
View File

@ -0,0 +1 @@
min_minetest_version = 5.2.0