跳转到内容

模組:AFC submission catcheck

被永久保护的模块
维基百科,自由的百科全书
local p = {}

local function removeFalsePositives(str)
	if not str then
		return ''
	end
	str = mw.ustring.gsub(str, "<!--.--->", "")
	str = mw.ustring.gsub(str, "<nowiki>.-</nowiki>", "")
	str = mw.ustring.gsub(str, "草稿分类-}}", "")
	str = mw.ustring.gsub(str,"%[%[Category:使用创建条目精灵建立的页面%]%]","")
	str = mw.ustring.gsub(str,"%[%[Category:不合适的草稿%]%]","")
	str = mw.ustring.gsub(str,"%[%[Category:有关.的草稿-%]%]","")
	return str
end

function p.checkforcats(frame)
    local t = mw.title.getCurrentTitle()
    tc = t:getContent()
    if tc == nil then 
        return ""
    end
    tc = removeFalsePositives(tc)
    if mw.ustring.match(tc, "%[%[%s-[Cc]ategory:" ) == nil then
        return ""
    else
        return "[[Category:有分类的草稿]]"
    end
end

function p.submitted(frame)
	if mw.ustring.find(removeFalsePositives(mw.title.getCurrentTitle():getContent()), '{{AFC submission||', 1, true) then
		return frame.args[1]
	else
		return frame.args[2]
	end
end

return p