promotional bannermobile promotional banner

McFilter

Abandoned
Library for addon writers to ensure that a callback is only called once, even though WoW spams the message many times.
McFilter adds basic filtering and callback registration for chat messages. The goal is to be simple, lightweight and self contained. Currently supports registering callbacks in response to chat events--does not support chat filter callbacks yet. They will be added shortly. What follows is an example of a simple mod that responds to a whisper with a request for their current DKP. Given that you have this function:
function MyMod.Whisper(dest, str)
  SendChatMessage(str, "WHISPER", nil, dest)
end
 -- Need real logic here, but whatevs.
function MyMod.GetCurrentDkp(who)
  return 100
end
Then, you'd add a filter function, which must be defined before you register the chat callback
function MyMod.OnPotentialRequest(msg, author, language)
  if (msg:find("^![dD][kK][pP]") then
    MyMod.Whisper(string.format("Your current DKP is %.2f", MyMod.GetCurrentDkp(author))
  end
end
You would add a callback first, like this:
  McFilter.RegisterChatCallback("CHAT_MSG_WHISPER", MyMod.OnPotentialRequest)
Additionally, to ensure that your mod won't cause an infinite loop (for example, if your response was "!dkp {resultNum}"), you could modify your MyMod.Whisper(dest, str) to look like this:
function MyMod.Whisper(dest, str)
  McFilter.Ignore(str, UnitName("player"))
  SendChatMessage(str, "WHISPER", nil, dest)
end
Ignore will ignore the specified message from the specified player exactly once, freeing all of your callback functions from needing similar functionality. This mod is required by McDkp.

The McFilter Team

profile avatar
  • 4
    Projects
  • 3.7K
    Downloads

More from _ForgeUser2672656

  • McDkp project image

    McDkp

    • 1.7K
    • Addons

    A dkp auction framework with pluggable rulesets.

    • 1.7K
    • January 21, 2010
    • Addons
    • +2
  • ThreadLite project image

    ThreadLite

    • 569
    • Addons

    Provides a lightweight threading library.

    • 569
    • January 21, 2010
    • Addons
    • +1
  • UpdateSet project image

    UpdateSet

    • 935
    • Addons

    UpdateSet

    • 935
    • June 9, 2009
    • Addons
  • McDkp project image

    McDkp

    • 1.7K
    • Addons

    A dkp auction framework with pluggable rulesets.

    • 1.7K
    • January 21, 2010
    • Addons
    • +2
  • ThreadLite project image

    ThreadLite

    • 569
    • Addons

    Provides a lightweight threading library.

    • 569
    • January 21, 2010
    • Addons
    • +1
  • UpdateSet project image

    UpdateSet

    • 935
    • Addons

    UpdateSet

    • 935
    • June 9, 2009
    • Addons