Модуль:Unsigned

Википедия сайттаҥ

Реализация шаблона {{Unsigned}}.


local p = {} -- p stands for package

function p.main (frame)
	local arg1 = mw.ustring.gsub(frame:getParent().args[1] or '', '\226\128\142', '') -- invisible ‎ mark
	local arg2 = mw.ustring.gsub(frame:getParent().args[2] or '', '\226\128\142', '') -- invisible ‎ mark
	
	local agent, moment
	if arg2 == nil or arg2 == '' then
		agent = arg1
	else
		if mw.ustring.match(arg1, '[0-9]+ [а-я ј ӱ ҥ]+ 20[0-9]+') then
			agent = arg2
			moment = arg1
		else
			agent = arg1
			moment = arg2
		end
		moment = mw.text.trim(moment)		-- два пробела L-39 ломают «Инструменты обсуждения»
	end
	agent = mw.text.trim(agent) -- пробел в начале ломает ip: Special:Contributions/_ip
	
	if agent == nil or agent == '' then
		return '<span class="error">Unsigned: јастыра параметрлер бичип салган</span>' -- Unsigned: неверные параметры написаны
	end
	
	local res = '<small class="autosigned"> —&nbsp;\'\'Бу реплика ' -- Эта реплика
	
	if mw.ustring.match(agent, '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$')
			or mw.ustring.match(agent, '^[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+$') 
			or mw.ustring.match(agent, '^[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+$') then
		res = res .. '[[Special:Contributions/' .. agent .. '|' .. agent .. ']] ([[User talk:' .. agent .. '|ш]]) IP-туружаачыга' -- IP-участником
	else
		res = res .. --frame:callParserFunction{ name = 'gender', args = { agent, 'участником', 'участницей' } }
			 ' [[User:' .. agent .. '|' .. agent .. ']] ([[User talk:'
			.. agent .. '|ш]] • [[Special:Contributions/' .. agent .. '|к]]) туружаачыга' -- участником
	end
	res = res .. ' бичип салган.' -- написана
	if moment ~= nil and moment ~= '' then
		if not mw.ustring.match(moment, '(+07)') then
			moment = moment .. '&#32;(+07)'  -- L-39
		end
		res = res .. ' ' .. moment
	end
	
	res = res .. '\'\'</small>'
	return frame:preprocess(res)
end

return p