Quantcast
Color RealID whispers by class? - WoWInterface
Thread Tools Display Modes
12-29-13, 05:18 PM   #1
Wimpface
A Molten Giant
 
Wimpface's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 648
Color RealID whispers by class?

Google searched yielded nothing but ElvUI and ShestakUI links.

I'm looking for a standalone addon that colors RealID whispers by class. RealID whispers aren't that confusing to tell apart because they use real names, but Battle Tags really get to me for some reason. Many times now have I sent a whisper to the wrong person because I'm whispering different battle tags and they're all similar length and same color. Just coloring the name would go a long way for me.

Does anyone know if such an addon exists?
__________________
All I see is strobe lights blinding me in my hindsight.
  Reply With Quote
12-29-13, 05:49 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,466
Try PhanxChat. The description I read on that addon says that it replaces RealID names with character names. Its possible that it also colors by class or this change makes the color by class option in the default blizz chat settings work for them as well.

Apart from that I don't see a specific addon that does just what you want, but it might be worth trying out the chat addons to see if they do what you want as well as other stuff.
__________________
  Reply With Quote
12-29-13, 05:57 PM   #3
Wimpface
A Molten Giant
 
Wimpface's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 648
Originally Posted by Xrystal View Post
Try PhanxChat. The description I read on that addon says that it replaces RealID names with character names. Its possible that it also colors by class or this change makes the color by class option in the default blizz chat settings work for them as well.

Apart from that I don't see a specific addon that does just what you want, but it might be worth trying out the chat addons to see if they do what you want as well as other stuff.
Last time I checked, Phanx was not a big fan of having his/her addons included in compilations, something that is an issue for me.

I'm also fairly happy with my current chat addon, and this is the only functionality I sorely miss. I cut Chatter for this because I felt Chatter was too cluttered for my needs, not to mention the bugs with channel name replacements.

I tried looking into adding the functionality by ripping some code out of ElvUI, but that ended up horribly confusing.
__________________
All I see is strobe lights blinding me in my hindsight.
  Reply With Quote
12-29-13, 06:08 PM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,466
Ah, didn't realise you wanted to add it to a compilation.

I'll have a dabble before I head off to bed to see if I can rig up something small.
__________________
  Reply With Quote
12-29-13, 06:32 PM   #5
Wimpface
A Molten Giant
 
Wimpface's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 648
Originally Posted by Xrystal View Post
Ah, didn't realise you wanted to add it to a compilation.
Unfortunately, but I'm not even sure I wouldn't be here asking either way.

Originally Posted by Xrystal View Post
I'll have a dabble before I head off to bed to see if I can rig up something small.
This would be very nice! I'd really appreciate that. I can wait, however, so don't feel pressured on time if you'd rather sleep. I'm in no hurry.
__________________
All I see is strobe lights blinding me in my hindsight.
  Reply With Quote
12-29-13, 08:00 PM   #6
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,466
Give this a whirl. I couldn't test it properly as the person I usually chat to for hours on end wasn't in game today. And my only other bnet friend online was in and out of dungeons and it bugged out on the only message I got rofl.

Did some tweaking and added some messages for debugging purposes. Just set debugMessages to false and the messages will stop appearing on the next UI reload.

Let me know if it still doesn't work and send a screenshot of those debug messages in that instance and I'll spend some time on it when my chatty friend next logs in, before start playing.
Attached Files
File Type: zip XRealIDColors.zip (1.3 KB, 151 views)
__________________
  Reply With Quote
12-29-13, 08:24 PM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Yes, you can include my addons in compilations, but you cannot modify them in any way.

If you want to modify one of my addons for your compilation, you have to rename it, removing all traces of the original name, so it cannot possibly be confused with the original addon, and nobody will come to me looking for help if/when it breaks.

If you want an addon that just colors RealID names by class, you are also free to copy the code from PhanxChat that does that, and use it to write your own addon.

All of this is clearly spelled out in the LICENSE.txt file in the addon folder, by the way.
__________________
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
12-29-13, 08:39 PM   #8
Wimpface
A Molten Giant
 
Wimpface's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 648
Originally Posted by Phanx View Post
Yes, you can include my addons in compilations, but you cannot modify them in any way.

If you want to modify one of my addons for your compilation, you have to rename it, removing all traces of the original name, so it cannot possibly be confused with the original addon, and nobody will come to me looking for help if/when it breaks.

If you want an addon that just colors RealID names by class, you are also free to copy the code from PhanxChat that does that, and use it to write your own addon.

All of this is clearly spelled out in the LICENSE.txt file in the addon folder, by the way.
That clears up a lot, my information was based on the word of a friend who had to pull PhanxChat from his UI a few years ago. I've never run into this issue myself, though.

And it would've been modified, good to know that you prefer renaming the addon completely rather than pulling the addon.

I'll try out the addon Xrystal, and report back on any issues I come across after this flex. Thanks a ton!
__________________
All I see is strobe lights blinding me in my hindsight.
  Reply With Quote
12-30-13, 12:02 AM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Wimpface View Post
And it would've been modified, good to know that you prefer renaming the addon completely rather than pulling the addon.
Basically I don't give a flying potato what anyone does with code I wrote, I just don't want people pestering me with bug reports for bugs in code I didn't write. It's annoying enough when people claim to be using "the latest version" and I waste my time investigating a bug that turns out to be caused by them running a 3-year-old version of the addon.
__________________
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
12-30-13, 12:18 AM   #10
Wimpface
A Molten Giant
 
Wimpface's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 648
Originally Posted by Phanx View Post
Basically I don't give a flying potato what anyone does with code I wrote, I just don't want people pestering me with bug reports for bugs in code I didn't write. It's annoying enough when people claim to be using "the latest version" and I waste my time investigating a bug that turns out to be caused by them running a 3-year-old version of the addon.
Completely understandable and seems to be a common stance. I misunderstood your opinion on this, sorry for my faulty assumption.

EDIT: As for the addon, all my RealID friends logged out when I wanted to test it, so it'll have to wait until tomorrow.

EDIT#2: Okay, I've done some testing with a friend. With the addon enabled, I don't even see his messages. They're just completely gone. Without it, it displays just fine.

He's on the same server as me.
He's a RealID friend, not a BattleTag friend.
He does not have any special characters in his name or character name, or realm name. No apostrophes, nothing.
I tried with my chat addon enabled and disabled, no change.
Debug messages seem to work fine. I've blocked out his name, but that's it. It does show as Player Name (CharName-Server Name) in classcolor under that block.

That is the entire message I get when he sends a whisper to me with debugging on. It doesn't show the actual whisper still, but I'm unsure if that's intentional or not when debugging.
__________________
All I see is strobe lights blinding me in my hindsight.

Last edited by Wimpface : 12-30-13 at 12:01 PM.
  Reply With Quote
12-30-13, 02:22 PM   #11
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Originally Posted by Wimpface View Post
EDIT#2: Okay, I've done some testing with a friend. With the addon enabled, I don't even see his messages. They're just completely gone. Without it, it displays just fine.(...)
IIRC from playing with ChatFrame_AddMessageEventFilter, the first return value of ChatFrame_AddMessageEventFilter is checked in boolean mode, that means if the first value equates to true, the message is filtered(and being prevented from passing towards the :AddMessage() method). The first return value in the code in XRealIDColors.lua(horrible name by the way ) on line 54 is always passing the third argument passed to the function(message), which always equates to true, as a result, the message is hidden.

The correct way to do it, is AFAIK the following:
lua Code:
  1. return false, message, sender, ...
instead of
lua Code:
  1. return message, sender, ...

Aside from that, the code creates 2 tables for each bnet whisper. Blegh :P

Last edited by ravagernl : 12-30-13 at 02:24 PM.
  Reply With Quote
12-30-13, 02:48 PM   #12
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,466
hmm, thought I had the correct return values, but perhaps not .. will take another look. And monitor my bnet friend messages today.

Oops, yes, forgot to add in the false value at the front of the 2 return lines to make sure the messages get output again. Brain was working but fingers weren't rofl.

Version attached to this message contains that extra change. Will see what I see happening tonight and will report back if it is doing what I am expecting it to do based on your initial post.

Based on your post after testing it sounds like the only problem was due to the missing false/true value as to whether to filter the message away. Adding that false in should make it work.

edit (after testing) : Well good news is that coloring seems to work, bad news is it is display extra stuff so it could be the way I am formatting the color that is wrong.
Attached Files
File Type: zip XRealIDColors.zip (1.3 KB, 126 views)
__________________

Last edited by Xrystal : 12-30-13 at 03:08 PM.
  Reply With Quote
12-30-13, 06:18 PM   #13
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Code:
local function ColorBNetWhispers(self,event,message,sender,...)
	local args = { ... }
	...
	local toonInfo = { BNGetToonInfo(presenceID) }
What is this, I don't even... why on earth are you creating all these tables instead of just using variables?! ಠ_ಠ

Code:
local function ColorBNetWhispers(self, event, message, sender, _, _, _, flags, _, _, _, _, lineID, _, presenceID)
	...
	local hasFocus, toonName, client, realmName, realmID, faction, race, class, guild, zoneName, level, gameText, broadcastText, broadcastTime, canSoR, toonID = BNGetToonInfo(presenceID)
__________________
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
12-30-13, 08:11 PM   #14
Wimpface
A Molten Giant
 
Wimpface's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 648
Originally Posted by Xrystal View Post
edit (after testing) : Well good news is that coloring seems to work, bad news is it is display extra stuff so it could be the way I am formatting the color that is wrong.
This doesn't appear to be the only issue left. I think the way it's formatted also screws up being able to click on the player name to send a message. It also messes with replying using the 'r' key, so to speak. It will try to send to the formatted player and won't find it.

When trying to reply to a player, currently, it'll return "Unable to whisper 'ExamplePlayer (Example-Example Server)'.", classcolored and all. I'm unsure if this is a problem with the formatting, or if it'll be a lasting issue.
__________________
All I see is strobe lights blinding me in my hindsight.
  Reply With Quote
12-30-13, 08:33 PM   #15
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You're going to have to pre-hook the chat frame's AddMessage method instead of using a chat filter. Chat filters are intended for changing the message text only; changing other values will have other (mostly undesirable) effects on how the chat system processes the message before displaying it in the chat frame. See PhanxChat for a working example.
__________________
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
12-30-13, 09:04 PM   #16
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,466
Thanks Phanx, will do.

Edit: Okay, gonna take me a while to figure this out ... Any time I try to adjust AddMessage function it crashes wow, so I guess I am doing something wrong somewhere rofl.

Edit2: Good News is it now color codes the Names and shows the Toon Name and Server based on toggle setting to do so. Bad News is that it currently crashes if you log in / reload and you don't have any realID friends online or seems to go into an infinite loop and crashes if your realID friend logs off. Phanx or anyone else, is there anything you can see in this code that may cause that as I can't seem to see anything that I am not covering myself for so that it simply returns an unformatted message string.

Removed the toast test since the crashing/hanging etc as it isn't really need in this instance so will see if that might be the cause of the issue but just in case it isn't the cause, here is the code in its entirety and a download version if you prefer.

Lua Code:
  1. local addonName, addonData = ...
  2.  
  3. local showToonName = true
  4. local showRealmName = showToonName and true
  5. local debugMessages = true
  6.  
  7. local bnNameFormat = "%s"
  8. local playerBNFormat = "|HBNplayer:%s|h" .. bnNameFormat .. "%s|h"
  9. local playerBNPattern = "|HBNplayer:(.-)|h%[(|Kf(%d+).-)%](.*)|h"
  10.  
  11. local function RGB_TO_HEX(rgb)
  12.     return string.format("%02x%02x%02x", rgb.r*255, rgb.g*255, rgb.b*255)
  13. end
  14.  
  15. local function ColorToonName(chatFrame,message,...)
  16.     local bnData, bnName, bnID, bnExtra = string.match(message, playerBNPattern)
  17.  
  18.     if bnData then
  19.         local toonInfo = { BNGetToonInfo(bnID) }
  20.         local link = string.format(playerBNFormat, bnData, bnName, bnExtra or "")
  21.  
  22.         if toonInfo[3] ~= "WoW" or toonInfo[3] == nil then
  23.             message = string.gsub(message, playerBNPattern, link)
  24.         else
  25.             local toonName = toonInfo[2]
  26.             local realmName = toonInfo[4]
  27.             local class = toonInfo[8]
  28.  
  29.             local color = RAID_CLASS_COLORS[class]
  30.             local classToken = addonData.ClassNames[class]
  31.             if not color then
  32.                 color = RAID_CLASS_COLORS[classToken]
  33.             end
  34.             local colorHex = RGB_TO_HEX(color)
  35.  
  36.             if showToonName then
  37.                 if showRealmName then
  38.                     coloredSender = string.format("|cff%s %s (%s-%s)|r",colorHex,bnName,toonName,realmName)
  39.                 else
  40.                     coloredSender = string.format("|cff%s %s (%s)|r",colorHex,bnName,toonName)
  41.                 end
  42.             else
  43.                 coloredSender = string.format("|cff%s %s|r",colorHex,bnName)
  44.             end
  45.  
  46.             link = string.format(playerBNFormat, bnData, coloredSender, bnExtra or "")
  47.             message = string.gsub(message, playerBNPattern, link)
  48.  
  49.         end
  50.     end
  51.     return message
  52. end
  53.  
  54. local function AddMessage(chatFrame, message, ...)
  55.     if type(message) == "string" then
  56.         local bnData, bnName, bnID, bnExtra = strmatch(message, playerBNPattern)
  57.         if bnData then
  58.             message = ColorToonName(chatFrame,message,...)
  59.         end
  60.     end
  61.     addonData[chatFrame].AddMessage(chatFrame,message, ...)
  62. end
  63.  
  64. addonData.XRICEvents = CreateFrame("Frame")
  65. addonData.XRICEvents:RegisterEvent("ADDON_LOADED")
  66. addonData.XRICEvents:SetScript("OnEvent",function(self,event,...)
  67.  
  68.     local args = { ... }
  69.  
  70.     if event == "ADDON_LOADED" and args[1] == addonName then
  71.         addonData.ClassNames = {}
  72.         for k, v in pairs(LOCALIZED_CLASS_NAMES_MALE) do
  73.                 addonData.ClassNames[v] = k
  74.         end
  75.         for k, v in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do
  76.                 addonData.ClassNames[v] = k
  77.         end
  78.  
  79.         for i = 1, NUM_CHAT_WINDOWS do
  80.             local chatFrame = _G["ChatFrame" .. i]
  81.             addonData[chatFrame] = addonData[chatFrame] or {}
  82.             if ( not addonData[chatFrame].AddMessage ) then
  83.                 addonData[chatFrame].AddMessage = chatFrame.AddMessage
  84.                 chatFrame.AddMessage = AddMessage
  85.             end
  86.         end
  87.     end
  88.  
  89. end)
Attached Files
File Type: zip XRealIDColors.zip (1.4 KB, 123 views)
__________________

Last edited by Xrystal : 12-30-13 at 11:19 PM.
  Reply With Quote
12-31-13, 01:38 AM   #17
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Code:
addonData.XRICEvents:SetScript("OnEvent",function(self,event,...)
    local args = { ... }
Stop doing this! Tables bad. Variables good. Use variables. No use tables.

See here for a quick and untested (but clean) conversion of the relevant parts of PhanxChat into a standalone addon:
http://www.wowace.com/paste/lmszetyg58bn621q/
__________________
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
12-31-13, 07:30 AM   #18
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,466
Thanks for the input Phanx. Did a bit of research on the difference between table based variables and standalone variables and there is a slight improvement on performance and of course readability. I am guessing that is why you are saying not to use them, you weren't clear there. I will of course take it under advisement when finalising the addon beyond this testing phase.

Looking at your extracted example I am assuming the temporary window element is required due to the fact that you can move a RealID conversation into a separate chat frame. Will add that element in and test it. Thanks again.

As to the initial crashing of the game when no one was online, removing the unnecessary toast test seemed to stop that from happening. Next test is to see what happens when a friend logs in and then out. So time to wait.
__________________

Last edited by Xrystal : 12-31-13 at 08:00 AM.
  Reply With Quote
12-31-13, 02:37 PM   #19
Wimpface
A Molten Giant
 
Wimpface's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 648
Originally Posted by Phanx View Post
Code:
addonData.XRICEvents:SetScript("OnEvent",function(self,event,...)
    local args = { ... }
Stop doing this! Tables bad. Variables good. Use variables. No use tables.

See here for a quick and untested (but clean) conversion of the relevant parts of PhanxChat into a standalone addon:
http://www.wowace.com/paste/lmszetyg58bn621q/
Is line 80 supposed to read like that? Won't this throw an error?
Code:
local firstName = local short = gsub(realName, "|Kf", "|Kg")
EDIT: Shouldn't it be
Code:
local firstName = gsub(realName, "|Kf", "|Kg")
__________________
All I see is strobe lights blinding me in my hindsight.

Last edited by Wimpface : 12-31-13 at 02:43 PM.
  Reply With Quote
12-31-13, 02:46 PM   #20
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,466
So far my version is working fine now apart from temporary chat frames. Still need to test and fix that scenario. But friends logging in and out don't seem to be crashing the game and neither does not having a friend online ( which at the moment seems to be 90% of the time nowadays rofl ).
__________________
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Color RealID whispers by class?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off