Hacker News new | ask | show | jobs
by RoseO 4236 days ago
I wrote a little bash script to allow for the sending of iMessages and made a little API in Node so I could send service status messages across all my devices easily.

It's probably not possible to do this in pure Node but if it's of interest here is the gist: https://gist.github.com/roldershaw/7311547

Now I can see iMessage chatbots being made :P

2 comments

Cool, I have something similar cobbled together: http://www.aktau.be/2014/02/12/send-imessages-via-the-comman...

The gist version should even be able to handle input from stdin: https://gist.github.com/aktau/8958054

Like this: ./imessage <number> < notes.txt

I use it quite often :). The most difficult thing to me was getting it to work even when Messages.app wasn't started. Applescript is quite frustrating for someone who's never dealt with it before. This was on Mavericks though, not sure if that's still a problem on Yosemite. Does your version have problems with that?

That's pretty cool, I never bothered handling actually starting the Messages app because I was just running it in a VM and assumed it would always work on startup.

I don't use this anymore because I've ditched my iPhone.

You could probably do this with node-applescript[0].

EDIT: ...which appears to be a simple wrapper around osascript.

[0]: https://github.com/TooTallNate/node-applescript

There's now also the official Javascript for Automation[1], however I'm not sure how much that ties in with node.

[1]: https://developer.apple.com/library/mac/releasenotes/Interap...

Totally different runtime. There's no way (short of IPC) you can interface between node.js and Javascript for Automation. I suppose you could write a CommonJS Modules-compatible shim for Automation, but libraries assuming a node-like environment just wouldn't work.
Yeah, that's what I assumed. I guess it might make 'developing' slightly easier thought, keeping in the same language with Node + Automation, rather than Node + AppleScript.