Thread Tools Display Modes
06-18-14, 07:17 AM   #1
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Copying presence name from editbox

I have a feeling there's no way around this, and I'm aware the special nature of presence names, but:

If you insert a BNet presence name into an editbox, it looks alright, but when you copy it and paste it somewhere, you get some of the magic string as well, like so: |Kf349|kActualName|k
I realise I'm not gonna be able to change what actually gets copied to the clipboard.

For a chat copying feature.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
06-18-14, 11:24 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Not possible. Real names are not accessible to addons, period. If a workaround was ever discovered, Blizzard would patch it as soon as they became aware of it.

However, what you can do is extract the presenceID from the link, pass that to BNGetFriendInfoByID to get the friend's BattleTag (it's the third return) and replace the "magic characters" in the link with the BattleTag for copying:

Code:
local presenceID = tonumber(string.match(LINK_GOES_HERE, "|K[a-z](%d+)"))
local _, _, battleTag = BNGetFriendInfoByID(presenceID)
local displayTag = string.match(battleTag, "^(.+)#")
The above will remove the numbers from the BattleTag, so "Somebody#1234" becomes just "Somebody", but if you'd rather show the whole thing just leave off the last line.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 06-23-14 at 05:48 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Copying presence name from editbox


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