2025-03-07 12:52:37 +01:00
|
|
|
local _, addon = ...
|
|
|
|
|
2025-03-10 13:32:44 +01:00
|
|
|
local function BuildIndex(text)
|
|
|
|
local numberMarks = text:gsub("%d+%.?%d*", "#?")
|
2025-03-20 20:18:54 +01:00
|
|
|
local normalized = numberMarks:gsub('"', "'")
|
|
|
|
return normalized
|
2025-03-10 13:32:44 +01:00
|
|
|
end
|
|
|
|
|
2025-03-07 12:52:37 +01:00
|
|
|
local function FillPlaceholders(text)
|
|
|
|
if text == nil then
|
|
|
|
return text
|
|
|
|
end
|
|
|
|
|
|
|
|
local playerName = UnitName("player")
|
|
|
|
|
|
|
|
local formatted = text;
|
|
|
|
formatted = string.gsub(formatted, '<name>', playerName);
|
|
|
|
|
|
|
|
return formatted
|
|
|
|
end
|
|
|
|
|
|
|
|
local function GetSpeech(message)
|
2025-03-10 13:32:44 +01:00
|
|
|
local index = BuildIndex(message)
|
|
|
|
local speech = addon.data.speech[index];
|
2025-04-17 19:04:49 +02:00
|
|
|
local text = speech and speech.m or nil
|
2025-03-10 13:32:44 +01:00
|
|
|
if text then
|
2025-04-18 14:03:11 +02:00
|
|
|
return FillPlaceholders(
|
|
|
|
addon.API.FillNumbers(text, message)
|
|
|
|
)
|
2025-03-10 13:32:44 +01:00
|
|
|
else
|
|
|
|
return nil
|
|
|
|
end
|
2025-03-07 12:52:37 +01:00
|
|
|
end
|
|
|
|
addon.API.GetSpeech = GetSpeech
|