Module:Mass notification

-- This module sends out notifications to multiple users.

local MAX_USERS = 50 -- The Echo user limit. local GROUP_PAGE_PATH = 'Module:Mass notification/groups/' local NO_NAME_ERROR = 'no group name was specified' local LOAD_ERROR = 'the group "$2" was not found' local MAX_USER_ERROR = 'attempted to send notifications to more than $1 users' local NO_USER_ERROR = 'could not find any usernames in $1' local INTRO_BLURB = 'Notifying all members of $1' .. ' (more info'	.. " · "	.. ' [$2 opt out] ) : ' local p = {}

local function message(msg, ...) return mw.message.newRawMessage(msg):params{...}:plain end

function p.main(frame) local args = frame:getParent.args; local groupName = args[1]; -- Validate input. if type(groupName) ~= 'string' then return makeWikitextError(NO_NAME_ERROR) end local groupSubmodule = GROUP_PAGE_PATH .. groupName local data = mw.loadData(groupSubmodule) local optOutUrl = tostring(mw.uri.fullUrl( groupSubmodule, {action = 'edit'} ))	local groupLink if data.group_page then groupLink = string.format('%s', data.group_page, groupName) else groupLink = groupName end introBlurb = message(INTRO_BLURB, groupLink, optOutUrl) local userLinks local userNamespace = mw.site.namespaces[2].name local links = {} for i, username in ipairs(data) do		username = tostring(username) links[i] = string.format(			'%s:%s',			userNamespace,			username		) end userLinks = string.format(		' (%s) ',		table.concat(links, ', ')	) return introBlurb .. userLinks end