Show HN: I made a command-line iMessage interface 11 years ago
ive played with this similar before capturing incoming. as well you can write events for messsages in javascript just now with yosemite the same as you would applescript. you can use osacompile and osascript command tools to run and compile javascript/applescript. the same things applescript can do. i find easier to write. doesnt have to be complicated to run for personal use inside ssh.