Add emoter and ehcoer

This commit is contained in:
2025-01-01 16:24:01 +01:00
parent 0ec3421a79
commit 36297ca09d
6 changed files with 117 additions and 2 deletions

View File

@@ -33,6 +33,8 @@ local function init()
---@field Dueler InitTable
---@field Bully InitTable
---@field AgentTracker InitTable
---@field Emoter InitTable
---@field Echoer InitTable
--- Config ---
---@class HeimdallConfig
@@ -44,6 +46,8 @@ local function init()
---@field dueler HeimdallDuelerConfig
---@field bully HeimdallBullyConfig
---@field agentTracker HeimdallAgentTrackerConfig
---@field emoter HeimdallEmoterConfig
---@field echoer HeimdallEchoerConfig
---@field whisperNotify table<string, string>
---@field stinkies table<string, boolean>
---@field agents table<string, string>
@@ -97,6 +101,16 @@ local function init()
---@field enabled boolean
---@field masterChannel string
---@class HeimdallEmoterConfig
---@field enabled boolean
---@field masterChannel string
---@field prefix string
---@class HeimdallEchoerConfig
---@field enabled boolean
---@field masterChannel string
---@field prefix string
--- Data ---
---@class HeimdallMessengerData
---@field queue table<string, Message>
@@ -194,6 +208,16 @@ local function init()
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "agentTracker", "enabled" }, false),
masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "agentTracker", "masterChannel" }, "Agent"),
},
emoter = {
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "emoter", "enabled" }, false),
masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "emoter", "masterChannel" }, "Agent"),
prefix = shared.GetOrDefault(Heimdall_Data, { "config", "emoter", "prefix" }, ""),
},
echoer = {
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "echoer", "enabled" }, false),
masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "echoer", "masterChannel" }, "Agent"),
prefix = shared.GetOrDefault(Heimdall_Data, { "config", "echoer", "prefix" }, ""),
},
agents = shared.GetOrDefault(Heimdall_Data, { "config", "agents" }, {}),
}

View File

@@ -15,4 +15,6 @@ Modules/Inviter.lua
Modules/Dueler.lua
Modules/Bully.lua
Modules/AgentTracker.lua
Modules/Emoter.lua
Modules/Echoer.lua
Heimdall.lua

BIN
Heimdall.zip LFS

Binary file not shown.

36
Modules/Echoer.lua Normal file
View 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

35
Modules/Emoter.lua Normal file
View File

@@ -0,0 +1,35 @@
local addonname, shared = ...
---@cast shared HeimdallShared
---@cast addonname string
---@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 not Heimdall_Data.config.emoter.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.emoter.masterChannel then return end
if string.find(msg, "^" .. Heimdall_Data.config.emoter.prefix) then
local emote = string.sub(msg, string.len(Heimdall_Data.config.emoter.prefix) + 1)
DoEmote(emote)
end
end)
print("Heimdall - Emoter loaded")
end

View File

@@ -82,6 +82,16 @@ local config = {
enabled = aura_env.config.agentTracker.enabled,
masterChannel = aura_env.config.agentTracker.masterChannel,
},
emoter = {
enabled = aura_env.config.emoter.enabled,
masterChannel = aura_env.config.emoter.masterChannel,
prefix = aura_env.config.emoter.prefix,
},
echoer = {
enabled = aura_env.config.echoer.enabled,
masterChannel = aura_env.config.echoer.masterChannel,
prefix = aura_env.config.echoer.prefix,
},
}
Heimdall_Data.config.spotter.enabled = config.spotter.enabled
@@ -125,5 +135,13 @@ Heimdall_Data.config.bully.enabled = config.bully.enabled
Heimdall_Data.config.agentTracker.enabled = config.agentTracker.enabled
Heimdall_Data.config.agentTracker.masterChannel = config.agentTracker.masterChannel
Heimdall_Data.config.emoter.enabled = config.emoter.enabled
Heimdall_Data.config.emoter.masterChannel = config.emoter.masterChannel
Heimdall_Data.config.emoter.prefix = config.emoter.prefix
Heimdall_Data.config.echoer.enabled = config.echoer.enabled
Heimdall_Data.config.echoer.masterChannel = config.echoer.masterChannel
Heimdall_Data.config.echoer.prefix = config.echoer.prefix
Heimdall_Data.config.whisperNotify = config.whisperNotify
Heimdall_Data.config.stinkies = config.stinkies