2 ms·
I've installed an AppleScript handler from within Messages.app. The script below is called ReceiveMessage.script and is located in ~/Library/Application Scripts
by sgt 10y ago
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
end using terms from
- DigitalJack 10y agoI 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.
- pmarreck 10y agoWhat'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.
- saghm 10y agoI'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)
- josh64 10y agoFWIW you can use JavaScript now instead of AppleScript.
- brennebeck 10y agoThe formatting got borked, but this is very cool. Could I contact you to get additional details? Edit: my email is in my profile
- mattwg 10y agoThanks for following up with details! I wasn't aware you could do this with Messages, that's a nice interface to know about.
- sgt 10y agoSince there was a bit of interest, I wrote this up in a short blog article: https://news.ycombinator.com/item?id=12563526 https://news.ycombinator.com/item?id=12563526