We use a normal SetHook call on the OnHyperlinkClick handler of all chat frames* where we handle our links. The whole link text (which gets lost in the call to SetHyperlink) is still available here:
DEFAULT_CHAT_FRAME:HookScript("OnHyperlinkClick", function(self, link, string, button, ...) local linkType, arg1, arg2, arg3 = strsplit(":", link) if linkType ~= "DBM" then return end if arg1 == "cancel" then DBM.Bars:CancelBar(link:match("DBM:cancel:(.+):nil$")) -- timer name may contain colons... (handle other links...)
Now we just have to prevent the default chat frame from doing something stupid (passing the link on to ItemRefTooltip:SetHyperlink())
This is done with a simple hook there which is better for the taint issue:
local old = ItemRefTooltip.SetHyperlink -- we have to hook this function since the default ChatFrame code assumes that all links except for player and channel links are valid arguments for this function function ItemRefTooltip:SetHyperlink(link, ...) if link:sub(0, 4) == "DBM:" then return end return old(self, link, ...) end
*) yes, that means it might have issues with addons that replace the chat frames with something custom, like WIM or something. But our messages that contain links are posted to DEFAULT_CHAT_FRAME only anyways and not to actual chats. So this method might not be useable for everyone.
I have honestly no idea why I wrote it that way back then (I wrote that code during the WotLK beta iirc). The more obvious and robust solution would probably to just hook SetHyperlink and embed all the required information in the link instead of relying on the text (which DBM doesn't anyways, so I wonder why I did it that way...).