Module:Othergroups

From Meta

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