Module:Report

-- -- @authors Noreplyz

-- --[[                                Module:Report

Module for report templates. Proofreads user input. This module is invoked using Template:Report spam, Template:Report vandalism and Template:Report profile.

--]] --

local p = {}

-- remove excess or wrongly entered content function trim_wiki(s) s = s:match( "^%s*(.-)%s*$" ) s = s:gsub("http:%/%/","") s = s:gsub("%.wikia%.com.*", "") return s end

function trim_page(s) s = s:match( "^%s*(.-)%s*$" ) s = s:gsub("http:%/%/","") s = s:gsub("^%a+%.wikia%.com%/wiki/","") s = s:gsub(" ","_") return s end

function trim_user(s) s = s:match( "^%s*(.-)%s*$" ) s = s:gsub("http:%/%/","") s = s:gsub("^%a+%.wikia%.com%/wiki%/","") s = s:gsub("^%a+%.wikia%.com%/","") s = s:gsub("User:","") s = s:gsub("Special:Contributions%/","") s = s:gsub("Special:Contribs%/","") s = s:gsub(" ","_") return s end

function trim_reason(s) s = s:match( "^%s*(.-)%s*$" ) s = s:gsub("\n"," ") return s end

function trim_id(s) s = s:match( "^%s*(.-)%s*$" ) s = s:gsub("#","") return s end

function createReport(frame, reportType) local tArgs = frame:getParent local ret = {}

local numArgs = 0 for key, value in ipairs(tArgs.args) do numArgs = numArgs + 1 end -- report params local wiki = trim_wiki(tArgs.args[1] or "") local reason = trim_reason(tArgs.args[2] or "") local user = "" local reporter = tArgs.args[numArgs - 1] or "" local time = tArgs.args[numArgs] or "" -- report-specific params local skin = "" if reportType == "Profile" then skin = "?useskin=wikia" end local page = "" local blockId = "" if reportType == "Phalanx" then page = trim_page(tArgs.args[2]) blockId = trim_id(tArgs.args[3] or "") reason = tArgs.args[4] end

-- start report creation

ret[#ret + 1] = ' \n' ret[#ret + 1] = '*Wiki: http://' .. wiki .. '.wikia.com \n' if reportType == "Phalanx" then -- Filter problem only ret[#ret + 1] = '*Page: http://' .. wiki .. '.wikia.com/wiki/' .. page .. ' \n' ret[#ret + 1] = '*Block ID: http://community.wikia.com/wiki/Special:PhalanxStats/' .. blockId .. ' \n' else -- Spam, Vandalism or Profile report for key, value in ipairs(tArgs.args) do            if (key >= 3 and key <= (numArgs - 2)) then user = trim_user(value) or "" ret[#ret + 1] = '*' .. reportType .. ': http://' .. wiki .. '.wikia.com/wiki/Special:Contributions/' .. user .. skin .. ' \n' end end end ret[#ret + 1] = '*Reason: '.. reason ..'\n' ret[#ret + 1] = '*Signature: --' .. reporter .. ' (talk) ' .. time .. '\n' ret[#ret + 1] = ' '

return table.concat(ret) end

function p.spam(frame) return createReport(frame, "Spammer") end

function p.vandalism(frame) return createReport(frame, "Vandal") end

function p.profile(frame) return createReport(frame, "Profile") end

function p.filter_problem(frame) return createReport(frame, "Phalanx") end

return p --