From e37b113d577669c20201f95b044449d92769e270 Mon Sep 17 00:00:00 2001 From: shagu Date: Mon, 24 Dec 2018 18:35:49 +0100 Subject: [PATCH] easteregg: make xmas less intrusive --- modules/easteregg.lua | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/modules/easteregg.lua b/modules/easteregg.lua index 11436a4b..a75aeb75 100644 --- a/modules/easteregg.lua +++ b/modules/easteregg.lua @@ -2,10 +2,29 @@ pfUI:RegisterModule("easteregg", function () if date("%m%d") == "1224" or date("%m%d") == "1225" then -- merry x-mas! local title = (UnitFactionGroup("player") == "Horde") and PVP_RANK_18_0 or PVP_RANK_18_1 + local oldflag = _G.CHAT_FLAG_AFK - _G.CHAT_FLAG_AFK = title .. " " - _G.MARKED_AFK = "|cff33ffccpf|cffffffffUI|r wishes you a merry christmas, |cff33ffcc" .. title .. "|r." - _G.MARKED_AFK_MESSAGE = "|cff33ffccpf|cffffffffUI|r wishes you a merry christmas, |cff33ffcc" .. title .. "|r: %s" + local pvpking = CreateFrame("Frame", "pfPvPKing", UIParent) + pvpking:Hide() + + pvpking:RegisterEvent("CHAT_MSG_SYSTEM") + pvpking:SetScript("OnEvent", function() + if strfind(arg1, _G.MARKED_AFK) or strfind(arg1, _G.MARKED_AFK_MESSAGE) then + _G.CHAT_FLAG_AFK = title .. " " + this.time = GetTime() + this:Show() + end + end) + + pvpking:SetScript("OnUpdate", function() + if this.time + 1 < GetTime() then + _G.CHAT_FLAG_AFK = oldflag + this:Hide() + end + end) + + _G.MARKED_AFK = "|cff33ffccShagu|cffffffff wishes you a merry christmas. You are now |cff33ffcc" .. title .. "|cffffffff. Thanks for using |cff33ffccpf|cffffffffUI|cffffffff!|r" + _G.MARKED_AFK_MESSAGE = "|cff33ffccShagu|cffffffff wishes you a merry christmas. You are now |cff33ffcc" .. title .. "|cffffffff. Thanks for using |cff33ffccpf|cffffffffUI|cffffffff!|r: %s" _G.CLEARED_AFK = "You are no longer |cff33ffcc" .. title .. "|r." end end)