Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New features #1

Open
JackSlateur opened this issue Dec 29, 2011 · 0 comments
Open

New features #1

JackSlateur opened this issue Dec 29, 2011 · 0 comments

Comments

@JackSlateur
Copy link

JackSlateur commented Dec 29, 2011

Hi there,
If people wrote a message like that : "HI THERe", it won't be filtered
That's why I rewrote your function (not so good, i'm a bit noob with lua).
This should hide message if less than 20% char are caps.
Here's the code :

local function bottleCaps(_, _, msg, ...)
    -- prevent all caps from showing in the chatframes
    if db.ignore then
        local tmp = msg
        local value
        local a = true
        for i = 65, 90 do
            a = true
            while(a == true) do
                value = string.find(tmp, string.char(i))
                if(value == nil) then
                    a = false
                else
                    if(value == 1) then
                        tmp = tmp:sub(2)
                    else
                        tmp = tmp:sub(1, value - 1)..tmp:sub(value + 1)
                    end
                end
            end
        end
        local ratio = tonumber(string.len(tmp)) / tonumber(string.len(msg))
        if(ratio < 0.2) then
            return true
        else
            return false, msg, ...
        end

    end

    --~ if db.ignore and msg == msg:upper() then
        --~ return true
    --~ end

    if db.verbose or msg == msg:upper() then
        -- Verbose Mode = all chat becomes lower case, regardless of original case
        -- else all ALL CAPS CHAT becomes lower case
        msg = msg:lower()

        -- Fix links
        msg = msg:gsub("|hitem", "|Hitem")
        msg = msg:gsub("|hquest", "|Hquest")
        msg = msg:gsub("|hspell", "|Hspell")
        msg = msg:gsub("|htalent", "|Htalent")
        msg = msg:gsub("|hachievement", "|Hachievement")
        msg = msg:gsub("|htrade", "|Htrade")
        msg = msg:gsub("|henchant", "|Henchant")
        msg = msg:gsub("|hglyph", "|Hglyph")
        msg = msg:gsub("|hurl", "|Hurl") -- website links created by Chatter, Prat etc.

        return false, msg, ...
    end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant