Page MenuHome1F616EMO Bugtracker

No OneTemporary

Size
5 KB
Referenced Files
None
Subscribers
None
diff --git a/list_moderators/init.lua b/list_moderators/init.lua
index c8292d3..2dc81cb 100644
--- a/list_moderators/init.lua
+++ b/list_moderators/init.lua
@@ -1,117 +1,135 @@
-- twi_mods/list_moderators/init.lua
-- Send list of moderators after join
--[[
Copyright © 2024 1F616EMO
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
]]
local S = minetest.get_translator("list_moderators")
local function is_afk() return false end
if minetest.global_exists("afk_indicator") then
is_afk = function(name)
local duration = afk_indicator.get(name)
return duration and duration > 5 * 60 or false
end
end
local color = minetest.get_color_escape_sequence("DarkOrange")
+local alt_color = minetest.get_color_escape_sequence("DarkCyan")
local busy_mods = {}
local function get_chat_string(name)
local list_moderators = {}
+ local list_helpers = {}
for _, player in pairs(core.get_connected_players()) do
local player_name = player:get_player_name()
local privs = minetest.get_player_privs(player_name)
+ local list
if privs.ban == true then
+ list = list_moderators
+ elseif privs.role_helper == true then
+ list = list_helpers
+ end
+ if list then
local display = player_name
local flags = {}
if name == player_name then
- flags[#flags+1] = S("You")
+ flags[#flags + 1] = S("You")
end
if privs.server then
flags[#flags + 1] = S("Admin")
end
if is_afk(player_name) then
flags[#flags + 1] = S("AFK")
end
if busy_mods[player_name] then
flags[#flags + 1] = S("Busy")
end
if #flags > 0 then
display = display .. " " ..
- minetest.get_color_escape_sequence("DarkCyan") .. "(" .. table.concat(flags, ", ") .. ")" .. color
+ alt_color .. "(" .. table.concat(flags, ", ") .. ")" .. color
end
- list_moderators[#list_moderators + 1] = display
+ list[#list + 1] = display
end
end
+ local rtn
if #list_moderators > 0 then
- return color ..
+ rtn = color ..
S("List of moderators online: @1", table.concat(list_moderators, ", "))
else
- return color ..
+ rtn = color ..
S("No moderators online. Seek help by typing /report in the chatroom.")
end
+ if #list_helpers > 0 then
+ rtn = rtn .. "\n" .. color .. S("List of helpers online: @1", table.concat(list_helpers, ", "))
+ end
+ return rtn
end
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
minetest.after(0.5, function()
if minetest.get_player_by_name(name) then
minetest.chat_send_player(name, get_chat_string(name))
end
end)
end)
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
busy_mods[name] = nil
end)
minetest.register_on_priv_revoke(function(name, _, priv)
- if priv == "ban" then
+ local privs = minetest.get_player_privs(name)
+ if priv == "ban" and not privs.role_helper
+ or privs == "role_helper" and not privs.ban then
busy_mods[name] = nil
end
end)
minetest.register_chatcommand("mods_busy", {
description = S("Set yourself as busy on the moderator list"),
- privs = { ban = true },
func = function(name)
+ local privs = minetest.get_player_privs(name)
+ if not (privs.ban or privs.role_helper) then
+ return false, S("Insufficant privileges!")
+ end
local prev_status = busy_mods[name]
busy_mods[name] = prev_status == nil and true or nil
return true, prev_status and S("Set to normal.") or S("Set to busy.")
end,
})
minetest.register_chatcommand("list_mods", {
- description = S("List all moderators"),
+ description = S("List all moderators and helpers"),
func = function(name)
return true, get_chat_string(name)
end,
-})
\ No newline at end of file
+})

File Metadata

Mime Type
text/x-diff
Expires
Mar 11 2026, 5:58 AM (6 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f2/a4/c4e1619413c8f22ed35ceb56a6f3
Default Alt Text
(5 KB)

Event Timeline