وحدة: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 = '&nbsp;<b>&middot;</b>&#32;'
local spi = 'أرابيكا:طلب تدقيق مستخدم'
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['مستخدم'], args['master name'], args['master'], args['رئيسي'], args['المستخدم الرئيسي'])
end

function p._user(sock, mastername, master)
	if not sock then
		return (
			'<strong class="error">لم يحدد اسم المستخدم.</strong>' ..
			'[[تصنيف:مدقق مستخدم دون مستخدم محدد]]'
		)
	end
	local span = mw.html.create('span'):attr('class', 'plainlinks cuEntry')
	local curtitle = mw.title.getCurrentTitle()
	local links = {
		'[[نقاش المستخدم:' .. sock .. '|نقاش]]' ..
			'<sup><span style="font-size: 120%;">' ..
				link('نقاش المستخدم:' .. sock, {
					action = 'edit',
					section = 'new'
				}, '<span style="color: grey;">+</span>') ..
			'</span></sup>',
		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)(), 'وسم'),
		'[[Special:Contributions/' .. sock .. '|مساهمات]]' ..
			'<span class="sysop-show">',
		'[[Special:DeletedContributions/' .. sock .. '|مساهمات محذوفة]]' ..
			'</span>',
		link('Special:Log', {
			user = sock
		}, 'سجلات'),
		link('Special:AbuseLog', {
			wpSearchUser = sock
		}, 'سجل الإساءة') ..
			'<span class="sysop-show">',
		'[[Special:Block/' .. sock .. '|منع المستخدم]]' ..
		(function()
			if curtitle:isSubpageOf(mw.title.new(spi)) then
				return (
					middot .. link('Special:Block', {
						wpBlockAddress = sock,
						wpExpiry = 'دائم',
						wpReason = '[https://ar.wikipedia.org/w/index.php?title=خاص:تدقيق_مستخدم&user={{urlencode:{{{1}}}}}&uselang=ar&reason={{urlencode:[[خاص:وصلة دائمة/{{REVISIONID}}|طلب]]}}',
						['wpReason-other'] = 'لطفًا انظر: [[:w:ar:' .. spi .. '/' ..
							mw.text.split(curtitle.text, '/')[2] ..
						']]'
					}, 'spi block')
				)
			else
				return ''
			end
		end)() ..
			'</span>',
		link('Special:Log/block', {
			page = 'User:' .. sock
		}, 'سجل المنع'),
		'[[:m:Special:CentralAuth/' .. sock .. '|سجل الحساب الموحد]]' ..
			'<span class="cuLink checkuser-show">',
		link('Special:CheckUser', (function()
			local param = {
				user = sock
			}
			if mw.text.split(curtitle.prefixedText, '/')[1] == spi then
				param['السبب'] = sock .. ' from [[' .. curtitle.prefixedText .. ']]'
			end
			return param
		end)(), 'تدقيق المستخدم') ..
		'(' .. link('Special:CheckUserLog', {
			cuSearch = sock
		}, 'سجلات') .. ')',
		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['السبب'] = sock .. ' from [[' .. curtitle.prefixedText .. ']]'
			end
			return param
		end)(), 'investigate'),
		extlink(
			tostring(mw.uri.new('https://checkuser.wikimedia.org/w/index.php'):extend({
				title = 'Special:Search',
				search = sock,
				ns0 = 1,
				ns2 = 1,
				ns14 = 1
			})),
			'cuwiki'
		) ..
			'</span>'
	}
	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'], args['مستخدم'], args['رئيسي'], args['المستخدم الرئيسي'])
end

function p._ip(ip, mastername)
	if not ip then
		return (
			'<strong class="error">No username provided.</strong>' ..
			'[[تصنيف:تدقيق آيبي مع معرف رقمي غير محدد]]'
		)
	end
	local span = mw.html.create('span'):attr('class', 'plainlinks neverexpand cuEntry')
	local curtitle = mw.title.getCurrentTitle()
	local links = {
		'[[User talk:' .. ip .. '|نقاش]]' ..
			'<sup><span style="font-size: 120%;">' ..
				link('نقاش المستخدم:' .. ip, {
					action = 'edit',
					section = 'new'
				}, '<span style="color: grey">+</span>') ..
			'</span></sup>',
		link('User:' .. ip, {
			action = 'edit',
			preload = 'Template:Checkip/Preload',
			['preloadparams[]'] = (
				mastername and
				mastername or
				'<!-- Insert sock master name here -->'
			)
		}, 'وسم'),
		'[[Special:Contributions/' .. ip .. '|مساهمات]]',
		link('Special:AbuseLog', {
			wpSearchUser = ip
		}, 'سجل الإساءة'),
		extlink(
			tostring(mw.uri.new('https://tools.wmflabs.org/whois/gateway.py'):extend({
				lookup = 'true',
				ip = ip
			})),
			'WHOIS'
		),
		extlink(
			tostring(mw.uri.new('https://www.robtex.com/rbls/' .. ip .. '.html')),
			'RBLs'
		),
		extlink(
			tostring(mw.uri.new('https://ipcheck.toolforge.org/index.php'):extend({
				ip = ip
			})),
			'فحص الوكيل'
		) ..
			'<span class="sysop-show">',
		'[[Special:Block/' .. ip .. '|منع المستخدم]]' .. (function()
			if curtitle:isSubpageOf(mw.title.new(spi)) then
				return (
					middot .. link('Special:Block', {
						wpTarget = ip,
						wpReason = 'إساءة استخدام [[WP:Sock puppetry|حسابات متعددة]]',
						['wpReason-other'] = 'لطفًا أنظر: [[:w:ar:' .. spi .. '/' ..
							mw.text.split(curtitle.text, '/')[2] ..
						']]'
					}, 'spi block')
				)
			else
				return ''
			end
		end)() ..
			'</span>',
		link('Special:Log/block', {
			page = 'User:' .. ip
		}, 'سجل المنع'),
		extlink(
			tostring(mw.uri.new('https://guc.toolforge.org/'):extend({
				by = 'date',
				user = ip
			})),
			'مساهمات عبر الويكي'
		) ..
			'<span class="cuLink checkuser-show">',
		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['السبب'] = '[[' .. curtitle.prefixedText .. ']]'
			end
			return param
		end)(), 'تدقيق المستخدم') .. ' ' ..
		'(' .. link('Special:CheckUserLog', {
			cuSearch = ip
		}, 'سجلات') .. ')' ..
			'</span>'
	}
	span = span:wikitext(table.concat({
		noping(ip),
		'(' .. table.concat(links, middot) .. ')'
	}, ' '))
	return tostring(span)
end

return p