mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-11-11 04:50:17 +01:00
add action_timers for report mod and rewrite code
This commit is contained in:
parent
cc0546b9e3
commit
629e877970
|
@ -1,2 +1,3 @@
|
|||
email
|
||||
action_timers
|
||||
unified_inventory?
|
||||
|
|
|
@ -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,22 +67,11 @@ 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)
|
||||
|
||||
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
|
||||
else
|
||||
core.chat_send_player(name, "You don't have permission"
|
||||
.. " to run this command (missing privileges: "
|
||||
.. table.concat(missing_privs, ", ") .. ")")
|
||||
end
|
||||
return true -- Handled fields reception
|
||||
end)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user