I am fond of making text input 'filter' scripts, for example the following script is intended to insert a space between each of the characters of the text input :
using terms from application "Colloquy"
on process outgoing chat message msg in chatView
set msgTxt to (body of msg as string)
set AppleScript's text item delimiters to " "
set msgchars to (characters of msgTxt) as string
set AppleScript's text item delimiters to ""
send chatView message msgchars
return false
end process outgoing chat message
end using terms from
The result of this is that typing 'hello' would appear as 'h e l l o'. (More advanced/specialised filters can easily be imagined).
The problem is that when I 'send' my filtered message from 'process outgoing chat message', 'process outgoing chat message' gets called again, leading to a dead loop.
There are a couple of possible solutions to this problem, but I would suggest an optional extra parameter for 'send' which would ensure that 'process outgoing chat message' does not get called. The exact implementation is not so important however. Whatever works out.