init.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. anticurse = {}
  2. anticurse.logpath = minetest.get_worldpath() .. "/cursing.txt"
  3. anticurse.logfile = io.open(anticurse.logpath, "a+")
  4. minetest.register_on_shutdown(function()
  5. if anticurse.logfile then
  6. anticurse.logfile:flush()
  7. anticurse.logfile:close()
  8. end
  9. end)
  10. -- Make these live-reloadable.
  11. if minetest.get_modpath("reload") then
  12. local path = minetest.get_modpath("anticurse")
  13. reload.register_file("anticurse:kick_msg", path .. "/kick_msg.lua")
  14. reload.register_file("anticurse:foul_db", path .. "/bad-language.lua")
  15. reload.register_file("anticurse:curse_db", path .. "/other-language.lua")
  16. reload.register_file("anticurse:core", path .. "/check-string.lua")
  17. reload.register_file("anticurse:api", path .. "/api.lua")
  18. else
  19. local path = minetest.get_modpath("anticurse")
  20. dofile(path .. "/kick_msg.lua")
  21. dofile(path .. "/bad-language.lua")
  22. dofile(path .. "/other-language.lua")
  23. dofile(path .. "/check-string.lua")
  24. dofile(path .. "/api.lua")
  25. end
  26. minetest.register_privilege("anticurse_bypass", {
  27. description = "Player's chat will not be scanned for cursing.",
  28. give_to_singleplayer = true,
  29. })
  30. minetest.register_on_prejoinplayer(function(pname, ip)
  31. if rename.name_currently_allocated(pname) then
  32. return "That name is currently allocated by someone else!"
  33. end
  34. return anticurse.on_prejoinplayer(pname, ip)
  35. end)