36 lines
1.2 KiB
Lua
36 lines
1.2 KiB
Lua
local addonname, shared = ...
|
|
---@cast shared HeimdallShared
|
|
---@cast addonname string
|
|
local ModuleName = "Echoer"
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
|
shared.Echoer = {}
|
|
function shared.Echoer.Init()
|
|
local frame = CreateFrame("Frame")
|
|
frame:RegisterEvent("CHAT_MSG_CHANNEL")
|
|
frame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
|
if Heimdall_Data.config.echoer.debug then
|
|
print(string.format("%s: OnEvent", ModuleName))
|
|
shared.dumpTable(Heimdall_Data.config.echoer)
|
|
end
|
|
if not Heimdall_Data.config.echoer.enabled then return end
|
|
|
|
local channelId = select(6, ...)
|
|
local _, channelname = GetChannelName(channelId)
|
|
if Heimdall_Data.config.echoer.debug then
|
|
print(string.format("%s: channelname = %s", ModuleName, channelname))
|
|
end
|
|
if channelname ~= Heimdall_Data.config.echoer.masterChannel then return end
|
|
|
|
if string.find(msg, "^" .. Heimdall_Data.config.echoer.prefix) then
|
|
if Heimdall_Data.config.echoer.debug then
|
|
print(string.format("%s: msg = %s", ModuleName, msg))
|
|
end
|
|
local msg = string.sub(msg, string.len(Heimdall_Data.config.echoer.prefix) + 1)
|
|
SendChatMessage(msg, "SAY")
|
|
end
|
|
end)
|
|
|
|
print("Heimdall - Echoer loaded")
|
|
end
|