report/init.lua

37 lines
1.3 KiB
Lua
Raw Normal View History

2015-12-11 18:45:32 +01:00
minetest.register_chatcommand("report", {
func = function(name, param)
2015-12-18 05:11:11 +01:00
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
2015-12-11 18:45:32 +01:00
-- Send to online moderators / admins
-- Get comma separated list of online moderators and admins
2015-12-18 05:11:11 +01:00
local mods = {}
2015-12-11 18:45:32 +01:00
for _, player in pairs(minetest.get_connected_players()) do
local toname = player:get_player_name()
if minetest.check_player_privs(toname, {kick = true, ban = true}) then
table.insert(mods, toname)
minetest.chat_send_player(toname, "-!- " .. name .. " reported: " .. param)
2015-12-11 18:45:32 +01:00
end
end
2015-12-18 05:11:11 +01:00
if #mods > 0 then
mod_list = table.concat(mods, ", ")
2015-12-18 23:34:14 +01:00
email.send_mail(name, minetest.setting_get("name"),
2015-12-18 05:11:11 +01:00
"Report: " .. param .. " (mods online: " .. mod_list .. ")")
return true, "Reported. Moderators currently online: " .. mod_list
else
2015-12-18 23:34:14 +01:00
email.send_mail(name, minetest.setting_get("name"),
2015-12-18 05:11:11 +01:00
"Report: " .. param .. " (no mods online)")
return true, "Reported. We'll get back to you."
2015-12-11 18:45:32 +01:00
end
end
})