Module:Checkuser

local p = {}

local getArgs = function(fr) return require('Module:Arguments').getArgs(fr, {		trim = true,		removeBlanks = true	}) end local noping = function(name) return require('Module:No ping')._main({name}) end

local middot = ' &middot;&#32;' local spi = 'Wikipedia:Sockpuppet investigations' local extlink = function(url, text) return '[' .. tostring(url) .. (text and ' ' .. text or '') .. ']' end local link = function(page, param, text) return extlink(mw.uri.fullUrl(page, param), text) end

function p.user(frame) local args = getArgs(frame) return p._user(args['User'] or args[1], args['master'], args['mastername']) end

function p._user(sock, master, mastername) if not sock then return (			' No username provided. ' ..			''		) end local span = mw.html.create('span'):attr('class', 'plainlinks cuEntry') local curtitle = mw.title.getCurrentTitle local links = { 'talk' .. ' ' ..			link('User talk:' .. sock, {				action = 'edit',				section = 'new'			}, ' + ') .. ' ',		link('User:' .. sock, (function local param = { action = 'edit', preload = 'Template:Checkuser/Preload' .. (master == 'yes' and ' master' or '') }			if master ~= 'yes' then param['preloadparams[]'] = (					mastername and					mastername or					''				) end return param end), 'tag'), 'contribs' .. ' ',		'deleted contribs' .. ' ',		link('Special:Log', {			user = sock		}, 'logs'), link('Special:AbuseLog', {			wpSearchUser = sock		}, 'filter log') .. ' ',		'block user' .. (function			if curtitle:isSubpageOf(mw.title.new(spi)) then				return ( middot .. link('Special:Block', {						wpBlockAddress = sock,						wpExpiry = 'indefinite',						wpReason = 'Abusing multiple accounts',						['wpReason-other'] = 'Please see: ' .. spi .. '/' ..							mw.text.split(curtitle.text, '/')[2] ..						''					}, 'spi block') )			else				return ''			end		end) .. ' ',		link('Special:Log/block', {			page = 'User:' .. sock		}, 'block log'), 'CA' .. ' ',		link('Special:CheckUser', (function local param = { user = sock }			if mw.text.split(curtitle.prefixedText, '/')[1] == spi then param['reason'] = sock .. ' from ' .. curtitle.prefixedText .. '' end return param end), 'CheckUser') .. '(' .. link('Special:CheckUserLog', { cuSearchType = 'target', cuSearch = sock }, 'log') .. ')', link('Special:Investigate', (function local param = { targets = sock }			if curtitle.prefixedText == spi .. '/' .. table.concat({				mw.text.split(curtitle.prefixedText, '/')[2],				mw.text.split(curtitle.prefixedText, '/')[3]			}, '/') then param['reason'] = sock .. ' from ' .. curtitle.prefixedText .. '' end return param end), 'investigate'), extlink(			tostring(mw.uri.new('//checkuser.wikimedia.org/w/index.php'):extend({				title = 'Special:Search',				search = sock,				ns0 = 1,				ns2 = 1,				ns14 = 1			})),			'cuwiki'		) .. ' '	}	span = span:wikitext(table.concat({ noping(sock), '(' .. table.concat(links, middot) .. ')' }, ' '))	return tostring(span) .. '__NOINDEX__' end

function p.ip(frame) local args = getArgs(frame) return p._ip(args['User'] or args[1], args['mastername']) end

function p._ip(ip, mastername) end

return p