模块:UserlinkUserEditCount

Moqi留言 | 贡献2024年6月4日 (二) 18:41的版本 (创建页面,内容为“local p = {} function p.getUserEditCount(frame) local username = frame.args[1] if not username then return "没有提供用户名" end local api = mw.site.api({ action = 'query', list = 'usercontribs', ucuser = username, uclimit = 'max', ucnamespace = 0, -- 仅限主命名空间 }) if not api or not api.query or not api.query.usercontribs then return "无法获取用户编辑总…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

可在模块:UserlinkUserEditCount/doc创建此模块的帮助文档

local p = {}

function p.getUserEditCount(frame)
    local username = frame.args[1]
    if not username then
        return "没有提供用户名"
    end

    local api = mw.site.api({
        action = 'query',
        list = 'usercontribs',
        ucuser = username,
        uclimit = 'max',
        ucnamespace = 0, -- 仅限主命名空间
    })

    if not api or not api.query or not api.query.usercontribs then
        return "无法获取用户编辑总数"
    end

    local editCount = #api.query.usercontribs
    return "用户 " .. username .. " 的编辑总数为: " .. editCount
end

return p