init.lua 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. --No griefers
  25. string.find(pname, "[Gg][Rr][Ii][Ee][Ff][Ee][Rr]") then
  26. return true
  27. end
  28. --]]
  29. return false
  30. end
  31. -- Returns `true` if the name is reserved for server usage.
  32. -- (Such as special names used in code.)
  33. banned_names.reserved_name = function(pname)
  34. local lower = string.lower(pname)
  35. -- Used for server emails, server ownership, etc.
  36. -- Also for public beds.
  37. if lower == "server" then
  38. return true
  39. end
  40. -- Used as the dummy value for string metadata.
  41. if lower == "dummy" then
  42. return true
  43. end
  44. -- No devil numbers.
  45. if string.find(pname, "666+") then
  46. return true
  47. end
  48. return false
  49. end
  50. -- One-time only code.
  51. if not banned_names.run_once then
  52. local c = "banned_names:core"
  53. local f = banned_names.modpath .. "/init.lua"
  54. reload.register_file(c, f, false)
  55. banned_names.run_once = true
  56. end