模組:RFCUform

维基百科,自由的百科全书
文档图示 模块文档[创建]
local rfcu = {}

function rfcu.main(frame)
    local args = frame:getParent().args
    
    if not args['username1'] then
		return require('Module:Error').error{[1] = "[[Template:RFCUform]]錯誤:沒有參數<code>username1</code>"}
   end
   
    local users = {}
    local moreusername = args["moreusername"]
    local reason = args["reason"]
    local t_users, user
    local i = 1
    
    while true do --frame的args不是完全table实现,无法用#args查表长,只能死循环试探结束。
        t_users = args['username' .. i]
        if (t_users ~= nil) then
        	if t_users == '' then else
        		users[#users + 1] = t_users
			end
			i = i +1
		else
			break
        end
    end
    
    local wt = "=== " .. args['username1'] .. " ===\n"

    wt = wt .. "{{status2}}\n"
    
    local userurllist = ""
    
    for i = 1, #users do
    	user = users[i]
    	wt = wt .. "{{checkuser|" .. user .. "}}"
    	if userurllist == '' then
    		userurllist = "?users=" .. user
    	else
    		userurllist = userurllist .. "&users=" .. user
    	end
    end
    
    userurllist = "//tools.wmflabs.org/sigma/editorinteract.py" .. userurllist .. "&server=zhwiki"
    
    if moreusername ~= nil then else
    	wt = wt .. "{{error|'''[[Template:RFCUform]]錯誤:可以支援參數<code>username11</code>以上,請不要使用此參數'''}}\n"
    end
    
    wt = wt .. "\n*  <span class=\"plainlinks\">工具:[" .. userurllist .. " 編輯交互關係分析] ([" .. userurllist .. "&ns=0 條目] - [" .. userurllist .. "&ns=2 -{zh-hans:用户页;zh-hant:用戶頁;zh-tw:使用者頁面;}-] - [" .. userurllist .. "&ns=4 -{zh-hans:项目页面;zh-hant:專案頁面;zh-tw:計畫頁面;}-] )</span>\n"

    wt =  wt .. "\n* 理由:" .. (reason ~= nil and reason or "{{red|'''请提供理由'''}}") .. "\n"
    if mw.isSubsting() then
		 wt =  wt .. "--~~~~"
	end
    return frame:preprocess(wt .. "--~~~~")
end

return rfcu