Skip to content

Commit e9c3b12

Browse files
authored
Merge pull request #37 from Bapham12/main
Fix protection level checks and sandbox link creation
2 parents 86f49de + a1f7ff6 commit e9c3b12

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎Lua banner/main.lua‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function p.renderBox(modules)
3434
for i, module in ipairs(modules) do
3535
moduleLinks[i] = string.format('[[:%s]]', module)
3636
local maybeSandbox = mw.title.new(module .. '/sandbox')
37-
if maybeSandbox.exists then
37+
if maybeSandbox and maybeSandbox.exists then
3838
moduleLinks[i] = moduleLinks[i] .. string.format(' ([[:%s|sandbox]])', maybeSandbox.fullText)
3939
end
4040
end
@@ -97,9 +97,11 @@ function p.renderTrackingCategories(args, modules, titleObj)
9797
if not args.noprotcat and protCatName then
9898
local protLevels = {
9999
autoconfirmed = 1,
100-
extendedconfirmed = 2,
101-
templateeditor = 3,
102-
sysop = 4
100+
editextendedconfirmedprotected = 2,
101+
edittemplateeditorprotected = 3,
102+
sysop = 4,
103+
editbureaucratprotected = 5,
104+
editmoderatorprotected = 6
103105
}
104106
local currentProt
105107
if titleObj.id ~= 0 then
@@ -109,7 +111,8 @@ function p.renderTrackingCategories(args, modules, titleObj)
109111
if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end
110112
for i, module in ipairs(modules) do
111113
if module ~= "WP:libraryUtil" then
112-
local moduleProt = mw.title.new(module).protectionLevels["edit"][1]
114+
local moduleTitle = mw.title.new(module)
115+
local moduleProt = moduleTitle and moduleTitle.protectionLevels["edit"][1]
113116
if moduleProt == nil then moduleProt = 0 else moduleProt = protLevels[moduleProt] end
114117
if moduleProt < currentProt then
115118
cats[#cats + 1] = protCatName

0 commit comments

Comments
 (0)