80 lines
2.9 KiB
Lua
80 lines
2.9 KiB
Lua
local addonname, shared = ...
|
|
---@cast addonname string
|
|
|
|
---@class DechickenatorData
|
|
---@field blacklistedBuffs table<string, boolean>
|
|
|
|
---@alias auraType
|
|
---| 'BUFF'
|
|
---| 'DEBUFF'
|
|
|
|
-- Lifebloom;B;R;e:spit;m:cuntfucker;c:YELL
|
|
---@class Alert
|
|
---@field message string?
|
|
---@field channel string?
|
|
---@field emote string?
|
|
---@field spellName string
|
|
---@field auraType string?
|
|
---@field remove boolean
|
|
|
|
if not Dechickenator_Data then Dechickenator_Data = {} end
|
|
if not Dechickenator_Data.alerts then Dechickenator_Data.alerts = {} end
|
|
local function init()
|
|
local cleuFrame = CreateFrame("Frame")
|
|
cleuFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
|
|
cleuFrame:SetScript("OnEvent", function(self, event, ...)
|
|
local subevent = CLEUParser.GetSubevent(...)
|
|
if subevent == "SPELL_AURA_APPLIED" or subevent == "SPELL_AURA_REFRESH" then
|
|
local target = CLEUParser.GetDestName(...)
|
|
if target ~= UnitName("player") then return end
|
|
local spellName = CLEUParser.GetSpellName(...)
|
|
if not Dechickenator_Data.alerts[spellName] then return end
|
|
local source = CLEUParser.GetSourceName(...)
|
|
if Dechickenator_Data.alerts[spellName].message then
|
|
local msg = Dechickenator_Data.alerts[spellName].message
|
|
if string.find(msg, "%s") then
|
|
msg = string.format(msg, tostring(source))
|
|
end
|
|
local channel = "SAY"
|
|
if Dechickenator_Data.alerts[spellName].channel then
|
|
channel = Dechickenator_Data.alerts[spellName].channel
|
|
end
|
|
SendChatMessage(msg, channel)
|
|
end
|
|
if Dechickenator_Data.alerts[spellName].emote then
|
|
DoEmote(Dechickenator_Data.alerts[spellName].emote, source)
|
|
end
|
|
if Dechickenator_Data.alerts[spellName].remove then
|
|
CancelUnitBuff("player", spellName)
|
|
end
|
|
end
|
|
end)
|
|
|
|
print("Dechickenator loaded!")
|
|
end
|
|
|
|
local loadedFrame = CreateFrame("Frame")
|
|
loadedFrame:RegisterEvent("ADDON_LOADED")
|
|
loadedFrame:SetScript("OnEvent", function(self, event, addonName)
|
|
if addonName == addonname then
|
|
init()
|
|
end
|
|
end)
|
|
|
|
SlashCmdList["DECHICKENATOR_TOGGLE_BLACKLISTED_BUFF"] = function(input)
|
|
print("Toggling blacklisted buff: " .. tostring(input))
|
|
if Dechickenator_Data.blacklistedBuffs[input] then
|
|
Dechickenator_Data.blacklistedBuffs[input] = nil
|
|
else
|
|
Dechickenator_Data.blacklistedBuffs[input] = true
|
|
end
|
|
print(Dechickenator_Data.blacklistedBuffs[input])
|
|
end
|
|
SLASH_DECHICKENATOR_TOGGLE_BLACKLISTED_BUFF1 = "/dechicken"
|
|
|
|
SlashCmdList["DECHICKENATOR_SET_MESSAGE"] = function(input)
|
|
print("Setting message: " .. tostring(input))
|
|
Dechickenator_Data.message = input
|
|
print(Dechickenator_Data.message)
|
|
end
|
|
SLASH_DECHICKENATOR_SET_MESSAGE1 = "/dechicken_message" |