summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2015-08-01 23:04:17 -0500
committercheapie <no-email-for-you@example.com>2015-08-01 23:04:17 -0500
commit54742a6684546ad743c14ae49d8e88f4f02cac0e (patch)
tree881576a1738390defe1bb934029869114ca2f4de
parentc815d74e7e0400a2af3d679cad5c42c61c2efe80 (diff)
downloaddropthecaps-54742a6684546ad743c14ae49d8e88f4f02cac0e.tar
dropthecaps-54742a6684546ad743c14ae49d8e88f4f02cac0e.tar.gz
dropthecaps-54742a6684546ad743c14ae49d8e88f4f02cac0e.tar.bz2
dropthecaps-54742a6684546ad743c14ae49d8e88f4f02cac0e.tar.xz
dropthecaps-54742a6684546ad743c14ae49d8e88f4f02cac0e.zip
Allow 2 messages with all caps before kicking the player
-rw-r--r--depends.txt1
-rw-r--r--init.lua30
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?
diff --git a/init.lua b/init.lua
index 50f3d07..665a031 100644
--- a/init.lua
+++ b/init.lua
@@ -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)