置顶公告:【置顶】关于临时开启评论区所有功能的公告(2022.10.22) | 【置顶】关于本站Widget恢复使用的公告
  • 你好~!欢迎来到萌娘百科镜像站!如需查看或编辑,请联系本站管理员注册账号。
  • 本镜像站和其他萌娘百科的镜像站无关,请注意分别。

Module:Sandbox/滝沢朔太郎/UserGroupSysop

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳到导航 跳到搜索
Template-info.svg 模块文档  [创建] [刷新]
local module = {}





----- 在下方修改各用户组成员列表 -----

local bureaucrat = {
    { "Baskice", prefix = "<sub>站长</sub>" },
    "AnnAngela",
    "云霞",
    { "Etolli", postfix = "<sub>暂不参与站务</sub>", active = false } -- active参数仅在false时表示该用户将被[[Template:大召唤术]]忽略。
}

local sysop = {
    "金萌桥姬",
    "蓝羽汇",
    "弗霖凯",
    "北极星与南十字",
    "Lyhic"
}

----- 在上方修改各用户组成员列表 -----





--[[
    供Module:Summon(大召唤术)读取数据的接口。
--]]
function module.enumerate()
    local users = {}
    local groups = { bureaucrat, sysop, patroller } -- 在上方添加用户组后,在这里添加引用。
    for _, group in ipairs(groups) do
        for _, user in ipairs(group) do
            if type(user) == "string" and mw.text.trim(user) ~= "" then
                table.insert(users, mw.text.trim(user))
            elseif type(user) == "table" and type(user[1]) == "string" and mw.text.trim(user[1]) ~= "" and user.active ~= false then
                table.insert(users, mw.text.trim(user[1]))
            end
        end
    end
    
    return users
end

local UserGroupInfo = function(group, frame)
    local parent = frame:getParent()
    if parent and parent:getTitle() == "Template:UserGroup" then
        frame = parent
    end
    if frame.args["Count"] then
        return #group
    else
        local list = {}
        for _, user in ipairs(group) do
            if type(user) == "string" and mw.text.trim(user) ~= "" then
                table.insert(list, frame:expandTemplate{ title = "User", args = { user } })
            elseif type(user) == "table" and type(user[1]) == "string" and mw.text.trim(user[1]) ~= "" then
                table.insert(list,
                    frame:preprocess(user.prefix or "")..
                    frame:expandTemplate{ title = "User", args = { user[1] } }..
                    frame:preprocess(user.postfix or "")
                )
            end
        end
        return table.concat(list, " • ")
    end
end

function module.bureaucrat(frame)
    return UserGroupInfo(bureaucrat, frame)
end

function module.sysop(frame)
    return UserGroupInfo(sysop, frame)
end

return module