mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-02-24 15:00:26 +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
|
email
|
||||||
|
action_timers
|
||||||
unified_inventory?
|
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", {
|
minetest.register_chatcommand("report", {
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
param = param:trim()
|
param = param:trim()
|
||||||
@ -10,28 +37,7 @@ minetest.register_chatcommand("report", {
|
|||||||
minetest.chat_send_player(name, "If you're reporting a player, " ..
|
minetest.chat_send_player(name, "If you're reporting a player, " ..
|
||||||
"you should also include a reason why. (Eg: swearing, sabotage)")
|
"you should also include a reason why. (Eg: swearing, sabotage)")
|
||||||
end
|
end
|
||||||
|
return action_timers.wrapper(name, "report", "report_" .. name, 600, report.send, {name, param})
|
||||||
-- 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
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -61,21 +67,10 @@ if minetest.get_modpath("unified_inventory") then
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local cmd_def = core.chatcommands["report"]
|
|
||||||
if not cmd_def then
|
local success, message = action_timers.wrapper(name, "report", "report_" .. name, 600, report.send, {name, fields.text})
|
||||||
return
|
if message then
|
||||||
end
|
core.chat_send_player(name, message)
|
||||||
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, ", ") .. ")")
|
|
||||||
end
|
end
|
||||||
return true -- Handled fields reception
|
return true -- Handled fields reception
|
||||||
end)
|
end)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user