(Створена сторінка: local p = {} function p.FetchData(frame) local categoryName = "Учасники_спільноти_MCC" -- category name as per your URL local titles = mw.site.stats.getPagesInCategory(categoryName, "pages") -- Start the wikitable local output = '{| class="wikitable"\n' output = output .. '! Nickname !! Prize Pool !! Date Added !! Recruiter\n' -- Process each page in the category for _, pageTitle in ipairs(titles) do...)
 
Немає опису редагування
Рядок 2: Рядок 2:


function p.FetchData(frame)
function p.FetchData(frame)
     local categoryName = "Учасники_спільноти_MCC" -- category name as per your URL
    -- This function fetches pages from a category and extracts information from the 'MCC Player' template.
     local titles = mw.site.stats.getPagesInCategory(categoryName, "pages")
     local categoryName = "Учасники_спільноти_MCC" -- Set the correct category name
     local continue = nil
    local pages = {}
 
    -- Fetching pages from the category
    repeat
        local query = mw.title.makeTitle(14, categoryName):categoryMembers{continue = continue}
        for _, page in ipairs(query) do
            table.insert(pages, page.title)
        end
        continue = query.continue
    until not continue


     -- Start the wikitable
     -- Start the wikitable
Рядок 9: Рядок 20:
     output = output .. '! Nickname !! Prize Pool !! Date Added !! Recruiter\n'
     output = output .. '! Nickname !! Prize Pool !! Date Added !! Recruiter\n'


     -- Process each page in the category
     -- Process each page
     for _, pageTitle in ipairs(titles) do
     for _, pageTitle in ipairs(pages) do
         local pageContent = mw.title.new(pageTitle):getContent()
         local page = mw.title.new(pageTitle)
        local content = page:getContent()
       
        -- Extract data using patterns (very basic pattern matching, customize as needed)
        local nickname = content:match("| nickname = ([^\n]+)")
        local prizePool = content:match("| prize_pool = ([^\n]+)")
        local dateAdded = content:match("| date_added = ([^\n]+)")
        local recruiterLink = content:match("| recruiter = %[%[([^|%]]+)")
        local recruiter = recruiterLink and mw.title.new(recruiterLink):getPrefixedText() or 'N/A'
          
          
        -- Extract data using patterns
        local nickname = pageContent:match("| nickname = ([^\n]+)")
        local prizePool = pageContent:match("| prize_pool = ([^\n]+)")
        local dateAdded = pageContent:match("| date_added = ([^\n]+)")
        local recruiter = pageContent:match("| recruiter = %[%[([^|%]]+)|")
         -- Append to the table
         -- Append to the table
         output = output .. '|-\n'
         output = output .. '|-\n'
         output = output .. string.format('| %s || %s || %s || %s\n', nickname or 'N/A', prizePool or 'N/A', dateAdded or 'N/A', recruiter or 'N/A')
         output = output .. string.format('| %s || %s || %s || %s\n', nickname or 'N/A', prizePool or 'N/A', dateAdded or 'N/A', recruiter)
     end
     end


     -- Close the wikitable
     -- Close the wikitable
     output = output .. '|}'
     output = output .. '|}'
     return output
     return output
end
end


return p
return p

Версія за 22:26, 22 квітня 2024

Документацію для цього модуля можна створити у Модуль:List/документація

local p = {}

function p.FetchData(frame)
    -- This function fetches pages from a category and extracts information from the 'MCC Player' template.
    local categoryName = "Учасники_спільноти_MCC" -- Set the correct category name
    local continue = nil
    local pages = {}

    -- Fetching pages from the category
    repeat
        local query = mw.title.makeTitle(14, categoryName):categoryMembers{continue = continue}
        for _, page in ipairs(query) do
            table.insert(pages, page.title)
        end
        continue = query.continue
    until not continue

    -- Start the wikitable
    local output = '{| class="wikitable"\n'
    output = output .. '! Nickname !! Prize Pool !! Date Added !! Recruiter\n'

    -- Process each page
    for _, pageTitle in ipairs(pages) do
        local page = mw.title.new(pageTitle)
        local content = page:getContent()
        
        -- Extract data using patterns (very basic pattern matching, customize as needed)
        local nickname = content:match("| nickname = ([^\n]+)")
        local prizePool = content:match("| prize_pool = ([^\n]+)")
        local dateAdded = content:match("| date_added = ([^\n]+)")
        local recruiterLink = content:match("| recruiter = %[%[([^|%]]+)")
        local recruiter = recruiterLink and mw.title.new(recruiterLink):getPrefixedText() or 'N/A'
        
        -- Append to the table
        output = output .. '|-\n'
        output = output .. string.format('| %s || %s || %s || %s\n', nickname or 'N/A', prizePool or 'N/A', dateAdded or 'N/A', recruiter)
    end

    -- Close the wikitable
    output = output .. '|}'
    return output
end

return p