capturetheflag/mods/report/init.lua

41 lines
1.4 KiB
Lua
Raw Normal View History

2015-12-18 01:50:19 +00:00
if not chatplus.send_mail then
error("You need to update chatplus!")
end
2015-12-07 23:28:50 +00:00
minetest.register_chatcommand("report", {
func = function(name, param)
2015-12-18 01:50:19 +00: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
-- Send to online moderators / admins
-- Get comma separated list of online moderators and admins
local mods = {}
2015-12-07 23:28:50 +00:00
for _, player in pairs(minetest.get_connected_players()) do
2015-12-30 13:43:09 +00:00
local pname = player:get_player_name()
if minetest.check_player_privs(pname, {kick = true, ban = true}) then
table.insert(mods, pname)
minetest.chat_send_player(pname, "-!- " .. name .. " reported: " .. param)
2015-12-07 23:28:50 +00:00
end
end
2015-12-18 01:50:19 +00:00
if #mods > 0 then
mod_list = table.concat(mods, ", ")
chatplus.send_mail(name, minetest.setting_get("name"),
"Report: " .. param .. " (mods online: " .. mod_list .. ")")
return true, "Reported. Moderators currently online: " .. mod_list
else
chatplus.send_mail(name, minetest.setting_get("name"),
"Report: " .. param .. " (no mods online)")
return true, "Reported. We'll get back to you."
2015-12-07 23:28:50 +00:00
end
end
})