By the time
CHAT_MSG_SAY fires, the message had already been sent to the server. The event is responding to the server saying your message was sent and is an echo. What you'll need to do is replace
SendChatMessage() with a function that does a replacement or blocks the message, then calls the original function if necessary.
Lua Code:
local _SendChatMessage=SendChatMessage;-- Save a reference to the original function
function SendChatMessage(message,...)-- We don't care what the rest of the args are, we just need to pass them on
_SendChatMessage(message:gsub("idiot","moron"),...);-- Replace instances of "idiot" with "moron"
end
I get the sense that the nature of the ban is due to toxicity rather than the language of the message itself. That being said, it would be easy to modify this to just block the message from going out.
Lua Code:
local _SendChatMessage=SendChatMessage;-- Save a reference to the original function
function SendChatMessage(message,...)-- We don't care what the rest of the args are, we just need to pass them on
if not message:find("idiot") then-- Block sending message if it contains "idiot"
_SendChatMessage(message,...);
end
end