1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-09-21 20:20:18 +02:00

add action_timers for report mod and rewrite code

This commit is contained in:
crabman77 2015-12-23 22:53:59 +01:00
parent cc0546b9e3
commit 629e877970
2 changed files with 33 additions and 37 deletions

View File

@ -1,2 +1,3 @@
email
action_timers
unified_inventory?

View File

@ -1,3 +1,30 @@
report = {}
function report.send(sender, message)
-- 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, "-!- " .. sender .. " reported: " .. message)
end
end
if #mods > 0 then
local mod_list = table.concat(mods, ", ")
email.send_mail(sender, minetest.setting_get("name"),
"Report: " .. message .. " (mods online: " .. mod_list .. ")")
return true, "Reported. Moderators currently online: " .. mod_list
else
email.send_mail(sender, minetest.setting_get("name"),
"Report: " .. message .. " (no mods online)")
return true, "Reported. We'll get back to you."
end
end
minetest.register_chatcommand("report", {
func = function(name, param)
param = param:trim()
@ -10,28 +37,7 @@ minetest.register_chatcommand("report", {
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
local 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
return action_timers.wrapper(name, "report", "report_" .. name, 600, report.send, {name, param})
end
})
@ -61,21 +67,10 @@ if minetest.get_modpath("unified_inventory") then
return
end
local name = player:get_player_name()
local cmd_def = core.chatcommands["report"]
if not cmd_def then
return
end
local has_privs, missing_privs = core.check_player_privs(name, cmd_def.privs)
if has_privs then
core.set_last_run_mod(cmd_def.mod_origin)
local success, message = cmd_def.func(name, fields.text)
if message then
core.chat_send_player(name, message)
end
else
core.chat_send_player(name, "You don't have permission"
.. " to run this command (missing privileges: "
.. table.concat(missing_privs, ", ") .. ")")
local success, message = action_timers.wrapper(name, "report", "report_" .. name, 600, report.send, {name, fields.text})
if message then
core.chat_send_player(name, message)
end
return true -- Handled fields reception
end)