There's nothing wrong with it as far as I see. Just add the config option to your worldserver.config (since the patch edits the .dist) and test it after applying the patch (manually if there was an error).
The script generates a bug with /afk and /busy, making them to not being removed correctly from your character.
You can't put the code in the middle of the function, you should put it once per condition in HandleMessagechatOpcode (wherever you want it, in my case I put it in every check because I wanted the blue chat in every type of the msg) .