init.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. banned_names = banned_names or {}
  2. banned_names.modpath = minetest.get_modpath("banned_names")
  3. -- Public API function.
  4. -- Returns true if name is all numeric, otherwise returns false.
  5. banned_names.all_numeric = function(pname)
  6. if string.find(pname, "^%d+$") then
  7. return true
  8. end
  9. return false
  10. end
  11. banned_names.guest_name = function(pname)
  12. -- Mobile users make up most traffic. We probably shouldn't do this.
  13. ---[[
  14. -- Names typically generated by tablet clients when the user hasn't
  15. -- actually entered anything in the name field.
  16. if string.find(pname, "^[A-Z][a-z]+%d%d%d$") or
  17. -- Anything with `guest` in it.
  18. string.find(pname, "[Gg][Uu][Ee][Ss][Tt]") then
  19. return true
  20. end
  21. --]]
  22. return false
  23. end
  24. -- Returns `true` if the name is reserved for server usage.
  25. -- (Such as special names used in code.)
  26. banned_names.reserved_name = function(pname)
  27. local lower = string.lower(pname)
  28. -- Used for server emails, server ownership, etc.
  29. -- Also for public beds.
  30. if lower == "server" then
  31. return true
  32. end
  33. -- Used as the dummy value for string metadata.
  34. if lower == "dummy" then
  35. return true
  36. end
  37. -- No devil numbers.
  38. if string.find(pname, "666+") then
  39. return true
  40. end
  41. return false
  42. end
  43. -- One-time only code.
  44. if not banned_names.run_once then
  45. local c = "banned_names:core"
  46. local f = banned_names.modpath .. "/init.lua"
  47. reload.register_file(c, f, false)
  48. banned_names.run_once = true
  49. end