Module:BlockMessages

--| Module:BlockMessages (v1.0.2) --by "The JoTS" --- This module is meant to be used in conjunction to MessageBlock and --- allows for customized block messages for every offense listed in the --- Ipbreason-dropdown system message.

--

-- [==[ Module Start ]==] -- return { main = function(frame) local reasons = setmetatable({}, {__index = function(t,i)            return rawget(t, "__DEFAULT__")                or {"You have been banned for $2 because ", i, ":$1" } end}) do local _reasons, currReason -- Get messages _reasons = mw.message.new("Custom-Ipbreason-messages") assert(_reasons:exists,               "MediaWiki:Custom-Ipbreason-messages does not exist.") -- Parse messages for type, msg in                   (tostring(_reasons)..'\n'):gmatch("([;:])(.-)\n") do                if type == ";" then currReason = {} reasons[msg] = currReason elseif type == ":" and currReason then table.insert(currReason, msg) end end end -- Get selected message local args = frame.args local offense, notes = args[1]:match("^(.+):%s*(.+)") offense = offense or args[1] return (mw.text.trim(table.concat(reasons[offense], '\n'))           :gsub("$%d", { ["$1"] = notes, ["$2"] = args[2] }))   end }