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