EthanCentaurai/BottleCap — Issue #1: New features
Author: clobrother
Created: 2011-12-29 20:14:07+00:00
State: open

Hi there,
If people wrote a message like that : "HI THERe", it won't be filtered
That's why a rewrite 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