From bbc0fb55c69a7234aff93e4155053c32c9c06342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20P=C3=A9rez-Cerezo?= Date: Sun, 23 Sep 2018 16:09:44 +0200 Subject: Added option to add notes to criminal record, map ip to time The option to map IP address to time will make it easier to delete personal information after a certain time, since the IP records can be expired after a certain time if the player has commited no large infractions. Also, this would prevent players with dynamic IP addresses from being accidentally banned because of a previous owner. --- init.lua | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 24dab44..0f816d2 100644 --- a/init.lua +++ b/init.lua @@ -107,7 +107,7 @@ function xban.ban_player(player, source, expires, reason) --> bool, err if pl then local ip = minetest.get_player_ip(player) if ip then - e.names[ip] = true + e.names[ip] = os.time() end e.last_pos = pl:getpos() end @@ -229,7 +229,7 @@ minetest.register_on_joinplayer(function(player) end e.names[name] = true if ip then - e.names[ip] = true + e.names[ip] = os.time() end e.last_seen = os.time() end) @@ -268,6 +268,29 @@ minetest.register_chatcommand("xtempban", { end, }) +minetest.register_chatcommand("xnote", { + description = "Add a note to a player's criminal record", + params = " ", + privs = { kick=true }, + func = function(name, params) + local plname, note = params:match("(%S+)%s+(.+)") + if not (plname and note) then + return false, "Usage: /xnote " + end + local record = { + source = name, + time = os.time(), + expires = nil, + reason = note, + type = "note", + } + xban.add_record(plname, record) + return true, ("Added note for %s."):format(plname) + end, +}) + + + minetest.register_chatcommand("xunban", { description = "XUnBan a player", params = " ", -- cgit v1.2.3