Creating custom links in chat?

So I was wondering if it’s possible to create truly custom links that when a user clicks them will display some info. We’ve all seen the various ones like:

/script DEFAULT_CHAT_FRAME:AddMessage("Shift-click this link to put into chat: 124cffff8000124Hitem:19019:0:0:0:0:0:0:0124h[Thunderfury, Blessed Blade of the Windseeker]124h124r");

What I’m wondering is if it’s possible to just create a link that would look like “[MyAddonName: Some Output]”

When you click it you’d get that same sort of movable item style window where it could display information from the addon.

Result would be sort of like this;

MyAddonName: Some Output
No of Players in Raid: 15
No of Players Ready: 10
No of Players Not Ready: 1
No of Players AFK: 4

Just thinking of a “tidy” way to send information to other users who don’t have the addon without spamming multiple lines into Whisper/Party/Chat/Raid. This way players only see a single line with the link and if they choose to see it they can click on it. Info would obviously be static but that’s ok for what I’m thinking.

I vaguely remember completely fake item links were being created some years back and I can see that fake item addons are still a thing. But from what I can tell the link still looks like say Thunderfury, just with different stats/enchants and so on. That’s not what I’m hoping to achieve.

edit: Sorry I meant to link to https://wowpedia.fandom.com/wiki/ItemLink
I had a read of that but it looks like you need to use a database ID that exists, and that you can’t just create your own sort of pseudo id.

edit 2: I thought Weakauras did it but on closer inspection it’s not quite the same. From what I can tell if you create a WA link. When someone clicks it they need the addon installed. So it’s likely WA checking the active chat window and dealing with links.

I am creating custom hyperlinks like this:

function myAddon:HyperlinkHandler(...)
  local _, linkType = ...
  local _, myIdentifier, var1, var2 = strsplit(":", linkType)

  if myIdentifier== "myAddonName" then
    -- Do whatever you want.
  end
end

hooksecurefunc(ItemRefTooltip, "SetHyperlink", myAddon:HyperlinkHandler)

Then the hyperlink must look like this:

|Hitem:myAddonName:value1:value2|h[Click here!]|h

The above example shows how you can pass var1=value1, var2=value2 to your HyperlinkHandler. This is optional and you can do as many as you need.

1 Like

If I understand that correctly though, whoever is clicking the link needs the addon. So it’d be like Weakauras Links, if you don’t have Weakauras installed you’ll see the link someone sent but can’t actually do anything with it?

edit: I will add. I like the solution and if I can’t find a way for “addon free” people to see the link then I’ll implement that and it just means other people miss out.

Oh I see. I did not get that you wanted it to work for people without your addon. If this is possible, then I don’t know how. Good luck. :grinning:

Ah yeah sorry, I wasn’t clear on that in the original post. I already suspected that it wasn’t possible since I haven’t seen any addon already doing that. I was just hoping that I was wrong.

I’d already implemented the example code from https://wowwiki-archive.fandom.com/wiki/Hooking_functions (the tinfoil hat one) but it’s obviously not perfect as when you just hover over the link without clicking it shows “Turtle Scale Helm” since that’s what is really attached to ItemID 8191. And obviously it doesn’t work for people without your addon.