Module:Othergroups

From Meta Wiki
Revision as of 18:24, 12 December 2024 by TheAstorPastor (talk | contribs) (1 revision imported: some changes are needed ; like removing link to UTRS)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Othergroups/doc

local getArgs = require('Module:Arguments').getArgs
local inArray = require('Module:TableTools').inArray
local cfg = require('Module:Othergroups/config')
local data = require('Module:Othergroups/data')

local p = {}

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

function p._main(args)
	local user = args[1]
	local exclude = args[2] or ''
	
	assert(user, "no user")
	
	userGroups = data[user:gsub('_', ' ')]
	if userGroups == nil then
		return ''
	end
	
	ret = ''
	for k,v in ipairs(cfg.groups) do
		if v ~= exclude and inArray(userGroups, v) then
			if #ret > 0 then
				ret = ret .. ', '
			end
			ret = ret .. cfg.pages[v]
		end
	end
	
	return ret
end

return p