View Single Post
09/29/19, 06:23 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
You could use a ZO_PreHook to the function CHAT_SYSTEM.OnChatEvent like this e.g.

Lua Code:
  1. function MyOnChatEvent(control, ...)
  2.     --Setting enabled?
  3.     secondsSinceMidnight = 0
  4.     if settings.enableChatBlacklist and settings.chatKeyWords ~= nil and settings.chatKeyWords ~= "" then
  5.         if settings.blacklistedTextToChat then
  6.             --Get the current time
  7.             secondsSinceMidnight = GetSecondsSinceMidnight()
  8.         end
  9.         --Filter the incoming chat message now
  10.         local chatMessageWasBlacklisted = MyFunctionToCheckIfMessageWasBlacklistedWithBooleanReturnCode or false
  11.         if chatMessageWasBlacklisted then
  12.             --Abort the chat event function so no text is shown in the chat
  13.             return true
  14.         end
  15.     end
  16.     --Call the original chat event method now to show the text in the chat
  17.     return false
  18. end
  19. ZO_PreHook(CHAT_SYSTEM, "OnChatEvent", MyOnChatEvent)

The secondsSinceMdinight is only there if you want to implement something like a "do not too often" or "wait 2 seconds before next blacklisted message check is done".
  Reply With Quote