モジュール:サンドボックス/Q8j/UserAN

local p = {} --p はパッケージの p です。この変数名は何でも構いません。
-- target=利用者名、type=type、status=状態
function p.Main( frame )
	--Local宣言
	local username = mw.uri.decode(frame.args'target','WIKI')
	local userping = "利用者:" .. username .. ""
	local usernolink = "利用者:" .. username
	local talk = "会話"
	local contributions = "投稿記録"
	local log = "//ja.wikipedia.org/w/index.php?title=%E7%89%B9%E5%88%A5:Log&page=User:" .. mw.uri.encode(username,"WIKI") .. " 記録"
	local ca = "CA"
	local block = "ブロック"
	local guc = " .. username .. " guc"
	local whois4 = " .. username .. " IPv4"
	local whois6 = " .. username .. " IPv6"
	local forip = "IP:" .. username .. '（' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. guc .. " / Whois " .. whois4 .. " ・ " .. whois6 .. " / " .. block .. "）"
	local forping = userping .. '（' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. ca .. " / " .. block .. "）"
	local forusernolink =  usernolink .. '（' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. ca .. " / " .. block .. "）"
	local icon = {
		done = '済',
		doing = '未了',
		reject = '却下 却下',
	}
	local type2 = string.lower(frame.args"type")
	local statusA = string.lower(frame.args"status")
	local statusB = frame.args"status2"
	-- Local宣言ここまで
	
	-- type判定
	local mtype = ""
		if type2 == "ipuser2" or type2 == "ip2" then
			mtype = forip
		elseif type2 == "none" then
			mtype = username
		elseif type2 == "usernolink" or type2 == "unl" then
			mtype = forusernolink
		elseif type2 == 'diff' then
			mtype = '特別:差分/' .. username .. 'の投稿者'
		elseif type2 == 'logid' then
			mtype = '特別:転送/logid/' .. username .. 'の利用者'
		else
			mtype = forping
		end
	-- type判定ここまで
	-- status判定
	local m_status = ""
		if statusA == "" then
			if statusB =="" then
				m_status = icon.doing
			else
				m_status = icon.done
			end
		elseif statusA == "done" or statusA == "済" or statusA == "済み" then
			m_status = icon.done
		elseif statusA == "not done" or statusA == "却下" or statusA == "非対処" then
			m_status = icon.reject
		else
			m_status = icon.done .. " " .. "" .. frame.args"status" .. ""
		end
	
	-- status判定ここまで
	
	return m_status .. " " .. mtype 
end
function p.test1( frame )
	-- test1。Template‐ノート:UserAN#引数「type」のUserNoLink（UNL）について（Special:Diff/84301971）。提案通りPageIDで転送するもの
	--Local宣言
	local username = mw.uri.decode(frame.args'target','WIKI')
	local userping = "利用者:" .. username .. ""
	local usernolink = "利用者:" .. username
	local talk = "会話"
	local contributions = "投稿記録"
	local log = "//ja.wikipedia.org/w/index.php?title=%E7%89%B9%E5%88%A5:Log&page=User:" .. mw.uri.encode(username,"WIKI") .. " 記録"
	local ca = "CA"
	local block = "ブロック"
	local guc = "//xtools.wmflabs.org/globalcontribs/ipr-" .. username .. " xtool"
	local whois4 = " .. username .. " IPv4"
	local whois6 = " .. username .. " IPv6"
	local forip = "IP:" .. username .. '（' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. guc .. " / Whois " .. whois4 .. " ・ " .. whois6 .. " / " .. block .. "）"
	local forping = userping .. '（' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. ca .. " / " .. block .. "）"
	local forusernolink =  usernolink .. '（' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. ca .. " / " .. block .. "）"
	local icon = {
		done = '済',
		doing = '未了',
		reject = '却下 却下',
	}
	local type2 = string.lower(frame.args"type")
	local statusA = string.lower(frame.args"status")
	local statusB = frame.args"status2"
	-- Local宣言ここまで
	
	-- type判定
	local mtype = ""
		if type2 == "ipuser2" or type2 == "ip2" then
			mtype = forip
		elseif type2 == "none" then
			mtype = username
		elseif type2 == "usernolink" or type2 == "unl" then
			if mw.title.new(username,2).exists then
				mtype = '利用者:' .. username .. '（' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. ca .. " / " .. block .. "）"
			else
				mtype = forusernolink
			end
		else
			mtype = forping
		end
	-- type判定ここまで
	-- status判定
	local m_status = ""
		if statusA == "" then
			if statusB =="" then
				m_status = icon.doing
			else
				m_status = icon.done
			end
		elseif statusA == "done" or statusA == "済" or statusA == "済み" then
			m_status = icon.done
		elseif statusA == "not done" or statusA == "却下" or statusA == "非対処" then
			m_status = icon.reject
		else
			m_status = icon.done .. " " .. "" .. frame.args"status" .. ""
		end
	
	-- status判定ここまで
	
	return m_status .. " " .. mtype 
end
function p.test2( frame )
	-- test1。Template‐ノート:UserAN#引数「type」のUserNoLink（UNL）について（Special:Diff/84301971）。fullurl、plainlinks
	--Local宣言
	local username = mw.uri.decode(frame.args'target','WIKI')
	local userping = "利用者:" .. username .. ""
	local usernolink = "利用者:" .. username
	local talk = "会話"
	local contributions = "投稿記録"
	local log = "//ja.wikipedia.org/w/index.php?title=%E7%89%B9%E5%88%A5:Log&page=User:" .. mw.uri.encode(username,"WIKI") .. " 記録"
	local ca = "CA"
	local block = "ブロック"
	local guc = "//xtools.wmflabs.org/globalcontribs/ipr-" .. username .. " xtool"
	local whois4 = " .. username .. " IPv4"
	local whois6 = " .. username .. " IPv6"
	local forip = "IP:" .. username .. '（' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. guc .. " / Whois " .. whois4 .. " ・ " .. whois6 .. " / " .. block .. "）"
	local forping = userping .. '（' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. ca .. " / " .. block .. "）"
	local forusernolink =  usernolink .. '（' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. ca .. " / " .. block .. "）"
	local icon = {
		done = '済',
		doing = '未了',
		reject = '却下 却下',
	}
	local type2 = string.lower(frame.args"type")
	local statusA = string.lower(frame.args"status")
	local statusB = frame.args"status2"
	-- Local宣言ここまで
	
	-- type判定
	local mtype = ""
		if type2 == "ipuser2" or type2 == "ip2" then
			mtype = forip
		elseif type2 == "none" then
			mtype = username
		elseif type2 == "usernolink" or type2 == "unl" then
			if mw.title.new(username,2).exists then
				mtype =  .. mw.title.new( username , 2 ).fullUrl .. ' 利用者:' .. username .. '（' .. talk .. " / " .. contributions .. " / " .. log .. " / " .. ca .. " / " .. block .. "）"
			else
				mtype = forusernolink
			end
		else
			mtype = forping
		end
	-- type判定ここまで
	-- status判定
	local m_status = ""
		if statusA == "" then
			if statusB =="" then
				m_status = icon.doing
			else
				m_status = icon.done
			end
		elseif statusA == "done" or statusA == "済" or statusA == "済み" then
			m_status = icon.done
		elseif statusA == "not done" or statusA == "却下" or statusA == "非対処" then
			m_status = icon.reject
		else
			m_status = icon.done .. " " .. "" .. frame.args"status" .. ""
		end
	
	-- status判定ここまで
	
	return m_status .. " " .. mtype 
	end
return p