Module:Wp/bcc/RFBOT

From Wikimedia Incubator

Documentation for this module may be created at Module:Wp/bcc/RFBOT/doc

local p = {}

local pre="Wikidata:Requests for permissions/Bot/"
 
function p.list( frame )
    local list={}
    if mw.title.new(pre..frame.args.user).exists==false then
        return list
    end
    list[1]=pre..frame.args.user
    local num=2
    if mw.title.new(pre..frame.args.user.." "..num).exists==true then
        repeat
            list[num]=pre..frame.args.user.." "..num
            num=num+1
        until mw.title.new(pre..frame.args.user.." "..num).exists==false
    end
    return list
end

function p.all( frame )
    if (#p.list(frame))==0 then
        if frame.args.fallback then
            return frame.args.fallback
        else
            return "none"
        end
    end
    local list={}
    a = {}
    for v,n in pairs(p.list(frame)) do table.insert(a, n) end
    table.sort(a)
    for key in ipairs(a) do
        if frame.args.short=="1" then
            table.insert(list,"[["..p.list(frame)[key].."|"..key.."]]")
        else
            table.insert(list,"*[["..p.list(frame)[key].."]]")
        end
    end
    if frame.args.short=="1" then
        return table.concat(list," ")
    else
        return table.concat(list,"\n")
    end
end

function p.count( frame )
    return (#p.list(frame))
end
 
return p