local module = {} local getArgs = require('Module:Arguments').getArgs local randomSeed = 0 function module._main(args) function random(count, min, max) randomSeed = randomSeed + 1 math.randomseed(tostring(os.time()):reverse():sub(1, 7)..randomSeed) if count == 1 then return math.random(min, max) end local order = {} function test(num) for i=1, #order do if num == order[i] then return true end end return false end repeat local ran = math.random(min, max) if test(ran) == false then order[#order + 1] = ran end until(#order == count) return order end local data = args[1] local num = tonumber(args['num']) or 19 local anime = {} local iter = string.gmatch(data, '%[%[(.-)%]%]') for v in iter do v = string.gsub(v, '<.->', '') local link = v local text = v if string.find(v, '%|') ~= nil then link = string.gsub(v, '([^|]*)%|?([^|]*)', '%1') text = string.gsub(v, '[^|]*%|?([^|]*)', '%1') end if mw.ustring.find(text, '^[查论编]$') == nil then local r = random(1, 0, 255) local g = random(1, 0, 255) local b = random(1, 0, 255) local element = '[['..link..'|<span style="display:inline-block; color:rgb('..r..','..g..','..b..');">'..text..'</span>]]' anime[#anime + 1] = element end end local set = {} local ran = random(num, 1, #anime) for i=1, num do set[#set + 1] = anime[ran[i]] end local str = '' for i=1, #set do str = str..set[i]..'$' end return str end function module.main(frame) local args = getArgs(frame) return module._main(args) end return module