From 0d2ad26892e4e9ad1fab5ea2530619cc245fc932 Mon Sep 17 00:00:00 2001 From: atomaka Date: Fri, 12 Aug 2011 18:42:39 -0400 Subject: [PATCH] Monitor all forms of chat changes instead of just slash commands. --- ChatSaver.lua | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ChatSaver.lua b/ChatSaver.lua index 3df37fe..dce25fe 100644 --- a/ChatSaver.lua +++ b/ChatSaver.lua @@ -11,8 +11,6 @@ function core:OnInitialize() end function core:OnEnable() - self:RawHook(SlashCmdList,'JOIN','JoinChannel',true); - self:RawHook(SlashCmdList,'LEAVE','LeaveChannel',true); self:Hook('ToggleChatChannel','ToggleChatChannel',true); self:RegisterEvent('CHANNEL_UI_UPDATE','RejoinChannels'); @@ -68,6 +66,21 @@ end --[[ EVENT FUNCTIONS ]] -- +function core:ProcessChannelChange(_,message,_,_,_,_,_,_,index,name) + if message == 'YOU_JOINED' then + local number,_,category = core:GetChannelInfo(name) + + if category == 'CHANNEL_CATEGORY_CUSTOM' then + ChatSaverDB[name] = {} + ChatSaverDB[name]['frames'] = {} + ChatSaverDB[name]['index'] = number + ChatSaverDB[name]['frames'][DEFAULT_CHAT_FRAME:GetID()] = true + end + elseif message == 'YOU_LEFT' then + ChatSaverDB[name] = nil + end +end + function core:RejoinChannels(...) local currentChannels = {}; for i = 1,select('#',GetChannelList()) do @@ -90,6 +103,7 @@ function core:RejoinChannels(...) end self:UnregisterEvent('CHANNEL_UI_UPDATE'); + self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','ProcessChannelChange') end function core:SetupChatSaver(...) @@ -111,6 +125,7 @@ function core:SetupChatSaver(...) end self:UnregisterEvent('CHAT_MSG_CHANNEL_NOTICE'); + self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','ProcessChannelChange') end function core:StoreChannel(_,_,_,_,_,_,_,_,_,name)