1. [Script LUA] Listen to Chat Frame and hide specific words

    Hello, I added to my personal addon some lua lines to hide gold sellers and what I consider spam or anyway not interested into.
    So I added a filter to CHAT_MSG_WHISPER that goes to something like this

    function hide(self, event, message, sender)
    if message:find("gold")
    then
    SendChatMessage("Your message was not delivered due to unwanted words", "WHISPER", nil, sender)
    return true
    end
    end

    It works, when someone whispers to me "gold" or a sentence that contains the word "gold", the function triggers and hides the whisper, and at the same time it sends a whisper back to the sender informing him that the message was not delivered to me.
    The problem is I don't know why, but the sender gets 2-3 even more messages from me. Like if I had multiple SendChatMessage, but I wrote the command only once.

    Any idea about what could be the cause? I want to automatically reply to the "spammers" without flooding them..I just need to send 1 whisper back.
    Thanks let me know if you have any help.
    Edited: July 11, 2018 Reason: typo

  2. Sorry that I know little about LUA, but what if the reply message is for each "gold" of the sentence?

    For example: "Hello!! I want to sell you gold, all the gold you want, just if you pay with something in exchange. www.goldgold.com"
    Maybe what the code does is to reply 4 times, because there are 4 "gold" words.If it's possible, you could try something to check only 1 time the word, if there are more in the same message :D

  3. Nope, I already trying whispering to myself with my alt just "gold" and I got 2x whispers back.

  4. Basically what's going on is your filter function registered by ChatFrame_AddMessageEventFilter is being called once for each chat frame that utilizes the CHAT_MSG_WHISPER event. So what I've done in my projects was use the filter to block messages and create a frame that listens for CHAT_MSG_WHISPER and handle any actions from there.

  5. Basically what's going on is your filter function registered by ChatFrame_AddMessageEventFilter is being called once for each chat frame that utilizes the CHAT_MSG_WHISPER event. So what I've done in my projects was use the filter to block messages and create a frame that listens for CHAT_MSG_WHISPER and handle any actions from there.
    Mmm so let me understand, I need to keep the "ChatFrame_AddMessageEventFilter" leading to the function with the conditions to filter (unwanted keywords) and also create a frame with "OnEvent", listening to CHAT_MSG_WHISPER, with the same exact conditions but with the SendChatMessage added?

  6. Alright, done it! Works perfectly with RegisterEvent Frame, thank you very much!
    I just don't undertand the multiple Frames fired with only 1 whisper..If you want/can explain it, it would be nice, I'm interested.
    Thanks again

  7. ChatFrame_AddMessageEventFilter is a global function exposed by one of Blizzard's addons; you can see a newer implementation of it over here. Every time you get a whisper your filter is called on each chat frame that listens for whispers, it acts as a conditional to allow processing the event any further, and there's more than one chat frame, so it's called multiple times.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •