local _, addon = ...

local function FillPlaceholders(text)
    if text == nil then
        return text
    end

    local playerName = UnitName("player")

    local formatted = text;
    formatted = string.gsub(formatted, '<name>', playerName);
    formatted = string.gsub(formatted, 'Champions', playerName);
    formatted = string.gsub(formatted, 'champions', playerName);

    return formatted
end

local function GetSpeech(message)
    local speech = addon.data.speech[message];
    local text = speech and speech.text or nil
    return FillPlaceholders(text)
end
addon.API.GetSpeech = GetSpeech