View Single Post
07-13-15, 03:52 PM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,327
I've noticed many custom chat addons that replace the chatframes don't use Blizzard's chat filter system. This isn't guaranteed to work if a user is running one.

Chat filters also can run multiple times according to how many frames are set to receive whisper events. On the same note, if no chatframes are registered to receive whispers, the filter will never run. If you need to reliably have code run regardless of user settings or conflicts with other addons, you need to handle the event yourself.

Lua Code:
  1. local EventFrame=CreateFrame("Frame");
  2. EventFrame:RegisterEvent("CHAT_MSG_WHISPER");-- Need to register an event to receive it
  3. EventFrame:SetScript("OnEvent",function(self,event,msg,sender)
  4.     if msg:lower():find("!stats") then--    We're making sure the command is case insensitive by casting it to lowercase before running a pattern check
  5.         SendChatMessage("Your response here","WHISPER",nil,sender);
  6.     end
  7. end);
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 07-13-15 at 03:57 PM.
  Reply With Quote