模組:ArbComMember
外观
local p = {}
local members = {
["1F616EMO"] = { ANPDP = "m:Special:diff/30128411", VRT = true, status = "active" },
["Bluedeck"] = { ANPDP = "m:Special:diff/27897869", VRT = false, status = "active" },
["Borschts"] = { ANPDP = "m:Special:diff/25877782", VRT = true, status = "active" },
["Ericliu1912"] = { ANPDP = "m:Special:diff/26279777", VRT = true, status = "active" },
["Hamish"] = { ANPDP = "m:Special:diff/19081843", VRT = true, status = "active" },
["Manchiu"] = { ANPDP = "m:Special:diff/26723447", VRT = true, status = "active" },
["Newbamboo"] = { ANPDP = nil, VRT = false, status = "active" },
["SCP-2000"] = { ANPDP = "m:Special:diff/22478376", VRT = true, status = "active" },
["Tokisaki Kurumi"] = { ANPDP = "m:Special:diff/31171660", VRT = true, status = "active" },
["ZhaoFJx"] = { ANPDP = "m:Special:diff/28792878", VRT = true, status = "active" },
["人间百态"] = { ANPDP = nil, VRT = false, status = "active" },
}
local icon_vrt = "[[File:Permission logo 2021.svg|16px|link=phab:L45|alt=VRT]]"
local function iterTable(self)
local list = {}
for key in pairs(self) do
table.insert(list, key)
end
table.sort(list)
local index = 0
return function ()
index = index + 1
if index > #list then
return nil
else
return list[index], self[list[index]]
end
end
end
function p.render(frame)
local args = frame.args[1] and frame.args or frame:getParent().args
local username = args[1]
local mode = args[2]
return p._render(username, mode)
end
function p._render(username, mode)
if not username then
return ""
end
username = username:gsub("^%s*(.-)%s*$", "%1"):gsub("_", " "):gsub("^(.)", string.upper)
if username == "" then
return ""
end
if mode then
mode = mode:gsub("^%s*(.-)%s*$", "%1")
end
local perm = members[username] or { ANPDP = nil, VRT = false }
local result
if mode == "talk" then
result = string.format("[[User:%s|-{%s}-]]([[User talk:%s|討論]] | [[Special:Contributions/%s|貢獻]])", username, username, username, username)
else
result = string.format("[[User:%s|-{%s}-]]", username, username)
end
if perm.VRT then
result = icon_vrt .. " " .. result
end
if perm.ANPDP and perm.ANPDP ~= "" then
local tag_content = string.format(
' <span style="font-family: sans-serif; cursor: default; font-size: 0.8em; font-weight: bold;" title="ANPDP Positive">([[%s|<span class="skin-invert" style="color: #54595d;">ANPDP</span>]])</span>',
perm.ANPDP
)
result = result .. tag_content
end
return result
end
function p.ping(frame)
local getArgs = require("Module: Arguments").getArgs
local yesno = require("Module:Yesno")
local args = getArgs(frame, {trim = false, removeBlanks = false})
local pinglist = {}
for username, value in pairs(members) do
table.insert(pinglist, string.format("[[User:%s]]", username))
end
local pingtext = mw.text.tag('span', {['style']='display:none'}, table.concat(pinglist))
if not yesno(args.hidden, false) then
pingtext = (args["@"] or "@") .. "[[WP:ArbCom|" .. (args.label or "仲裁委员会") .. "]]" .. (args.p or ":") .. pingtext
end
return pingtext
end
function p.MMS(frame)
local mmslist = {}
for username, value in iterTable(members) do
table.insert(mmslist, "# " .. frame:expandTemplate{ title = "user", args = { username } })
frame:callParserFunction("#target", "User talk:" .. username)
end
return table.concat(mmslist, "\n")
end
function p.list(frame)
local getArgs = require("Module: Arguments").getArgs
local args = getArgs(frame, {trim = false, removeBlanks = false})
local activelist, inactivelist = {}, {}
local function heading(text, color)
return mw.text.tag("span", {style="font-family: Georgia, 'DejaVu Serif', serif; color: " .. color .. "; font-size:120%; font-weight: bold;"}, frame:expandTemplate({ title = "Visible anchor", args = { text } }))
end
for username, value in iterTable(members) do
if value.status == "active" then
table.insert(activelist, p._render(username, "talk") .. (args[username] or ""))
elseif value.status == "inactive" then
table.insert(inactivelist, p._render(username, "talk") .. (args[username] or ""))
end
end
if #activelist == 0 then
table.insert(activelist, "(暫無)")
end
if #inactivelist == 0 then
table.insert(inactivelist, "(暫無)")
end
return heading("活躍", "var(--color-content-added, #006400)") .. "\n* " .. table.concat(activelist, "\n* ") .. "\n" .. heading("不活躍", "var(--color-error, #CC0000)") .. "\n* " .. table.concat(inactivelist, "\n* ")
end
return p