|
AppleScript
I was written a small applescript to replace some characters in chat message. Here is my code.
property searchList : {"live"}property replaceList : {"love"}to switchText of t from s to r set text item delimiters to s set t to t's text items set text item delimiters to r tell t to set t to beginning & ({""} & rest) tend switchTextto convertText(t) set d to text item delimiters considering case repeat with n from 1 to count searchList set t to switchText of t from my searchList's item n to my replaceList's item n end repeat end considering set text item delimiters to d tend convertTextusing terms from application "Messages" on message sent theMessage for theChat try return convertText(theMessage) end try end message sent on message received theMessage from theBuddy for theChat return convertText(theMessage) end message received on chat room message received theMessage from theBuddy for theChat return convertText(theMessage) end chat room message received end using terms from
This code worked fine for Yahoo account, but it dont work when i received messages from iMessage and Jabber account. I tried to look into Alerts event and i found "Message received in active chat" ,maybe iMessage and Jabber account use this event to alert received message, but the problem is this object not defined in applescript. How can i define it, or make this code work with iMessage and Jabber account.
Mac mini, OS X Mountain Lion (10.8.2) |
|