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 From 563e0a7bca093aae8ddc0e1af73083b406b809f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20P=C3=A9rez-Cerezo?= Date: Sun, 23 Sep 2018 16:49:33 +0200 Subject: Fix wrong time listing in /xban_record, use the same format as gui --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 0f816d2..4e1a997 100644 --- a/init.lua +++ b/init.lua @@ -193,7 +193,7 @@ function xban.get_record(player) if rec.source then msg = msg..", Source: "..rec.source end - table.insert(record, ("[%s]: %s"):format(os.date("%c", e.time), msg)) + table.insert(record, ("[%s]: %s"):format(os.date("%Y-%m-%d %H:%M:%S", rec.time), msg)) end local last_pos if e.last_pos then -- cgit v1.2.3