Cr0wL0ck
New Member
- Joined
- Aug 23, 2014
Greeting's
i am trying to make a troll filter addon, the idea is that it by default disables repeated spam but when typing in a command it removes anything with the listed troll words from chat after it has been used
"in short it mutes most if not all troll sentences".
here's the .lua code, in this example it should mute all sentences containing "test" or "troll" when typing in /run TestFilter.
i cannot see where i went wrong but i cannot get the command part to work, it mutes spam perfectly and only shows the first time but
i am trying to make a troll filter addon, the idea is that it by default disables repeated spam but when typing in a command it removes anything with the listed troll words from chat after it has been used
"in short it mutes most if not all troll sentences".
here's the .lua code, in this example it should mute all sentences containing "test" or "troll" when typing in /run TestFilter.
Code:
ChatFilter_ChatFrame_OnEvent = ChatFrame_OnEventChatFilter_Timer = GetTime()
ChatFilter_Messages = {{},{},{},{},{},{},{},{},{}}
function ChatFrame_OnEvent(event)
SLASH_CF1 = "/Run TestFilter";
SlashCmdList["CF"] = function(msg)
ZSM_SlashCommandHandler(msg);
if ( strsub(event, 1, 8) == "CHAT_MSG" ) then
if arg2 then
if TestFilter and string.find(string.lower(arg1),"Test", "troll") then
return
end
local type = strsub(event, 10);
if ( string.sub(type,1,7) == "CHANNEL" or type == "WHISPER" or type == "GUILD" or type == "YELL" or type == "SAY" or type == "EMOTE" or type == "RAID" ) then
while ChatFilter_Timer < GetTime() do
ChatFilter_Timer = ChatFilter_Timer + 1
for i = 0,7 do
ChatFilter_Messages[9-i] = ChatFilter_Messages[9-i-1]
end
ChatFilter_Messages[1] = {}
end
for i = 1,5 do
for j = 1, table.getn(ChatFilter_Messages[i]) do
if ChatFilter_Messages[i][j] == arg2..arg1 then
return
end
end
end
table.insert(ChatFilter_Messages[1],arg2..arg1)
end
end
end
ChatFilter_ChatFrame_OnEvent(event)
end
function ColorPrint(msg,r,g,b)
DEFAULT_CHAT_FRAME:AddMessage(msg, r, g, b)
end
function Print(msg)
ColorPrint(msg, 1, 1, 0)
end
i cannot see where i went wrong but i cannot get the command part to work, it mutes spam perfectly and only shows the first time but