Page 7 of 8

Re: SpamThrottle: Vanilla addon to reduce chat spam

PostPosted: Tue Oct 13, 2015 6:52 pm
by revulsion
Hey Mopar, would grafting your SpamThrottle into an existing chat addon like Prat or ChatMOD get around both needing the same API in incompatible ways?

I ask because as much as I like your addon, having clean chat windows is better than not seeing gold whispers.

Re: SpamThrottle: Vanilla addon to reduce chat spam

PostPosted: Wed Oct 14, 2015 4:11 am
by Mopar
It's certainly possible, although both addons are pretty complex. What they are doing is hooking the same function, ChatFrame_OnEvent() - a hook replaces the default function (while saving it), does something, then calls the original function.

But note that SpamThrottle has a lot of GUI code for managing the options that might be an issue.

I guess the main comment though is I don't have time to do this myself at the moment, due to work commitments. Although I do plan to have a look at that hook as well as the hook for UnitPopup_OnClick() to see if I can resolve some conflicts - when I have some time available.

Re: SpamThrottle: Vanilla addon to reduce chat spam

PostPosted: Wed Oct 14, 2015 12:05 pm
by Logon
Mopar wrote:Yeah this is an aspect of the original vanilla way of creating chat handlers. The APIs were modified in 2.0 and it's possible to make it compatible there, but not in vanilla, because of the way you have to hook the chat handling function. Sorry about that, just have to choose between the two.


Are you sure?
You can Always hook the prat function that does the registering and you just pass Prat the info it needs from your addon? haven't got prat infront of me, but look into it.

Just wait a few seconds reallife time
then do
Code: Select all
local oldChatFrameFunction;
local function ChatFrameEvent(event, arg1,etctec)
  --Do ya shizzle
  if(we want the message not to be filtered)
    oldChatFrameFunction(event, arg1, etcetc);
  end
end
function delayedInit()
  oldChatFrameFunction  = ChatFrame_OnEvent;
  ChatFrame_OnEvent = ChatFrameEvent;
end


edit: test this, do mind that this is all written free hand and havent been tested

Code: Select all
--============================
--= This replaces the default ChatFrame handler with our own.
--= Implementation could conflict with other chat handling programs, but the API here is really old,
--= and was from before Chat Filters were implemented.
--============================

local OldChatFrame_OnEvent;

local SpamThrottle_ChatFrame_OnEvent;

local UpdateFrame = CreateFrame("Frame", nil);
UpdateFrame:SetScript("OnUpdate",OverHookEvents);
UpdateFrame:Show();
local StartTime = time();
local Initialized;
function OverHookEvents()
   if(time() - StartTime > 10 and Initialized == nil) then
      OldChatFrame_OnEvent = ChatFrame_OnEvent;
      ChatFrame_OnEvent = SpamThrottle_ChatFrame_OnEvent;
      StartTime = nil;
      UpdateFrame:SetScript("OnUpdate", nil);
      UpdateFrame = nil;
      Initialized = true;
   end
end
--ChatFrame_OnEvent
function SpamThrottle_ChatFrame_OnEvent(event)
-- arg1 is the actual message
-- arg2 is the player name
-- arg4 is the composite channel name (e.g. "3. global")
-- arg8 is the channel number (e.g. "3")
-- arg9 is the channel name (e.g. "global")

   local hideColor = "|cFF5C5C5C";
   local oppFacColor = "|cA0A00000";
   local theColor = hideColor;

   if SpamThrottle_Config == nil then SpamThrottle_init(); end
   
   if not SpamThrottle_Config.STActive then
      OldChatFrame_OnEvent(event);
      return;
   end;

   if (SpamThrottle_Config.STCtrlMsgs) then -- Remove the left/joined channel spam and a few other notification messages
      if (event == "CHAT_MSG_CHANNEL_JOIN" or event == "CHAT_MSG_CHANNEL_LEAVE" or event == "CHAT_MSG_CHANNEL_NOTICE" or event == "CHAT_MSG_CHANNEL_NOTICE_USER") then      
         return;
      end
   end
         
   if arg2 then -- if this is not a server message
      if (event == "CHAT_MSG_CHANNEL" or (event == "CHAT_MSG_YELL" and SpamThrottle_Config.STYellMsgs) or (event == "CHAT_MSG_SAY" and SpamThrottle_Config.STSayMsgs) or (event == "CHAT_MSG_WHISPER" and SpamThrottle_Config.STWispMsgs)) then
         
         -- Code to handle message goes here. Just return if we are going to ignore it.
         
         if arg1 and arg2 then   -- only execute this code once although event handler is called many times per message
            local NormalizedMessage = SpamThrottle_strNorm(arg1, arg2);
            if time() == MessageLatestTime[NormalizedMessage] then return end;
         end

         local BlockType = SpamThrottle_ShouldBlock(arg1,arg2,event,arg9);
         SpamThrottle_RecordMessage(arg1,arg2);
         
         if SpamThrottle_Config.STWispBack and event == "CHAT_MSG_WHISPER" and not SpamThrottle_Config.STReverse then
            if BlockType == 1 or BlockType == 2 then
               SendChatMessage(SpamThrottleChatMsg.WhisperBack, "WHISPER", nil, arg2);
            end
         end

         if BlockType == 2 then
            return;
         end
         
         if BlockType == 3 then
            theColor = oppFacColor;
         end
         
         if BlockType == 1 or BlockType == 3 then
            local CleanText = "";
            CleanText = string.gsub(arg1,"|c%x%x%x%x%x%x%x%x", "");
            CleanText = string.gsub(CleanText,"|r", "");
            CleanText = string.gsub(CleanText,"|H.-|h", "");
            CleanText = string.gsub(CleanText,"|h", "");
            
            if event == "CHAT_MSG_YELL" then
               CleanText = theColor .. "[" .. arg2 .. "] yells: " .. CleanText .. "|r";
            else
               if event == "CHAT_MSG_SAY" then
                  CleanText = theColor .. "[" .. arg2 .. "] says: " .. CleanText .. "|r";
               else
                  if event == "CHAT_MSG_WHISPER" then
                     CleanText = theColor .. "[" .. arg2 .. "] whispers: " .. CleanText .. "|r";
                  else
                     CleanText = theColor .. "[" .. arg4 .. "] [" .. arg2 .. "]: " .. CleanText .. "|r";
                  end
               end
            end
            
            DEFAULT_CHAT_FRAME:AddMessage(CleanText);
            return;
         end
      end
   end

   local theStatusValue = string.format("%7d",table.length(MessageList));
   SpamThrottleStatusValue5:SetText(theStatusValue);

   theStatusValue = string.format("%7d",FilteredCount);
   SpamThrottleStatusValue6:SetText(theStatusValue);

   OldChatFrame_OnEvent(event);
end

Re: SpamThrottle: Vanilla addon to reduce chat spam

PostPosted: Wed Oct 14, 2015 12:36 pm
by Logon
I Think you can even unhook the fucker by doing Prat:AceHook:unhook(getglobal("ChatFrame"..id), "AddMessage")

Re: SpamThrottle: Vanilla addon to reduce chat spam

PostPosted: Sat Feb 27, 2016 9:10 pm
by Canibalismo
does anyone know of an add-on that does the opposite thing?
I want to be notified on specific keywords i.e. BRD

Re: SpamThrottle: Vanilla addon to reduce chat spam

PostPosted: Thu Mar 17, 2016 2:41 am
by kaybee10
Canibalismo wrote:does anyone know of an add-on that does the opposite thing?
I want to be notified on specific keywords i.e. BRD


Addon called calltoarms, pretty sure thats what you're looking for

Re: SpamThrottle: Vanilla addon to reduce chat spam

PostPosted: Thu Mar 17, 2016 11:34 am
by darkreignfox
Love the addon, only recently started getting this silly level of spamage from gold sellers and happy there is something out there to stop it.

One question, getting a new notice after the addon was installed: "system message if you have used your current password at another private server please change it through our website for more information"

Re: SpamThrottle: Vanilla addon to reduce chat spam

PostPosted: Fri Mar 18, 2016 11:39 am
by Azonos
Will this block the gold spam whispers as well?

Re: SpamThrottle: Vanilla addon to reduce chat spam

PostPosted: Sun Mar 27, 2016 11:20 am
by Petroix
This addon is broken it hides all messages if I add any keyword.. added .com and gold sellers are still visible, added $ and it hide almost all messages, X messages are hidden every second, gold sellers don't spam so fast, it's not working completly. And /y doesnt work ppl keep spamming every few seconds and this addon doesnt do shit to block them till I set it to 3k seconds but thats stupid cuz it hides important messages too.

Re: SpamThrottle: Vanilla addon to reduce chat spam

PostPosted: Wed Mar 30, 2016 8:11 am
by Soulxlock
Azonos wrote:Will this block the gold spam whispers as well?

Yes it will, if you add the correct catchphrase.

Thanks to the creator of this addon, a must have in my opinion.