View Single Post
10/01/14, 04:54 AM   #3
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Ayantir View Post
Lua Code:
  1. local function ChatMessageChannel(messageType, fromName, text)
  2.    
  3.     if messageType == CHAT_CHANNEL_WHISPER then
  4.    
  5.         -- Don't zo_strformat UserId's
  6.         local pstPerson
  7.         if string.find(from, "@") == nil then
  8.             pstPerson = zo_strformat(SI_UNIT_NAME, fromName)
  9.         end
  10.        
  11.         d(pstPerson)
  12.        
  13.         if (IsFriend(pstPerson)) then
  14.             d("A friend just whispered you")
  15.         end
  16.        
  17.     end
  18.    
  19. end
  20.  
  21. ZO_ChatSystem_AddEventHandler(EVENT_CHAT_MESSAGE_CHANNEL, ChatMessageChannel)

I didn't checked it, but it should work as intended, no?
This function will replace existing event handler, so it can cause conflicts between this and other addons. I'd recommend hooking of the existing event handler.
Lua Code:
  1. local function ChatMessageChannel(messageType, fromName, ...)
  2.     if messageType == CHAT_CHANNEL_WHISPER then
  3.         if IsFriend(fromName) then
  4.             d("A friend just whispered you")
  5.         end
  6.     end
  7. end
  8.  
  9. ZO_PreHook(ZO_ChatSystem_GetEventHandlers(), EVENT_CHAT_MESSAGE_CHANNEL, ChatMessageChannel)
  Reply With Quote