Compare commits

...

9 Commits

Author SHA1 Message Date
a171a1ce2c Merge branch 'github' 2022-07-02 16:31:50 +02:00
1ae980fc43 Help of the command /report simplified.
- Command "/report modos" renamed to "/report modos_list"
- Add template.txt file in locale folder
- Rewrite comments in english
2022-07-02 16:27:32 +02:00
a91898239f Add load message 2022-07-02 15:58:06 +02:00
75ddb31b5b Delete depends.txt and description.txt, add mod.conf 2022-07-02 15:27:55 +02:00
2abc7e46ee Remove load message at startup 2022-07-02 15:25:17 +02:00
eae7de5bf6 Report sent to moderators even if they are offline.
- Use mod storage to keep list of modos
- Add "/report modos" command to get list of known modos.
- Add french translation
2022-07-02 15:15:52 +02:00
e7f0275a88 Fix crash when no moderators online 2021-08-11 21:54:30 +02:00
8b2ff073ea Can send reports to offline moderators + add french translation 2021-07-25 00:01:37 +02:00
dfe4d8e321 Begin write of send email to offline moderators 2021-07-24 12:48:31 +02:00
6 changed files with 101 additions and 19 deletions

View File

@ -1 +0,0 @@
email

View File

@ -1 +0,0 @@
Allows players to report misconduct or bugs using /report.

View File

@ -1,38 +1,98 @@
local S = minetest.get_translator("report")
local storage = minetest.get_mod_storage()
assert(storage, "mod_storage is required")
local function get_modo_list()
local store = storage:get_string("report")
if store then
return minetest.deserialize(store) or {}
end
return nil
end
local function is_known_modo(name)
for _, modo in ipairs(get_modo_list()) do
if modo == name then
return true
end
end
return false
end
minetest.register_on_joinplayer(function(player)
-- Get player privs
local player_name = player:get_player_name()
local is_modo = minetest.check_player_privs(player_name, {kick = true, ban = true})
-- Is player a known moderator?
local known = is_known_modo(player_name)
-- Add or remove the player to/from moderators list
if not known and is_modo then
local modos = get_modo_list()
table.insert(modos, player_name)
storage:set_string("report", minetest.serialize(modos))
elseif known and not is_modo then
local modos = get_modo_list()
for i, modo in ipairs(modos) do
if modo == player_name then
table.remove(modos, i)
storage:set_string("report", minetest.serialize(modos))
break
end
end
end
end)
minetest.register_chatcommand("report", { minetest.register_chatcommand("report", {
description = S("Send a report to moderators. '/report modos_list' to get the list of moderators."),
params = "<msg>",
func = function(name, param) func = function(name, param)
param = param:trim() param = param:trim()
if param == "" then if param == "" then
return false, "Veuillez écrire un message pour le rapport. " .. return false, S("Please write a message for the report. If it's about one or several players in particular, please give their name.")
"Si il s'agit d'un (de) joueur(s) en particulier, veuillez aussi indiquer son (leur) nom(s)." end
if param == "modos_list" then
return true, S("Moderators list: @1", table.concat(get_modo_list(), ", "))
end end
local _, count = string.gsub(param, " ", "") local _, count = string.gsub(param, " ", "")
if count == 0 then if count == 0 then
minetest.chat_send_player(name, "Si vous rapportez l'attitude d'un joueur, " .. minetest.chat_send_player(name, S("If you are reporting a player's attitude, you should also say why. (Ex: insult, sabotage)"))
"vous devriez aussi dire quelle en est la raison. (Ex: insulte, sabotage)")
end end
-- Send to online moderators / admins -- Send to online moderators / admins
-- Get comma separated list of online moderators and admins -- Get comma separated list of online moderators and admins
local mods = {} local modos_online = {}
for _, player in pairs(minetest.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
local toname = player:get_player_name() local toname = player:get_player_name()
if minetest.check_player_privs(toname, {kick = true, ban = true}) then if is_known_modo(toname) then
table.insert(mods, toname) table.insert(modos_online, toname)
minetest.chat_send_player(toname, "-!- " .. name .. " a rapporté : " .. param) minetest.chat_send_player(toname, S("-!- @1 has reported: @2", name, param))
end end
end end
if #mods > 0 then local admin = minetest.setting_get("name")
mod_list = table.concat(mods, ", ")
email.send_mail(name, minetest.setting_get("name"), if #modos_online > 0 then
"Rapport: " .. param .. " (modos connecté(s) : " .. mod_list .. ")") local mod_list = table.concat(modos_online, ", ")
return true, "Rapporté. Moderateur(s) connecté(s) : " .. mod_list email.send_mail(name, admin, S("Report: @1 (online moderator(s): @2)", param, mod_list))
for _, modo in ipairs(get_modo_list()) do
if modo ~= admin then
email.send_mail(name, modo, S("Report: @1 (online moderator(s): @2)", param, mod_list))
end
end
return true, S("Reported. Online moderator(s): @1", mod_list)
else else
email.send_mail(name, minetest.setting_get("name"), email.send_mail(name, admin, S("Report: @1 (no online moderator)", param))
"Rapport: " .. param .. " (pas de modo connecté)") for _, modo in ipairs(get_modo_list()) do
return true, "Rapporté. On reviendra vers vous." if modo ~= admin then
email.send_mail(name, modo, S("Report: @1 (no online moderator)", param))
end
end
return true, S("Reported. We will get back to you.")
end end
end end
}) })
minetest.log("action", "[report] loaded.") minetest.log("action", "[report] mod loaded.")

10
locale/report.fr.tr Normal file
View File

@ -0,0 +1,10 @@
# textdomain:report
Send a report to moderators. '/report modos_list' to get the list of moderators.=Envoie un rapport aux modérateurs. '/report modos_list' pour obtenir la liste des modérateurs.
Please write a message for the report. If it's about one or several players in particular, please give their name.=Veuillez écrire un message pour le rapport. Si il s'agit d'un ou plusieurs joueurs en particulier, veuillez aussi indiquer leur nom.
Moderators list: @1=Liste de modérateurs : @1
If you are reporting a player's attitude, you should also say why. (Ex: insult, sabotage)=Si vous rapportez l'attitude d'un joueur, vous devriez aussi dire quelle en est la raison. (Ex: insulte, sabotage)
-!- @1 has reported: @2=-!- @1 a rapporté : @2
Report: @1 (online moderator(s): @2)=Rapport : @1 (moderateur(s) connecté(s) : @2)
Reported. Online moderator(s): @1=Rapporté. Moderateur(s) connecté(s) : @1
Report: @1 (no online moderator)=Rapport : @1 (pas de modérateur connecté)
Reported. We will get back to you.=Rapporté. On reviendra vers vous.

10
locale/template.txt Normal file
View File

@ -0,0 +1,10 @@
# textdomain:report
Send a report to moderators. '/report modos_list' to get the list of moderators.=
Please write a message for the report. If it's about one or several players in particular, please give their name.=
Moderators list: @1=
If you are reporting a player's attitude, you should also say why. (Ex: insult, sabotage)=
-!- @1 has reported: @2=
Report: @1 (online moderator(s): @2)=
Reported. Online moderator(s): @1=
Report: @1 (no online moderator)=
Reported. We will get back to you.=

4
mod.conf Normal file
View File

@ -0,0 +1,4 @@
name = report
title = Report
description = Allows players to report misconduct or bugs using /report.
depends = email