小 (导入1个版本:导入自求闻百科的页面[页面文字原许可:CC BY-SA 4.0]) |
(// Edit via Wikiplus) |
||
第32行: | 第32行: | ||
local bot_archive = '' |
local bot_archive = '' |
||
if isKeep(arg) then |
if isKeep(arg) then |
||
spanid = '_new_request' |
|||
bot_archive = mw.getCurrentFrame():expandTemplate{title='Bot-directive-archiver', args={'keep'}} |
bot_archive = mw.getCurrentFrame():expandTemplate{title='Bot-directive-archiver', args={'keep'}} |
||
end |
end |
2023年5月22日 (一) 17:44的最新版本
local p = {}
local page = mw.title.new( 'Module:Status/data.json' )
local content = page:getContent()
local data = mw.text.jsonDecode( content )
local function status (x)
for k,v in pairs(data) do
for _,s in pairs(v.status) do
if x == s then return k end
end
end
return 'unknown'
end
local function color (x)
return data[status(x)].color
end
local function text (x, arg1, arg2)
return arg2 or data[status(x)].text or arg1 or '处理中'
end
local function isKeep (x)
return data[status(x)].keep or false
end
function p._main(args)
local arg = args[1] and args[1]:lower() or '处理中'
local code = args['prefix'] or '状态:'
local spanid = nil
local bot_archive = ''
if isKeep(arg) then
bot_archive = mw.getCurrentFrame():expandTemplate{title='Bot-directive-archiver', args={'keep'}}
end
code = code .. mw.text.tag('span', {
['style'] = 'background:' .. color(arg),
['id'] = spanid or ''
}, '  ')
code = code .. ' ' .. mw.text.tag('b', {}, text(arg, args[1], args[2])) .. (args['sign'] or '')
code = mw.text.tag('div', {}, code) .. bot_archive
return code
end
--[=[
local paid = {}
if id then paid['id'] = id end
if id then paid['id'] = id end
if style then paid['style'] = style end
if title then paid['title'] = title end
]=]--
function p.main(frame)
local args = {}
for k, v in pairs( frame:getParent().args ) do
args[k] = v
end
return p._main(args)
end
return p