跳转到内容

模組:KillRSP/HelpData

维基百科,自由的百科全书
local p = {}

function p.getHelpData(frame)
    local res = {
        absolute = {} -- 仅保留域名部分,彻底抛弃名称(suspected)匹配
    }
    
    local success, data = pcall(mw.loadData, 'Module:RSP/HelpData')
    if success and type(data) == 'table' then
        for _, entry in pairs(data) do
            if type(entry) == 'table' then
                -- 严格提取域名
                if type(entry.domains) == 'table' then
                    for _, d in ipairs(entry.domains) do
                        if type(d) == 'string' and d ~= "" then
                            table.insert(res.absolute, { d = d, src = 'help' })
                        end
                    end
                end
            end
        end
    end

    if frame == mw.getCurrentFrame() then
        return mw.text.jsonEncode(res)
    else
        return res
    end
end

return p