Module:Contentious topics/talk notice: Difference between revisions

Content deleted Content added
simplify
fix bug
Line 44:
local messageBody
 
-- HelperHelpers to add a restriction if it's active and hasn't been added yet
local function addRestriction(restriction, topicWide)
if (yesno(args[restriction]) or topicWide) and not restrictionFlags[restriction] then
restrictionFlags[restriction] = true
table.insert(restrictions, restriction)
end
end
local function maybeAddRestriction(restriction) return addRestriction(restriction, false) end
local function alwaysAddRestriction(restriction) return addRestriction(restriction, true) end
 
-- ExplicitlyAdd declaredthe always-available restrictions
addRestrictionmaybeAddRestriction("0RR")
addRestrictionmaybeAddRestriction("0RR-nocat")
addRestrictionmaybeAddRestriction("1RR")
addRestrictionmaybeAddRestriction("1RR-nocat")
addRestrictionmaybeAddRestriction("BRD")
addRestrictionmaybeAddRestriction("consensus-required")
 
-- Topic-based restrictions
Line 65 ⟶ 68:
if topicWide then
for _, restriction in ipairs(topicWide) do
addRestrictionalwaysAddRestriction(restriction)
end
end
Line 72 ⟶ 75:
if additional then
for _, restriction in ipairs(additional) do
addRestrictionmaybeAddRestriction(restriction)
end
end
Line 85 ⟶ 88:
end
 
-- Check whether any of the added restrictions are actually defined, and are real restrictions
local underRestrictions = #restrictions > 0false
for _, r in ipairs(restrictions) do
 
if restrictionsDefinition[r] then
underRestrictions = true
break
end
end
local articleOrPage = currentTitleObject:inNamespaces(1) and "article" or "page"