มอดูล:Requested entries
เอกสารการใช้งานสำหรับมอดูลนี้อาจสร้างขึ้นที่ มอดูล:Requested entries/doc
local p = {}
local random = require('Module:Math')._random
function p.main(frame)
total = tonumber(frame.args[1])
links = {}
content = mw.title.new('วิกิคำคม:บทความที่ต้องการ'):getContent()
for thlink, enlink in content:gmatch('* %[%[(%S-)%]%] %(%[%[(:en:%S-)%]%]%)') do
if not thlink:find(']', 1, true) then
table.insert(links, {thlink, enlink})
end
end
selected = {}
out = {}
while #out < total do
num = random(#links)
if not selected[num] then
selected[num] = true
table.insert(out, '[[' .. links[num][1] .. ']][[' .. links[num][2] .. '|^]]')
end
end
return table.concat(out, ' ')
end
return p