<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh">
	<id>https://arolstar52-zhtest.hf.space/index.php?action=history&amp;feed=atom&amp;title=Module%3ATeam_appearances_list</id>
	<title>Module:Team appearances list - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://arolstar52-zhtest.hf.space/index.php?action=history&amp;feed=atom&amp;title=Module%3ATeam_appearances_list"/>
	<link rel="alternate" type="text/html" href="https://arolstar52-zhtest.hf.space/index.php?title=Module:Team_appearances_list&amp;action=history"/>
	<updated>2026-06-28T01:22:27Z</updated>
	<subtitle>在这个wiki上该页的修订历史</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://arolstar52-zhtest.hf.space/index.php?title=Module:Team_appearances_list&amp;diff=2872836&amp;oldid=prev</id>
		<title>imported&gt;Ericliu1912：​cc. Liu116</title>
		<link rel="alternate" type="text/html" href="https://arolstar52-zhtest.hf.space/index.php?title=Module:Team_appearances_list&amp;diff=2872836&amp;oldid=prev"/>
		<updated>2026-05-28T14:06:54Z</updated>

		<summary type="html">&lt;p&gt;cc. &lt;a href=&quot;/index.php?title=User:Liu116&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;User:Liu116（页面不存在）&quot;&gt;Liu116&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module implements [[Template:Team appearances list]].&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local data_competitions&lt;br /&gt;
local country_alias_data&lt;br /&gt;
local country_alias&lt;br /&gt;
&lt;br /&gt;
-- 代表团写法&lt;br /&gt;
local linksuffix = {&lt;br /&gt;
	[&amp;#039;zh&amp;#039;] = &amp;quot;代表团&amp;quot;,&lt;br /&gt;
	[&amp;#039;zh-hans&amp;#039;] = &amp;quot;代表团&amp;quot;,&lt;br /&gt;
	[&amp;#039;zh-cn&amp;#039;] = &amp;quot;代表团&amp;quot;,&lt;br /&gt;
	[&amp;#039;zh-sg&amp;#039;] = &amp;quot;代表团&amp;quot;,&lt;br /&gt;
	[&amp;#039;zh-my&amp;#039;] = &amp;quot;代表团&amp;quot;,&lt;br /&gt;
	[&amp;#039;zh-hant&amp;#039;] = &amp;quot;代表團&amp;quot;,&lt;br /&gt;
	[&amp;#039;zh-hk&amp;#039;] = &amp;quot;代表團&amp;quot;,&lt;br /&gt;
	[&amp;#039;zh-mo&amp;#039;] = &amp;quot;代表團&amp;quot;,&lt;br /&gt;
	[&amp;#039;zh-tw&amp;#039;] = &amp;quot;代表團&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local function load_data(frame)&lt;br /&gt;
	frame = frame or mw.getCurrentFrame()&lt;br /&gt;
	-- 根据模块是否以sandbox作为结尾决定引用sandbox模块还是正式模块&lt;br /&gt;
	local sandbox = frame:getTitle():find(&amp;#039;sandbox&amp;#039;, 1, true) and &amp;#039;/sandbox&amp;#039; or &amp;#039;&amp;#039;&lt;br /&gt;
	local datamod = mw.loadData(&amp;#039;Module:Team appearances list/data&amp;#039; .. sandbox)&lt;br /&gt;
	if not data_competitions then&lt;br /&gt;
		data_competitions = datamod&lt;br /&gt;
	end&lt;br /&gt;
	if not country_alias_data then&lt;br /&gt;
		country_alias_data = mw.loadData(&amp;#039;Module:Country alias/data&amp;#039; .. sandbox)&lt;br /&gt;
	end&lt;br /&gt;
	if not country_alias then&lt;br /&gt;
		country_alias = require(&amp;#039;Module:Country alias&amp;#039; .. sandbox)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function strip_to_nil(text)&lt;br /&gt;
	-- If text is a string, return its trimmed content, or nil if empty.&lt;br /&gt;
	-- Otherwise return text (which may, for example, be nil).&lt;br /&gt;
	if type(text) == &amp;#039;string&amp;#039; then&lt;br /&gt;
		text = text:match(&amp;#039;(%S.-)%s*$&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	return text&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function make_options(args, frame)&lt;br /&gt;
	-- Return table of options from validated args or throw error.&lt;br /&gt;
	local options = {}&lt;br /&gt;
	local function valid_integer(name, min, max, is_optional)&lt;br /&gt;
		local arg = args[name]&lt;br /&gt;
		if arg == nil or arg == &amp;#039;&amp;#039; then&lt;br /&gt;
			if is_optional then&lt;br /&gt;
				return nil&lt;br /&gt;
			end&lt;br /&gt;
			error(&amp;#039;缺少&amp;#039; .. name .. &amp;#039;参数&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
		arg = tonumber(arg)&lt;br /&gt;
		if type(arg) ~= &amp;#039;number&amp;#039; then&lt;br /&gt;
			error(&amp;#039;参数&amp;#039; .. name .. &amp;#039;非数字&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
		if math.floor(arg) ~= arg then&lt;br /&gt;
			error(&amp;#039;参数&amp;#039; .. name .. &amp;#039;非整数&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
		if not (min &amp;lt;= arg and arg &amp;lt;= max) then&lt;br /&gt;
			error(&amp;#039;参数&amp;#039; .. name .. &amp;#039;无效&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
		return arg&lt;br /&gt;
	end&lt;br /&gt;
	local function valid_text(name)&lt;br /&gt;
		local arg = args[name]&lt;br /&gt;
		if arg == nil or arg == &amp;#039;&amp;#039; then&lt;br /&gt;
			error(&amp;#039;缺少&amp;#039; .. name .. &amp;#039;参数&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
		if type(arg) ~= &amp;#039;string&amp;#039; then&lt;br /&gt;
			error(&amp;#039;参数&amp;#039; .. name .. &amp;#039;非字符串&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
		return arg&lt;br /&gt;
	end&lt;br /&gt;
	options.lan = args[&amp;quot;lan&amp;quot;] or frame:callParserFunction{ name = &amp;#039;int&amp;#039;, args = {&amp;#039;Conversionname&amp;#039;} }&lt;br /&gt;
	local temp = linksuffix[options.lan]&lt;br /&gt;
	if temp == nil then&lt;br /&gt;
		options.lan = &amp;#039;zh&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	options.competition = valid_text(&amp;#039;competition&amp;#039;)&lt;br /&gt;
	options.team = valid_text(&amp;#039;team&amp;#039;)&lt;br /&gt;
	options.competitions = data_competitions.competitions[data_competitions.competitionsAliases[options.competition]]&lt;br /&gt;
	local begin_optional&lt;br /&gt;
	if options.competitions then&lt;br /&gt;
		begin_optional = true&lt;br /&gt;
	else&lt;br /&gt;
		options.interval = valid_integer(&amp;#039;interval&amp;#039;, 1, 30)&lt;br /&gt;
	end&lt;br /&gt;
	options.begin_year = valid_integer(&amp;#039;begin_year&amp;#039;, 1800, 2100, begin_optional)&lt;br /&gt;
	options.end_year = valid_integer(&amp;#039;end_year&amp;#039;, 1800, 2100, true)&lt;br /&gt;
	if options.begin_year and options.end_year then&lt;br /&gt;
		if options.begin_year &amp;gt; options.end_year then&lt;br /&gt;
			error(&amp;#039;参数end_year的值不得小于参数begin_year的值&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return options&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function extract_range(text)&lt;br /&gt;
	-- Return first (if text is a single year), or first, last if a range.&lt;br /&gt;
	-- The returned values are numbers.&lt;br /&gt;
	-- Return nothing if text is invalid.&lt;br /&gt;
	local year = text:match(&amp;#039;^(%d+)$&amp;#039;)&lt;br /&gt;
	if year then&lt;br /&gt;
		if #year == 4 then&lt;br /&gt;
			return tonumber(year)&lt;br /&gt;
		end&lt;br /&gt;
		return&lt;br /&gt;
	end&lt;br /&gt;
	local first, dash, last = text:match(&amp;#039;^(%d+)(%D+)(%d+)$&amp;#039;)&lt;br /&gt;
	if not (first and #first == 4) then&lt;br /&gt;
		return&lt;br /&gt;
	end&lt;br /&gt;
	dash = strip_to_nil(dash)&lt;br /&gt;
	if not (dash == &amp;#039;-&amp;#039; or dash == &amp;#039;–&amp;#039; or dash == &amp;#039;—&amp;#039;) then&lt;br /&gt;
		return&lt;br /&gt;
	end&lt;br /&gt;
	if #last ~= 4 then&lt;br /&gt;
		if #last == 2 then&lt;br /&gt;
			last = first:sub(1, 2) .. last&lt;br /&gt;
		else&lt;br /&gt;
			return&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	first = tonumber(first)&lt;br /&gt;
	last = tonumber(last)&lt;br /&gt;
	if first &amp;lt; last then&lt;br /&gt;
		return first, last&lt;br /&gt;
	elseif first == last then&lt;br /&gt;
		return first&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function competition_absences_action(data, absent_years, absent_ranges)&lt;br /&gt;
	for _, item in ipairs(data) do&lt;br /&gt;
		if type(item) == &amp;#039;number&amp;#039; then&lt;br /&gt;
			absent_years[item] = true&lt;br /&gt;
		else&lt;br /&gt;
			item = strip_to_nil(item)&lt;br /&gt;
			if type(item) == &amp;#039;string&amp;#039; then&lt;br /&gt;
				local first, last = extract_range(item)&lt;br /&gt;
				if not first then&lt;br /&gt;
					error(&amp;#039;Year &amp;#039; .. item .. &amp;#039; is not valid&amp;#039;)&lt;br /&gt;
				end&lt;br /&gt;
				if last then&lt;br /&gt;
					table.insert(absent_ranges, {first, last})&lt;br /&gt;
				else&lt;br /&gt;
					absent_years[first] = true&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return absent_years, absent_ranges&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function competition_absences(data, hasTable)&lt;br /&gt;
	-- Return two tables with absent years and absent year ranges.&lt;br /&gt;
	-- Parameter data is an array of strings from template parameters, or&lt;br /&gt;
	-- numbers or strings from built-in data.&lt;br /&gt;
	-- Parameters that are blank or not numbers or strings are ignored.&lt;br /&gt;
	local absent_years, absent_ranges = {}, {}&lt;br /&gt;
	if hasTable then&lt;br /&gt;
		for _, y in ipairs(data) do&lt;br /&gt;
			if type(y) == &amp;#039;table&amp;#039; then&lt;br /&gt;
				absent_years, absent_ranges = competition_absences_action(y, absent_years, absent_ranges)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		absent_years, absent_ranges = competition_absences_action(data, absent_years, absent_ranges)&lt;br /&gt;
	end&lt;br /&gt;
	return absent_years, absent_ranges&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function competition_information(args, frame)&lt;br /&gt;
	-- Return four tables with competition and team information:&lt;br /&gt;
	-- * List of competition years that the team attended or could have attended.&lt;br /&gt;
	-- * Table of absent years (when the team did not attend).&lt;br /&gt;
	-- * List of pairs of years (absent for each year in range, inclusive).&lt;br /&gt;
	-- 英文版的disqualified_year参数由于目前只支持一个年份，故暂时不添加支持&lt;br /&gt;
	local options = make_options(args, frame)&lt;br /&gt;
	local absences&lt;br /&gt;
	local comp_years = {}&lt;br /&gt;
	local aliases = {}&lt;br /&gt;
	local notes = {}&lt;br /&gt;
	local alias_args = {&lt;br /&gt;
		games = options.competition,&lt;br /&gt;
		lan = options.lan&lt;br /&gt;
	}&lt;br /&gt;
	local begin_year = options.begin_year&lt;br /&gt;
	local end_year = options.end_year&lt;br /&gt;
	local competitions = options.competitions&lt;br /&gt;
	local hasTable = nil&lt;br /&gt;
	alias_args.alias = options.team&lt;br /&gt;
	aliases[options.team] = country_alias.countryAlias2(alias_args, frame)&lt;br /&gt;
	if competitions then&lt;br /&gt;
		absences = competitions[options.team] &lt;br /&gt;
				or competitions[data_competitions.codeAliases[options.team]] &lt;br /&gt;
				or competitions[country_alias_data.countryAliases[options.team]]&lt;br /&gt;
		if absences then&lt;br /&gt;
			for _, y in ipairs(absences) do&lt;br /&gt;
				if type(y) == &amp;#039;table&amp;#039; then&lt;br /&gt;
					hasTable = true&lt;br /&gt;
					begin_year = y.begin_year or options.begin_year or 1800&lt;br /&gt;
					if y.begin_year and options.begin_year then&lt;br /&gt;
						begin_year = y.begin_year &amp;gt; options.begin_year and y.begin_year or options.begin_year&lt;br /&gt;
					end&lt;br /&gt;
					end_year = y.end_year or options.end_year or 2100&lt;br /&gt;
					if y.end_year and options.end_year then&lt;br /&gt;
						end_year = y.end_year &amp;lt; options.end_year and y.end_year or options.end_year&lt;br /&gt;
					end&lt;br /&gt;
					local alias = y.link_alias or options.team&lt;br /&gt;
					for _, z in ipairs(competitions) do&lt;br /&gt;
						if z &amp;gt; end_year then&lt;br /&gt;
							break&lt;br /&gt;
						elseif z &amp;gt;= begin_year then&lt;br /&gt;
							table.insert(comp_years, {z, alias})&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
					if not aliases[alias] then&lt;br /&gt;
						alias_args.alias = alias&lt;br /&gt;
						aliases[alias] = country_alias.countryAlias2(alias_args, frame)&lt;br /&gt;
					end&lt;br /&gt;
					if absences.note == &amp;#039;yes&amp;#039; and aliases[alias][1] ~= aliases[options.team][1] &lt;br /&gt;
					and not notes[alias] then&lt;br /&gt;
						table.insert(notes, alias)&lt;br /&gt;
						notes[alias] = #notes&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if not hasTable then&lt;br /&gt;
			begin_year = options.begin_year or (absences and absences.begin_year) or 1800&lt;br /&gt;
			end_year = options.end_year or (absences and absences.end_year) or 2100&lt;br /&gt;
			local alias = (absences and absences.link_alias) or options.team&lt;br /&gt;
			for _, y in ipairs(competitions) do&lt;br /&gt;
				if y &amp;gt; end_year then&lt;br /&gt;
					break&lt;br /&gt;
				elseif y &amp;gt;= begin_year then&lt;br /&gt;
					table.insert(comp_years, {y, alias})&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if not aliases[alias] then&lt;br /&gt;
				alias_args.alias = alias&lt;br /&gt;
				aliases[alias] = country_alias.countryAlias2(alias_args, frame)&lt;br /&gt;
			end&lt;br /&gt;
			if absences and absences.note == &amp;#039;yes&amp;#039; and aliases[alias][1] ~= aliases[options.team][1] &lt;br /&gt;
			and not notes[alias] then&lt;br /&gt;
				table.insert(notes, alias)&lt;br /&gt;
				notes[alias] = #notes&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		end_year = end_year or (os.date(&amp;#039;!*t&amp;#039;).year + options.interval)&lt;br /&gt;
		for y = begin_year, end_year, options.interval do&lt;br /&gt;
			table.insert(comp_years, {y, options.team})&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return comp_years, aliases, notes, competition_absences(absences or args, hasTable)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args, frame)&lt;br /&gt;
	load_data()  -- in case this function is called by another module&lt;br /&gt;
	local hlist = require(&amp;#039;Module:List&amp;#039;).horizontal&lt;br /&gt;
	local competitions, aliases, notes, absent_years, absent_ranges = competition_information(args, frame)&lt;br /&gt;
	local current_year = os.date(&amp;#039;!*t&amp;#039;).year&lt;br /&gt;
	local suff = &amp;#039;&amp;#039;&lt;br /&gt;
	if args.suffix and string.lower(args.suffix) == &amp;#039;yes&amp;#039; then&lt;br /&gt;
		suff = &amp;#039;年&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	local comp_name = {}&lt;br /&gt;
	local function is_absent(y)&lt;br /&gt;
		if absent_years[y] then&lt;br /&gt;
			return true&lt;br /&gt;
		end&lt;br /&gt;
		for _, range in ipairs(absent_ranges) do&lt;br /&gt;
			if range[1] &amp;lt;= y and y &amp;lt;= range[2] then&lt;br /&gt;
				return true&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
	local appearances = {}&lt;br /&gt;
	local absent_first, absent_last&lt;br /&gt;
	for i = 1, #competitions + 1 do&lt;br /&gt;
		local y&lt;br /&gt;
		local alias&lt;br /&gt;
		if competitions[i] then&lt;br /&gt;
			y = competitions[i][1]&lt;br /&gt;
			alias = competitions[i][2]&lt;br /&gt;
		end&lt;br /&gt;
		if y and is_absent(y) then&lt;br /&gt;
			if absent_first then&lt;br /&gt;
				absent_last = y&lt;br /&gt;
			else&lt;br /&gt;
				absent_first = y&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			if absent_first then&lt;br /&gt;
				table.insert(appearances,&lt;br /&gt;
					&amp;#039;&amp;lt;span style=&amp;quot;color:gray&amp;quot;&amp;gt;&amp;#039; ..&lt;br /&gt;
					(absent_last and (absent_first .. suff .. &amp;#039;–&amp;#039; .. absent_last) or absent_first) .. suff ..&lt;br /&gt;
					&amp;#039;&amp;lt;/span&amp;gt;&amp;#039;)&lt;br /&gt;
				absent_first, absent_last = nil, nil&lt;br /&gt;
			end&lt;br /&gt;
			if y then&lt;br /&gt;
				local name = aliases[alias][1]&lt;br /&gt;
				local lang = aliases[alias][2]&lt;br /&gt;
				if not comp_name[lang] then&lt;br /&gt;
					comp_name[lang] = country_alias.getGames(args.competition, lang)&lt;br /&gt;
				end&lt;br /&gt;
				local display = tostring(y)&lt;br /&gt;
				if y &amp;gt; current_year then&lt;br /&gt;
					display = &amp;#039;&amp;lt;i&amp;gt;&amp;#039; .. display .. &amp;#039;&amp;lt;/i&amp;gt;&amp;#039;&lt;br /&gt;
				end&lt;br /&gt;
				local note = &amp;#039;&amp;#039;&lt;br /&gt;
				if notes[alias] then&lt;br /&gt;
					note = &amp;#039;&amp;lt;sup&amp;gt;&amp;#039; .. tostring(notes[alias]) .. &amp;#039;&amp;lt;/sup&amp;gt;&amp;#039;&lt;br /&gt;
				end&lt;br /&gt;
				table.insert(appearances, string.format(&lt;br /&gt;
					&amp;#039;[[%d年%s%s%s|%s&amp;#039; .. suff .. &amp;#039;]]%s&amp;#039;,&lt;br /&gt;
					y, comp_name[lang], name, linksuffix[lang], display, note&lt;br /&gt;
				))&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local bottom = &amp;#039;&amp;#039;&lt;br /&gt;
	if #appearances &amp;gt; 0 and #notes &amp;gt; 0 then&lt;br /&gt;
		bottom = &amp;#039;&amp;lt;p style=&amp;quot;font-size:90%;margin:0 auto;&amp;quot;&amp;gt;&amp;#039;&lt;br /&gt;
		for j = 1, #notes do&lt;br /&gt;
			bottom = bottom .. &amp;#039;&amp;lt;sup&amp;gt;&amp;#039; .. j .. &amp;#039;&amp;lt;/sup&amp;gt;&amp;amp;nbsp;以“&amp;#039; .. aliases[notes[j]][1] .. &amp;#039;”名义参赛&amp;#039;&lt;br /&gt;
			if j &amp;lt; #notes then&lt;br /&gt;
				bottom = bottom .. &amp;#039;&amp;lt;br/&amp;gt;&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		bottom = bottom .. &amp;#039;&amp;lt;/p&amp;gt;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	return hlist(appearances) .. bottom&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	load_data(frame)&lt;br /&gt;
	return p._main(frame:getParent().args, frame)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Ericliu1912</name></author>
	</entry>
</feed>