In the script you receive the text the user just entered as argument0. You can use this text to pre-process the chat message before sending it. Finally the script should return true if the message should still be sent, or false if the message should be discarded.
For example, to check if a chat message starts with "/command", use this code: