View Single Post
04/23/14, 08:08 AM   #3
Fathis Ules
Thief Guild Master
 
Fathis Ules's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 42
|H marks the start of a hyperlink and |h the end
|c marks the start of a simple text color and |r the end

I ended up using a less costly method if anyone is interested, basically if |H is used, it returns true at the first invalid link detected

Code:
local links_type = { -- Color spammers now uses |H color links, need to check link validity
    [0] = "|H[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]:item:%d+:%d+:%d+:%d+:%d+:%d+:%d+:%d+:%d+:%d+:%d+:%d+:%d+:%d+:%d+:%d+:%d+:%d+:%d+:%d+|h%[[^%]]+%]|h", -- ITEM_LINK_TYPE        |H2DC50E:item:30164:1:7:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h[Ancolie]|h
    [1] = "|H[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]:achievement:%d+:%d+:%d+|h%[[^%]]+%]|h",                                                              -- ACHIEVEMENT_LINK_TYPE |HDCD822:achievement:554:65535:1397743073|h[Chasseur d'éclats célestes de Fendretour]|h
    [2] = "|H[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]:book:%d+|h%[[^%]]+%]|h"                                                                              -- BOOK_LINK_TYPE        |HE27A3F:book:156|h[Jorunn le Roi-scalde]|h
}

local function has_invalid_link(text)
    if text:match("|[hH]") then
        for a in text:gmatch("|H.-:.-|h.-|h") do
            local isLinkValid = false
            for i = 0, #links_type do
                if a:match(links_type[i]) then
                    isLinkValid = true
                    break
                end
            end
            if not isLinkValid then
                return true
            end
        end
    end
    return false
end

Last edited by Fathis Ules : 04/23/14 at 08:11 AM.
  Reply With Quote