MyChatAlert

MyChatAlert

20k Downloads

[FEATURE] +/- operators for advanced keywords

brodyreeves opened this issue ยท 0 comments

commented

+ to match additional words, - to restrict words

From PM:

for _, word in pairs(words) do -- find the word
    if word:lower():find("+") or word:lower():find("-") then
        astop = 0
        bstop = 0
        for mm in word:gmatch("-%a+") do                    
            if message:lower():find(mm:sub(2,-1)) then
                astop = 1
                break                                   
            end
        end                      
        for pp in word:gmatch("+%a+") do                    
            if message:lower():find(pp:sub(2,-1)) == nil then
                bstop = 1
                break                                   
            end
        end
        if bstop == 0 and astop == 0 then
            self:AddAlert("", self:TrimRealmName(author), message, channel)
        end
    elseif message:lower():find(word:lower()) then -- Alert message
        self:AddAlert(word, self:TrimRealmName(author), message, channel)
        return -- matched the message, stop
    end
end