Модуль:List: відмінності між версіями

224 байти додано ,  22 квітня 2024
нема опису редагування
Немає опису редагування
Немає опису редагування
 
Рядок 2: Рядок 2:


function p.FetchData(frame)
function p.FetchData(frame)
     -- This function fetches pages from a category and extracts information from the 'MCC Player' template.
     -- List of player pages to process
     local categoryName = "Учасники_спільноти_MCC" -- Set the correct category name
     local players = {
    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
Рядок 20: Рядок 16:
     output = output .. '! Nickname !! Prize Pool !! Date Added !! Recruiter\n'
     output = output .. '! Nickname !! Prize Pool !! Date Added !! Recruiter\n'


     -- Process each page
     -- Process each player page
     for _, pageTitle in ipairs(pages) do
     for _, playerName in ipairs(players) do
         local page = mw.title.new(pageTitle)
         local page = mw.title.new(playerName)
         local content = page:getContent()
         local content = page:getContent()
          
          
         -- Extract data using patterns (very basic pattern matching, customize as needed)
         -- Extract data using patterns (assume your template fields are consistent)
         local nickname = content:match("| nickname = ([^\n]+)")
         local nickname = content:match("| nickname = ([^\n]+)")
         local prizePool = content:match("| prize_pool = ([^\n]+)")
         local prizePool = content:match("| prize_pool = ([^\n]+)")
Рядок 34: Рядок 30:
         -- 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)
         output = output .. string.format('| %s || %s || %s || %s\n', nickname or playerName, prizePool or 'N/A', dateAdded or 'N/A', recruiter)
     end
     end