SpamMeNot API

This page is only relevent to version 3 of SpamMeNot.
If you've written your own AddOn that receives chat events from World Of Warcraft then you can ask SpamMeNot to filter the events for you in order to stop your AddOn from reacting to spam. By default SpamMeNot filters events for WIM and ChatSounds and you can see how that works by looking at the defaultHooks.lua file within the SpamMeNot folder.

Optional Dependency

If you want SpamMeNot to filter your AddOn's chat events then you'll need to specify SpamMeNot as an optional dependency in your .toc file. For example:
## OptionalDeps: SpamMeNot
This ensures that SpamMeNot, if present, loads before your AddOn and therefore ensures it's functions are available when you need them.

Filtering Chat

Chat filtering is achieved using RegisterEventHandler and UnregisterEventHandler and both of these functions can handle global functions and member functions. Let's pretend your AddOn receives CHAT_MSG_SAY events via a function called MyAddOn_ChatMsgSay(). Here's how you would ask SpamMeNot to filter it.
if SpamMeNot then
    SpamMeNot:RegisterEventHandler("MyAddOn_ChatMsgSay")
end
SpamMeNot will now stop any spam from reaching your MyAddOn_ChatMsgSay function. Note how I checked for the existance of SpamMeNot before trying that - It's important to remember that SpamMeNot may not even be installed on the user's system. If you want to tell SpamMeNot to stop filtering your event you can do so like this:
if SpamMeNot then
    SpamMeNot:UnregisterEventHandler("MyAddOn_ChatMsgSay")
end
A lot of modern AddOns, such as the Ace varienty tend to be object orientated and their event handlers are function members rather than global functions. If this is the case for your AddOn then you have to ask SpamMeNot to filter your event handler slightly differently as you have to specify your object instance as well.
if SpamMeNot then
    SpamMeNot:RegisterEventHandler(MyAddOn, "ChatMsgSay")
end
You can unregister it like this:
if SpamMeNot then
    SpamMeNot:UnregisterEventHandler(MyAddOn, "ChatMsgSay")
end
It's possible to register as many event handlers as you like. Some AddOns route all of their events to the same function and some have a different function for each event.

Filtering Whispers

SpamMeNot has the ability to silently store incoming whispers and then inject them back in to the system once it's verified the level of the sender. This means that whispers can be delayed and if SpamMeNot is filtering your AddOn's events then it needs to also be able to inject a delayed whisper in to your AddOn as well, or your AddOn will never see the message and the sender may think you're rather ignorant. This problem is easily overcome with a flag to tell SpamMeNot that your handler accepts CHAT_MSG_WHISPER events.
if SpamMeNot then
    SpamMeNot:RegisterEventHandler(MyAddOn, "ChatMsgWhisper", true)
    SpamMeNot:RegisterEventHandler(MyAddOn, "ChatMsgSay")
end
The above example demonstrates an AddOn asking SpamMeNot to filter 2 event functions called ChatMsgWhisper and ChatMsgSay. SpamMeNot will inject delayed whispers in to ChatMsgWhisper but not in to ChatMsgSay.

Comments

Posts Quoted:
Reply
Clear All Quotes