report/init.lua

39 lines
1.4 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, "Veuillez écrire un message pour le rapport. " ..
"Si il s'agit d'un (de) joueur(s) en particulier, veuillez aussi indiquer son (leur) nom(s)."
2015-12-18 05:11:11 +01:00
end
local _, count = string.gsub(param, " ", "")
if count == 0 then
minetest.chat_send_player(name, "Si vous rapportez l'attitude d'un joueur, " ..
"vous devriez aussi dire quelle en est la raison. (Ex: insulte, sabotage)")
2015-12-18 05:11:11 +01:00
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 .. " a rapporté : " .. 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"),
"Rapport: " .. param .. " (modos connecté(s) : " .. mod_list .. ")")
return true, "Rapporté. Moderateur(s) connecté(s) : " .. mod_list
2015-12-18 05:11:11 +01:00
else
2015-12-18 23:34:14 +01:00
email.send_mail(name, minetest.setting_get("name"),
"Rapport: " .. param .. " (pas de modo connecté)")
return true, "Rapporté. On reviendra vers vous."
2015-12-11 18:45:32 +01:00
end
end
})
minetest.log("action", "[report] loaded.")