diff --git a/init.lua b/init.lua index b54f72a..d556f74 100755 --- a/init.lua +++ b/init.lua @@ -28,7 +28,13 @@ local S = minetest.get_translator("filter") filter = { registered_on_violations = {} } -local utf8 = require 'lua-utf8' +local ie = core.request_insecure_environment() +local str = nil +if ie then + str = ie.require("lua-utf8") +else + str = string +end local words = {} local muted = {} local violations = {} @@ -66,7 +72,7 @@ end function filter.check_message(name, message) for _, w in ipairs(words) do - if utf8.find(utf8.lower(message), "%f[%a]" .. w .. "%f[%A]") then + if str.find(str.lower(message), "%f[%a]" .. w .. "%f[%A]") then return false end end diff --git a/readme.md b/readme.md index 27293e2..7d5b7cc 100644 --- a/readme.md +++ b/readme.md @@ -13,6 +13,8 @@ muted for 1 minute. After that, their `shout` privilege is restored. If they leave, their `shout` privilege is still restored, but only after the time expires, not before. +Add this mod to `secure.trusted_mods` to allow filtering utf8 lines. + ## API ### Callbacks