Files
Henry_Du d8eee041c8 feat: 明确音频优先级,优化发车音频触发时机
- 到达与发车最高优先级(3),其次是进站预告(2),然后是延误警告(1),最低为背景音乐(0)

- 将发车音乐的触发时机从固定时间改为动态计算(音频时长+1.5秒补偿),确保音频结束时列车刚好发车

- 拆分 handleTrainApproaching 与 handleTrainAlert 逻辑,解耦进站与延误的优先级

- 版本号提升至 v1.0.59
2026-08-04 13:00:04 +08:00

50 lines
1.3 KiB
Lua

function getKeywords(text)
if not text then return {} end
local s = tostring(text):lower()
local keywords = {}
for code in s:gmatch("[%a%d]+%-[%a%d]+") do
keywords[code] = true
end
for code in s:gmatch("%a+%d+") do
keywords[code] = true
end
for zh in s:gmatch("[\128-\255]+") do
local cleanZh = zh:gsub("站台", ""):gsub("轨道", ""):gsub("号", ""):gsub("线", "")
if cleanZh and cleanZh ~= "" then
keywords[cleanZh] = true
end
end
local list = {}
for k, _ in pairs(keywords) do
table.insert(list, k)
end
return list
end
local function test(a, b)
local k1 = getKeywords(a)
local k2 = getKeywords(b)
local match = false
for _, w1 in ipairs(k1) do
for _, w2 in ipairs(k2) do
if w1 == w2 or w1:find(w2, 1, true) or w2:find(w1, 1, true) then
match = true
break
end
end
end
print(a .. " vs " .. b .. " -> " .. tostring(match))
print(" K1: " .. table.concat(k1, ", "))
print(" K2: " .. table.concat(k2, ", "))
end
test("CE-03 (桃园)", "桃园")
test("CE-04", "CE-04 [西门]")
test("CRH-01", "CRH-01 南山线")
test("南山线", "南山")
test("???", "Unknown")