Page Menu
Home
1F616EMO Bugtracker
Search
Configure Global Search
Log In
Files
F174426
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/list_moderators/init.lua b/list_moderators/init.lua
index da119ad..7b714d7 100644
--- a/list_moderators/init.lua
+++ b/list_moderators/init.lua
@@ -1,90 +1,117 @@
-- 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 busy_mods = {}
+
local function get_chat_string(name)
local list_moderators = {}
for _, player in pairs(core.get_connected_players()) do
local player_name = player:get_player_name()
local privs = minetest.get_player_privs(player_name)
if privs.ban == true then
local display = player_name
local flags = {}
if name == player_name then
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[name] then
+ flags[#flags + 1] = S("Busy")
+ end
+
if #flags > 0 then
display = display .. " " ..
minetest.get_color_escape_sequence("DarkCyan") .. "(" .. table.concat(flags, ", ") .. ")" .. color
end
list_moderators[#list_moderators + 1] = display
end
end
if #list_moderators > 0 then
return color ..
S("List of moderators online: @1", table.concat(list_moderators, ", "))
else
return color ..
S("No moderators online. Seek help by typing /report in the chatroom.")
end
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
+ 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 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"),
func = function(name)
return true, get_chat_string(name)
end,
})
\ No newline at end of file
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Apr 18, 1:58 PM (1 d, 11 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
66/0b/d1656bd9dc321441dc72589e9abb
Default Alt Text
(4 KB)
Attached To
Mode
rTWIMODS Survival Server Custom Modifications
Attached
Detach File
Event Timeline
Log In to Comment