From 685c94bd0113df701c860f104914ac3381629b1f Mon Sep 17 00:00:00 2001 From: Anand S <36130650+ClobberXD@users.noreply.github.com> Date: Thu, 19 Apr 2018 20:01:55 +0530 Subject: [PATCH 1/5] Removes *all* white-spaces from message this to ensure players can't get around this mod by adding spaces between words (e.g. "f uck") --- init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 51fe8f9..a39654d 100644 --- a/init.lua +++ b/init.lua @@ -62,8 +62,9 @@ function filter.register_on_violation(func) end function filter.check_message(name, message) + local trimmed_msg = message:gsub(" ","") for _, w in ipairs(words) do - if string.find(message:lower(), "%f[%a]" .. w .. "%f[%A]") then + if string.find(trimmed_msg:lower(), "%f[%a]" .. w .. "%f[%A]") then return false end end From 34f0be2f9f5432fd1b2a280a329371c67b066d4b Mon Sep 17 00:00:00 2001 From: Anand S <36130650+ClobberXD@users.noreply.github.com> Date: Thu, 19 Apr 2018 20:45:59 +0530 Subject: [PATCH 2/5] Added priv check before un-muting player Unmutes player _only_ if the player is still muted --- init.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index a39654d..6d0e96b 100644 --- a/init.lua +++ b/init.lua @@ -85,11 +85,12 @@ function filter.mute(name, duration) minetest.after(duration * 60, function() muted[name] = nil - minetest.chat_send_player(name, "Chat privilege reinstated. Please do not abuse chat.") - local privs = minetest.get_player_privs(name) - privs.shout = true - minetest.set_player_privs(name, privs) + if privs.shout == false then + minetest.chat_send_player(name, "Chat privilege reinstated. Please do not abuse chat.") + privs.shout = true + minetest.set_player_privs(name, privs) + end end) end From e9df5c87c115219be950ac9b1ee212187f1ae9a9 Mon Sep 17 00:00:00 2001 From: Anand S <36130650+ClobberXD@users.noreply.github.com> Date: Fri, 20 Apr 2018 11:48:41 +0530 Subject: [PATCH 3/5] Highlighted mute and un-mute messages --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 6d0e96b..ecb2ac5 100644 --- a/init.lua +++ b/init.lua @@ -79,7 +79,7 @@ function filter.mute(name, duration) minetest.set_player_privs(name, privs) end - minetest.chat_send_player(name, "Watch your language! You have been temporarily muted") + minetest.chat_send_player(name, minetest.colorize("#FF8C00","Watch your language! You have been temporarily muted")) muted[name] = true @@ -87,7 +87,7 @@ function filter.mute(name, duration) muted[name] = nil local privs = minetest.get_player_privs(name) if privs.shout == false then - minetest.chat_send_player(name, "Chat privilege reinstated. Please do not abuse chat.") + minetest.chat_send_player(name, minetest.colorize("#FF8C00","Chat privilege reinstated. Please do not abuse chat.")) privs.shout = true minetest.set_player_privs(name, privs) end From 53312940c0cd75a6ad70b40a195764eec6b92344 Mon Sep 17 00:00:00 2001 From: Anand S <36130650+ClobberXD@users.noreply.github.com> Date: Fri, 20 Apr 2018 12:17:56 +0530 Subject: [PATCH 4/5] Reverted all changes Will make dedicated branch for each commit --- init.lua | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/init.lua b/init.lua index ecb2ac5..a980c1c 100644 --- a/init.lua +++ b/init.lua @@ -1,9 +1,6 @@ - --[[ - Copyright 2017-8 Auke Kok Copyright 2018 rubenwardy - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including @@ -11,10 +8,8 @@ distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -22,7 +17,6 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ]]-- filter = { registered_on_violations = {} } @@ -62,9 +56,8 @@ function filter.register_on_violation(func) end function filter.check_message(name, message) - local trimmed_msg = message:gsub(" ","") for _, w in ipairs(words) do - if string.find(trimmed_msg:lower(), "%f[%a]" .. w .. "%f[%A]") then + if string.find(message:lower(), "%f[%a]" .. w .. "%f[%A]") then return false end end @@ -79,18 +72,17 @@ function filter.mute(name, duration) minetest.set_player_privs(name, privs) end - minetest.chat_send_player(name, minetest.colorize("#FF8C00","Watch your language! You have been temporarily muted")) + minetest.chat_send_player(name, "Watch your language! You have been temporarily muted") muted[name] = true minetest.after(duration * 60, function() muted[name] = nil + minetest.chat_send_player(name, "Chat privilege reinstated. Please do not abuse chat.") + local privs = minetest.get_player_privs(name) - if privs.shout == false then - minetest.chat_send_player(name, minetest.colorize("#FF8C00","Chat privilege reinstated. Please do not abuse chat.")) - privs.shout = true - minetest.set_player_privs(name, privs) - end + privs.shout = true + minetest.set_player_privs(name, privs) end) end From 3224270932bbdd98f995c38dafc4ed788800bd21 Mon Sep 17 00:00:00 2001 From: Anand S <36130650+ClobberXD@users.noreply.github.com> Date: Fri, 20 Apr 2018 12:40:50 +0530 Subject: [PATCH 5/5] Highlighted player mute and un-mute messages --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index a980c1c..cc0794f 100644 --- a/init.lua +++ b/init.lua @@ -72,13 +72,13 @@ function filter.mute(name, duration) minetest.set_player_privs(name, privs) end - minetest.chat_send_player(name, "Watch your language! You have been temporarily muted") + minetest.chat_send_player(name, minetest.colorize("#FF8C00","Watch your language! You have been temporarily muted")) muted[name] = true minetest.after(duration * 60, function() muted[name] = nil - minetest.chat_send_player(name, "Chat privilege reinstated. Please do not abuse chat.") + minetest.chat_send_player(name, minetest.colorize("#FF8C00","Chat privilege reinstated. Please do not abuse chat.")) local privs = minetest.get_player_privs(name) privs.shout = true