Quantcast WoWInterface - View Single Post - Faction from GetPlayerInfoByGUID()
View Single Post
12-02-12, 06:58 AM   #14
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Billtopia View Post
what event fires when the SendAddonChatMessage fails to find its whisper target?
CHAT_MSG_SYSTEM is the event that fires, and the message argument should match a global string. Get the exact message in-game and then find it in your locale's GlobalStrings listing to get the global name. If it just says "Player not found." then it's probably ERR_FRIEND_NOT_FOUND.

However, you'd want to use ChatFrame_AddMessageEventFilter to catch and hide the message instead of registering your frame for the CHAT_MSG_SYSTEM event:

Code:
-- Have a filter function ready:
local CatchSystemMessage = function(frame, event, message)
    -- Remove the filter:
    ChatFrame_RemoveMessageEventFilter("CHAT_MSG_SYSTEM", CatchSystemMessage)
    -- Check the message:
    if message == ERR_FRIEND_NOT_FOUND then
         -- Sending the message failed.
         -- Do something here if needed.
         -- Hide the message from the user:
         return true
    end
end

-- When you try to send a message, register the filter first:
ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", CheckSystemMessage)
SendAddonMessage("TEST", "faction test", "WHISPER", nil, "Someguy")
This will catch the next system message after you send a message. If you wanted to be really fancy, you could add a timeout to remove the filter after some amount of time (probably 1 second would be more than enough). Otherwise you run the minor risk of catching the next system message even if it's not related to your event, and if the message is "Player not found." then it will get hidden.

Originally Posted by nazrhyn View Post
Wow Instant Messenger ... appears to be using LibWho-2.0 for that. The call is made in Modules/Filters.lua. Maybe you can use that or its methodologies?
LibWho-2.0 is just a wrapper around the /who query system, which is slow, and interferes with the user's ability to /who query people. It also doesn't work very well for players with short names. For example, if you are trying to /who someone named Pat, the results will include every name that includes the letters "pat" in that order at any position, and since it's limited to 49 results, you may not even get the Pat you were looking for. Using /who in an addon to find information about a specific player should be the absolute last resort.
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote