I've installed an AppleScript handler from within Messages.app. The script below is called ReceiveMessage.script and is located in ~/Library/Application Scripts/com.apple.iChat and basically accepts messages. That's how I handle inbound messages, and for outbound I basically also have a separate script for sending out messages. I do the actual work in separate python scripts called by the shell scripts though.
-- snip snip --
using terms from application "Messages"
on message received theText from theBuddy for theChat
set quoted_message to quoted form of theText
set quoted_id to quoted form of (id of theBuddy as text)
do shell script "echo " & quoted_message & " | ~/bin/MessageReceive.sh " & quoted_id & " > /dev/null 2>&1 &"
# make messages happy
return true
end message received
on message sent theMessage for theChat
end message sent
on active chat message received
end active chat message received
on chat room message received theMessage from theBuddy for theChat
end chat room message received
on addressed chat room message received theMessage from theBuddy for theChat
end addressed chat room message received
on addressed message received theMessage from theBuddy for theChat
end addressed message received
on av chat started
end av chat started
on av chat ended
end av chat ended
on login finished for theService
end login finished
on logout finished for theService
end logout finished
on buddy became available theBuddy
end buddy became available
on buddy became unavailable theBuddy
end buddy became unavailable
on completed file transfer
end completed file transfer
I like the project, but I really don't like applescript. In programming languages, it seems there is a tension between easy-to-write and easy-to-read. And I suppose a fork in the continuum with easy-to-read-for-novices and easy-to-read-for-programmers.
applescript went overboard on the easy-to-read-for-novices at severe cost to easy-to-write.
What's hard to read about it? Obviously (to me), those are all event handlers. Not sure why (or if?) you have to define the ones that don't actually do anything, though.
I'm pretty sure he's saying that they made it too easy to read, at the expense of being easy to write (with the premise that these are opposite ends of a spectrum stated above)
In some ways, yes. On the other hand, free software is also everywhere.
Linux, Webkit/Blink/Firefox, Apache/nginx, LLVM/GCC, Emacs/Vim… it's a pretty big list.
Instant messaging and Pro Photo/Video apps are a particularly sore point.
-- snip snip --
using terms from application "Messages" on message received theText from theBuddy for theChat set quoted_message to quoted form of theText set quoted_id to quoted form of (id of theBuddy as text) do shell script "echo " & quoted_message & " | ~/bin/MessageReceive.sh " & quoted_id & " > /dev/null 2>&1 &"
end using terms from