From 4594eaadabba50e3f48f3c8df7d6af79305f0042 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Mon, 21 Dec 2015 17:44:12 +0100 Subject: [PATCH] [report] Add the report mod - For #340 --- mods/report/README.md | 12 ++++++++++++ mods/report/depends.txt | 1 + mods/report/init.lua | 36 ++++++++++++++++++++++++++++++++++ worlds/minetestforfun/world.mt | 1 + 4 files changed, 50 insertions(+) create mode 100644 mods/report/README.md create mode 100644 mods/report/depends.txt create mode 100644 mods/report/init.lua diff --git a/mods/report/README.md b/mods/report/README.md new file mode 100644 index 00000000..91f3a79a --- /dev/null +++ b/mods/report/README.md @@ -0,0 +1,12 @@ +# Report + +Allows players to report things to admins and online moderators. + +Suppose `player`, `griefer` and `moderator` are online players. +`player` runs this command: `/report griefer is griefing` +`moderator` sees: `-!- player reported: griefer is griefing` +The Admin (named in "name") is mailed via chatplus: ` Report: player2 is griefing (mods online: player3)` + +License: WTFPL +Depends: chatplus. + diff --git a/mods/report/depends.txt b/mods/report/depends.txt new file mode 100644 index 00000000..7df2c284 --- /dev/null +++ b/mods/report/depends.txt @@ -0,0 +1 @@ +email diff --git a/mods/report/init.lua b/mods/report/init.lua new file mode 100644 index 00000000..3864fb25 --- /dev/null +++ b/mods/report/init.lua @@ -0,0 +1,36 @@ +minetest.register_chatcommand("report", { + func = function(name, param) + param = param:trim() + if param == "" then + return false, "Please add a message to your report. " .. + "If it's about (a) particular player(s), please also include their name(s)." + end + local _, count = string.gsub(param, " ", "") + if count == 0 then + minetest.chat_send_player(name, "If you're reporting a player, " .. + "you should also include a reason why. (Eg: swearing, sabotage)") + end + + -- Send to online moderators / admins + -- Get comma separated list of online moderators and admins + local mods = {} + for _, player in pairs(minetest.get_connected_players()) do + local name = player:get_player_name() + if minetest.check_player_privs(name, {kick = true, ban = true}) then + table.insert(mods, name) + minetest.chat_send_player(name, "-!- " .. name .. " reported: " .. param) + end + end + + if #mods > 0 then + mod_list = table.concat(mods, ", ") + email.send_mail(name, minetest.setting_get("name"), + "Report: " .. param .. " (mods online: " .. mod_list .. ")") + return true, "Reported. Moderators currently online: " .. mod_list + else + email.send_mail(name, minetest.setting_get("name"), + "Report: " .. param .. " (no mods online)") + return true, "Reported. We'll get back to you." + end + end +}) diff --git a/worlds/minetestforfun/world.mt b/worlds/minetestforfun/world.mt index d58a4379..bb0bb71d 100755 --- a/worlds/minetestforfun/world.mt +++ b/worlds/minetestforfun/world.mt @@ -220,6 +220,7 @@ load_mod_beds = true load_mod_builtin_item = true load_mod_chatplus = true load_mod_email = true +load_mod_report = true load_mod_snowdrift = false load_mod_snow = true