Add emoter and ehcoer
This commit is contained in:
36
Modules/Echoer.lua
Normal file
36
Modules/Echoer.lua
Normal file
@@ -0,0 +1,36 @@
|
||||
local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
|
||||
---@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 not Heimdall_Data.config.echoer.enabled then return end
|
||||
|
||||
local channelId = select(6, ...)
|
||||
local channelname = ""
|
||||
---@type any[]
|
||||
local channels = { GetChannelList() }
|
||||
for i = 1, #channels, 2 do
|
||||
---@type number
|
||||
local id = channels[i]
|
||||
---@type string
|
||||
local name = channels[i + 1]
|
||||
if id == channelId then
|
||||
channelname = name
|
||||
end
|
||||
end
|
||||
|
||||
if channelname ~= Heimdall_Data.config.echoer.masterChannel then return end
|
||||
|
||||
if string.find(msg, "^" .. Heimdall_Data.config.echoer.prefix) then
|
||||
local msg = string.sub(msg, string.len(Heimdall_Data.config.echoer.prefix) + 1)
|
||||
SendChatMessage(msg, "SAY")
|
||||
end
|
||||
end)
|
||||
|
||||
print("Heimdall - Echoer loaded")
|
||||
end
|
||||
Reference in New Issue
Block a user