Jump to content

Module:Protection banner: Difference between revisions

try a different category matching algorithm completely
(fix "Wikipedia protected categories" key)
(try a different category matching algorithm completely)
Line 136: Line 136:
-- Define the key table and the order to test it in
-- Define the key table and the order to test it in
local keyTable = {protType, protLevel, namespace, reason, expiry}
local keyTable = {protType, protLevel, namespace, reason, expiry}
local tryOrder
local attemptOrder = {
if reason == 'vandalism' then
{true, true, true, true, true},
tryOrder = {5, 4, 3, 2, 1}
{true, true, true, true, false},
else
{true, true, true, false, true},
tryOrder = {5, 3, 4, 2, 1}
{true, true, false, true, true},
end
{true, true, true, false, false},
{true, true, false, true, false},
{true, true, false, false, true},
{true, true, false, false, false},
{true, false, false, false, false},
{false, false, false, false, false}
}
-- Try successively generic matches until we run out of key combinations
-- Try successively generic matches until we run out of key combinations
local function attemptMatch()
for i, t in ipairs(attemptOrder) do
local key = table.concat(keyTable, '-')
local key = {}
return cats[key]
for j = 1, 5 do
end
if t[j] then
local attempt = attemptMatch()
key[j] = keyTable[j]
if attempt then
else
return attempt
key[j] = 'all'
end
end
for i, keyTableKey in ipairs(tryOrder) do
end
keyTable[keyTableKey] = 'all'
key = table.concat(key, '-')
attempt = attemptMatch()
local attempt = cats[key]
if attempt then
if attempt then
return attempt
return attempt
Cookies help us deliver our services. By using our services, you agree to our use of cookies.