67 lines
2.1 KiB
Lua
67 lines
2.1 KiB
Lua
local _, shared = ...
|
|
---@cast shared HeimdallShared
|
|
local ModuleName = "Emoter"
|
|
|
|
---@class HeimdallEmoterConfig
|
|
---@field enabled boolean
|
|
---@field debug boolean
|
|
---@field channels string[]
|
|
---@field prefix string
|
|
|
|
---@class Emoter
|
|
shared.Emoter = {
|
|
Init = function()
|
|
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] Channel message received from: %s", ModuleName, sender))
|
|
--end
|
|
|
|
if not Heimdall_Data.config.emoter.enabled then
|
|
--if Heimdall_Data.config.emoter.debug then
|
|
-- print(string.format("[%s] Module disabled, ignoring message", ModuleName))
|
|
--end
|
|
return
|
|
end
|
|
|
|
local channelId = select(6, ...)
|
|
local _, channelname = GetChannelName(channelId)
|
|
local ok = false
|
|
for _, channel in pairs(Heimdall_Data.config.emoter.channels) do
|
|
if channel == channelname then
|
|
ok = true
|
|
break
|
|
end
|
|
end
|
|
if not ok then
|
|
if Heimdall_Data.config.emoter.debug then
|
|
print(string.format("[%s] Channel name does not match any of the channels", ModuleName))
|
|
end
|
|
return
|
|
end
|
|
|
|
if Heimdall_Data.config.emoter.debug then
|
|
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
|
|
shared.dump(Heimdall_Data.config.emoter)
|
|
end
|
|
|
|
if string.find(msg, "^" .. Heimdall_Data.config.emoter.prefix) then
|
|
if Heimdall_Data.config.emoter.debug then
|
|
print(string.format("[%s] Found emote command in message: %s", ModuleName, msg))
|
|
end
|
|
local emote = string.sub(msg, string.len(Heimdall_Data.config.emoter.prefix) + 1)
|
|
if Heimdall_Data.config.emoter.debug then
|
|
print(string.format("[%s] Performing emote: %s", ModuleName, emote))
|
|
end
|
|
DoEmote(emote)
|
|
elseif Heimdall_Data.config.emoter.debug then
|
|
print(string.format("[%s] Message does not start with emote prefix", ModuleName))
|
|
end
|
|
end)
|
|
|
|
if Heimdall_Data.config.emoter.debug then print(string.format("[%s] Module initialized", ModuleName)) end
|
|
print(string.format("[%s] Module initialized", ModuleName))
|
|
end,
|
|
}
|