diff options
-rw-r--r-- | depends.txt | 1 | ||||
-rw-r--r-- | init.lua | 30 |
2 files changed, 27 insertions, 4 deletions
diff --git a/depends.txt b/depends.txt index 20efb18..7dd5e6f 100644 --- a/depends.txt +++ b/depends.txt @@ -1 +1,2 @@ irc? +notice? @@ -1,8 +1,30 @@ +caps_message_count={} + +minetest.register_on_joinplayer(function(player) + local player_name = player:get_player_name() + caps_message_count[player_name] = 0 +end) + +minetest.register_on_leaveplayer(function(player) + local player_name = player:get_player_name() + caps_message_count[player_name] = nil +end) + minetest.register_on_chat_message(function(name, message) if message:len()>16 and message:lower()~=message and message:upper()==message then - minetest.kick_player(name,"Sending all-caps messages is not allowed") - minetest.chat_send_all(string.format("* %s was kicked for sending an all-caps message.",name)) - if minetest.get_modpath("irc") then irc:say(string.format("* %s was kicked for sending an all-caps message.",name)) end - minetest.log("action", string.format("Kicked %s for sending an all-caps message",name)) + caps_message_count[name] = caps_message_count[name] + 1 + if caps_message_count[name]>=3 then + minetest.kick_player(name,"Sending all-caps messages is not allowed.") + minetest.chat_send_all(string.format("* %s was kicked for sending too many all-caps messages.",name)) + if minetest.get_modpath("irc") then irc:say(string.format("* %s was kicked for sending too many all-caps messages.",name)) end + minetest.log("action", string.format("Kicked %s for sending too many all-caps messages",name)) + else + if minetest.get_modpath("notice") then + notice.send(name,"Sending all-caps messages is not allowed") + else + minetest.chat_send_player(name,"Sending all-caps messages is not allowed.") + end + minetest.log("action",string.format("%s was warned for sending an all-caps message (%u so far)",name,caps_message_count[name])) + end end end) |