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 = '&amp;nbsp;&lt;b&gt;&amp;middot;&lt;/b&gt;&amp;#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 name'], args['master'])
 end
 
 function p._user(sock, mastername, master)
 	if not sock then
 		return (
 			'&lt;strong class=&quot;error&quot;&gt;No username provided.&lt;/strong&gt;' ..
 			'[[Category:Checkuser with no specified user]]'
 		)
 	end
 	local span = mw.html.create('span'):attr('class', 'plainlinks cuEntry')
 	local curtitle = mw.title.getCurrentTitle()
 	local links = {
 		'[[User talk:' .. sock .. '|பேச்சு]]' ..
 			'&lt;sup&gt;&lt;span style=&quot;font-size: 120%;&quot;&gt;' ..
 				link('User talk:' .. sock, {
 					action = 'edit',
 					section = 'new'
 				}, '&lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt;') ..
 			'&lt;/span&gt;&lt;/sup&gt;',
 		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
 					'&lt;!-- insert sock master here --&gt;'
 				)
 			end
 			return param
 		end)(), 'tag'),
 		'[[Special:Contributions/' .. sock .. '|பங்களிப்புகள்]]' ..
 			'&lt;span class=&quot;sysop-show&quot;&gt;',
 		'[[Special:DeletedContributions/' .. sock .. '|நீக்கப்பட்ட பங்களிப்புகள்]]' ..
 			'&lt;/span&gt;',
 		link('Special:Log', {
 			user = sock
 		}, 'logs'),
 		link('Special:AbuseLog', {
 			wpSearchUser = sock
 		}, 'filter log') ..
 			'&lt;span class=&quot;sysop-show&quot;&gt;',
 		'[[Special:Block/' .. sock .. '|பயனரைத் தடு]]' ..
 		(function()
 			if curtitle:isSubpageOf(mw.title.new(spi)) then
 				return (
 					middot .. link('Special:Block', {
 						wpBlockAddress = sock,
 						wpExpiry = 'indefinite',
 						wpReason = 'Abusing [[WP:Sock puppetry|multiple accounts]]',
 						['wpReason-other'] = 'Please see: [[:w:en:' .. spi .. '/' ..
 							mw.text.split(curtitle.text, '/')[2] ..
 						']]'
 					}, 'spi block')
 				)
 			else
 				return ''
 			end
 		end)() ..
 			'&lt;/span&gt;',
 		link('Special:Log/block', {
 			page = 'User:' .. sock
 		}, 'block log'),
 		'[[:m:Special:CentralAuth/' .. sock .. '|CA]]' ..
 			'&lt;span class=&quot;cuLink checkuser-show&quot;&gt;',
 		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', {
 			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'
 		) ..
 			'&lt;/span&gt;'
 	}
 	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['master name'])
 end
 
 function p._ip(ip, mastername)
 	if not ip then
 		return (
 			'&lt;strong class=&quot;error&quot;&gt;No username provided.&lt;/strong&gt;' ..
 			'[[Category:Checkip with no specified IP]]'
 		)
 	end
 	local span = mw.html.create('span'):attr('class', 'plainlinks neverexpand cuEntry')
 	local curtitle = mw.title.getCurrentTitle()
 	local links = {
 		'[[User talk:' .. ip .. '|talk]]' ..
 			'&lt;sup&gt;&lt;span style=&quot;font-size: 120%;&quot;&gt;' ..
 				link('User talk:' .. ip, {
 					action = 'edit',
 					section = 'new'
 				}, '&lt;span style=&quot;color: grey&quot;&gt;+&lt;/span&gt;') ..
 			'&lt;/span&gt;&lt;/sup&gt;',
 		link('User:' .. ip, {
 			action = 'edit',
 			preload = 'Template:Checkip/Preload',
 			['preloadparams[]'] = (
 				mastername and
 				mastername or
 				'&lt;!-- Insert sock master name here --&gt;'
 			)
 		}, 'tag'),
 		'[[Special:Contributions/' .. ip .. '|பங்களிப்புகள்]]',
 		link('Special:AbuseLog', {
 			wpSearchUser = ip
 		}, 'filter log'),
 		extlink(
 			tostring(mw.uri.new('//tools.wmflabs.org/whois/gateway.py'):extend({
 				lookup = 'true',
 				ip = ip
 			})),
 			'WHOIS'
 		),
 		extlink(
 			tostring(mw.uri.new('//www.robtex.com/rbls/' .. ip .. '.html')),
 			'RBLs'
 		),
 		extlink(
 			tostring(mw.uri.new('//ipcheck.toolforge.org/index.php'):extend({
 				ip = ip
 			})),
 			'proxy check'
 		) ..
 			'&lt;span class=&quot;sysop-show&quot;&gt;',
 		'[[Special:Block/' .. ip .. '|பயனரைத் தடு]]' .. (function()
 			if curtitle:isSubpageOf(mw.title.new(spi)) then
 				return (
 					middot .. link('Special:Block', {
 						wpTarget = ip,
 						wpReason = 'Abusing [[WP:Sock puppetry|multiple accounts]]',
 						['wpReason-other'] = 'Please see: [[:w:en:' .. spi .. '/' ..
 							mw.text.split(curtitle.text, '/')[2] ..
 						']]'
 					}, 'spi block')
 				)
 			else
 				return ''
 			end
 		end)() ..
 			'&lt;/span&gt;',
 		link('Special:Log/block', {
 			page = 'User:' .. ip
 		}, 'block log'),
 		extlink(
 			tostring(mw.uri.new('//guc.toolforge.org/'):extend({
 				by = 'date',
 				user = ip
 			})),
 			'cross-wiki contribs'
 		) ..
 			'&lt;span class=&quot;cuLink checkuser-show&quot;&gt;',
 		link('Special:CheckUser', (function()
 			local param = {
 				ip = ip
 			}
 			if curtitle.prefixedText == spi .. '/' .. table.concat({
 				mw.text.split(curtitle.prefixedText, '/')[2],
 				mw.text.split(curtitle.prefixedText, '/')[3]
 			}, '/') then
 				param['reason'] = '[[' .. curtitle.prefixedText .. ']]'
 			end
 			return param
 		end)(), 'CheckUser') .. ' ' ..
 		'(' .. link('Special:CheckUserLog', {
 			cuSearch = ip
 		}, 'log') .. ')' ..
 			'&lt;/span&gt;'
 	}
 	span = span:wikitext(table.concat({
 		noping(ip),
 		'(' .. table.concat(links, middot) .. ')'
 	}, ' '))
 	return tostring(span)
 end