Module:Sandbox/Danski454/SPI report

require('strict') local yesno = require('Module:Yesno') local getArgs = require('Module:Arguments').getArgs local TableTools = require('Module:TableTools') local p = {}

local newPageHeader = ' \n\n\n'

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

function p._main(args) local outText = '' local master = mw.title.getCurrentTitle.subpageText local socks = {} local ips = {} --Wikipedia:Sockpuppet investigations/SPI/Blank report template header if not mw.title.getCurrentTitle.exists then outText = string.gsub(newPageHeader, '__SUBPAGENAME__', master) end local status = '' if args.status then status = args.status elseif args.admincomment then status = 'close' elseif yesno(args.checkuser) then status = 'CUrequest' end outText = outText .. '===' .. mw.language.getContentLanguage:formatDate('d F Y') .. '===\n\n' --SPI report outText = outText .. '====Suspected sockpuppets====\n' if args.socksraw then outText = outText .. args.socksraw .. '\n' -- Twinkle uses this to pass in reports (and loads are filed this way), -- so parse the reports for use by the tools section local socksraw = mw.ustring.gsub(args.socksraw, '<!%-%-.-%-%->', '') --rm comments local sockMatches = mw.ustring.gmatch(socksraw, '') local ipMatches = mw.ustring.gmatch(socksraw, '') for i in sockMatches do			socks[#socks + 1] = i		end for i in ipMatches do			ips[#ips + 1] = i		end else -- loop over ip# and sock# args (copied from Module:Old XfD multi) for k, v in pairs(args) do			if type(k) == 'string' then local prefix, num = k:match('^(.-)([1-9][0-9]*)$') if prefix and num then num = tonumber(num) if prefix == 'sock' then socks[num] = v					elseif prefix == 'ip' then ips[num] = v					end end end end socks = TableTools.compressSparseArray(socks) ips = TableTools.compressSparseArray(ips) for i=1,#socks do outText = outText .. '* \n' end for i=1,#ips do outText = outText .. '* \n' end end outText = outText .. '\n' --Tools outText = outText .. '*\'\'\'Tools\'\'\': [https://tools.wmflabs.org/sigma/editorinteract.py?users=' .. mw.uri.encode(master) for i=1,#socks do outText = outText .. '&users=' .. mw.uri.encode(socks[i]) end for i=1,#ips do outText = outText .. '&users=' .. mw.uri.encode(ips[i]) end outText = outText .. ' Editor interaction utility] • [https://tools.wmflabs.org/interaction-timeline?wiki=enwiki&user=' .. mw.uri.encode(master) if socks[1] then outText = outText .. '&user=' .. mw.uri.encode(socks[1]) end outText = outText .. ' Interaction Timeline] • [https://tools.wmflabs.org/betacommand-dev/UserCompare/' .. mw.uri.encode(master) .. '.html User compare report] \'\'Auto-generated every hour.\'\' \n\n' --evidence if args.evidence then outText = outText .. args.evidence else outText = outText .. "No evidence submitted" end outText = outText .. ' ~\n\n' .. '==== Comments by other users ====\n' .. ' \'\'Accused parties may also comment/discuss in this section below. See Defending yourself against claims.\'\' ' .. '\n\n==== Clerk, CheckUser, and/or patrolling admin comments ====\n' if args.admincomment then outText = outText .. args.admincomment end outText = outText .. '\n\n' return outText end

return p