Import new /admin command mod
This commit is contained in:
parent
07a3c36466
commit
a06d4feee2
@ -2,6 +2,7 @@ A collection of miscellaneous mods for minetest providing "utility" functonality
|
||||
|
||||
Each mod in the pack is effectively independent, with minimal or no dependencies (including on any assumed underlying game) and they can be enabled/disabled individually. Mods are distributed as a single pack because they have a single shared maintenance/release cycle.
|
||||
|
||||
- `szutil_admin`: Alternative to the "admin" command that lists moderation team members.
|
||||
- `szutil_chatsocket`: Expose in-game chat stream as a unix-domain socket for arbitrary chat integrations.
|
||||
- `szutil_chatsounds`: Configurable beep notifications for in-game chat.
|
||||
- `szutil_clocksync`: Synchronize in-game clock smoothly with real-time clock so users can log in at predictable times of day.
|
||||
|
7
szutil_admin/README
Normal file
7
szutil_admin/README
Normal file
@ -0,0 +1,7 @@
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Replacement for the /admin command that lists any members of the server
|
||||
moderation team that are online (configurable based on privs), or a
|
||||
configurable fallback message if none are in-game.
|
||||
|
||||
------------------------------------------------------------------------
|
33
szutil_admin/init.lua
Normal file
33
szutil_admin/init.lua
Normal file
@ -0,0 +1,33 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local minetest, pairs, string, table
|
||||
= minetest, pairs, string, table
|
||||
local string_format, table_concat, table_sort
|
||||
= string.format, table.concat, table.sort
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local function conf(n)
|
||||
return minetest.settings:get(modname .. "_" .. n)
|
||||
end
|
||||
|
||||
local modprivs = minetest.string_to_privs(conf("priv") or "basic_privs")
|
||||
local hideprivs = minetest.string_to_privs(conf("hide") or "stealth")
|
||||
local onlinemsg = conf("online") or "Moderators currently online: %s"
|
||||
local offlinemsg = conf("offline") or "No moderators in-game currently; try public chat for help."
|
||||
|
||||
minetest.registered_chatcommands.admin.func = function()
|
||||
local names = {}
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local pname = player:get_player_name()
|
||||
if minetest.check_player_privs(pname, modprivs)
|
||||
and not minetest.check_player_privs(pname, hideprivs) then
|
||||
names[#names + 1] = pname
|
||||
end
|
||||
end
|
||||
if #names > 0 then
|
||||
table_sort(names)
|
||||
return true, string_format(onlinemsg, table_concat(names, ", "))
|
||||
end
|
||||
return true, offlinemsg
|
||||
end
|
1
szutil_admin/mod.conf
Normal file
1
szutil_admin/mod.conf
Normal file
@ -0,0 +1 @@
|
||||
name = szutil_admin
|
Loading…
x
Reference in New Issue
Block a user