View Single Post
11-02-16, 04:51 PM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
I do something similar in my personal addon where I hide and redirect LocalDefense spam to print() so that it doesn't trigger the channel sound I have set in Prat. With some minor tweaks, this should work for your usage.

What I have:

lua Code:
  1. local frame=CreateFrame('frame')
  2.  
  3. function frame:PLAYER_LOGIN()
  4.     ChatFrame_AddMessageEventFilter('CHAT_MSG_CHANNEL',function(_,_,_,sender,_,chan,_,_,_,_,_,_,_,guid)
  5.         if strmatch(chan,'LocalDefense') and sender=='' and not guid then return true end
  6.     end) -- hides local defense system spam
  7. end
  8.  
  9. function frame:CHAT_MSG_CHANNEL(msg,sender,_,chan,_,_,_,_,_,_,_,guid)
  10.     if strmatch(chan,'LocalDefense') and sender=='' and not guid then print(msg) end
  11. end -- prints local defense system spam to ChatFrame1
  12.  
  13. frame:RegisterEvent('PLAYER_LOGIN')
  14. frame:RegisterEvent('CHAT_MSG_CHANNEL')
  15. frame:SetScript('OnEvent',function(self,event,...)self[event](self,...)end)


What should work for you:

lua Code:
  1. local frame=CreateFrame("frame")
  2.  
  3. function frame:PLAYER_LOGIN()
  4.     ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM",function(_,_,msg)
  5.         if strmatch(msg,FRIENDS_LIST_ONLINE)
  6.         or strmatch(msg,FRIENDS_LIST_OFFLINE)
  7. --      or strmatch(msg,VARIABLE_CONTAINING_STRING)
  8. --      or strmatch(msg,"manually entered string")
  9.         then return true end
  10.     end)
  11. end
  12.  
  13. function frame:CHAT_MSG_SYSTEM(msg)
  14.     if strmatch(msg,FRIENDS_LIST_ONLINE)
  15.     or strmatch(msg,FRIENDS_LIST_OFFLINE)
  16. --  or strmatch(msg,VARIABLE_CONTAINING_STRING)
  17. --  or strmatch(msg,"manually entered string")
  18.     then print(msg) end
  19. end
  20.  
  21. frame:RegisterEvent("PLAYER_LOGIN")
  22. frame:RegisterEvent("CHAT_MSG_SYSTEM")
  23. frame:SetScript("OnEvent",function(self,event,...)self[event](self,...)end)


To reroute more system messages, just add another strmatch line to both blocks as shown above. Make sure to remove the -- at the beginning of the line for things you add. If you are not familiar with making an addon, paste the above into http://addon.bool.no and it'll give you a zip file you can install like any other addon.
  Reply With Quote