Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: I made a command-line iMessage interface (github.com/camhenlin)
130 points by camhenlin on Feb 7, 2015 | hide | past | favorite | 56 comments



Please note that this isn't actually using the iMessage protocol, this just uses AppleScript to fire messages via Messages.app. However, it's nice to finally be able to iMessage over SSH. :)


That's correct. In the future, if time permits, I would like to figure out how to use private APIs within OS X or the Messages.app libraries to send messages without the AppleScript files. Unfortunately that's non-trivial and takes some serious poking around. Right now it's a useful solution for me over ssh so I wanted to share it with the community since I thought others might find that ability useful as well


Agreed! I'm definitely going to lift some of this code for some Alfred workflows too.


Please post it, I'd love to see what you come up with!


## Why did you make this?

Why not?

Regardless of the actual repository (though don't get me wrong, this is still super cool and I like seeing AppleScript in action since I feel like it's criminally underused), this kind of thing in a Readme always brings a grin to my face. Tinkering for tinkering's sake is the best.


"Criminal" is definitely the word to use when it comes to applescript, though maybe not in quite that way.


"Why not?" is fine, but my question is:

What are you going to use it for?


I'd say using iMessage over ssh. What makes your question more valid than 'why make this'?


For those of you who, like me, might want to use this on older hardware, I got an error on launch on Mac OS X 10.8.5 Mountain Lion: https://github.com/CamHenlin/imessageclient/issues/2

Just thought I'd mention it here in case others are thinking of trying this out on Mountain Lion.

Edit: CamHenlin has already committed a fix for this problem. Nice work!


Thanks, hoping that I can help you out!


If it could be ingrated with [WeeChat] [1], it could be a way to provide iMessage support as a [web browser chat client] [2] and to [Android devices] [3].

[1]: https://weechat.org/ [2]: https://github.com/glowing-bear/glowing-bear [3]: https://github.com/ubergeek42/weechat-android


It's "just" using AppleScript for some GUI scripting, it's still using the Messages.app. Still a pretty cool project.


Hi, op here, I also made this last summer for purposes of imessaging on a windows phone: https://github.com/CamHenlin/imessageservice

unfortunately integration with other services is pretty difficult because everything requires routing messages through the OS X messages client


From reading the readme, it seems it only works on a Mac and you have to have messages.app running and logged in.


I know I'll sound like I am an old man yelling "Get off my lawn!", but as far as I can tell this is a text-mode application but it is not a commandline interface. Note that it's only the HN submission title that gets it wrong, the Readme.md on GitHub correctly calls it "terminal-based" rather than CLI.

An actual commandline interface would also be cool, to be able to easily send iMessages from shell scripts, for example.


Sure, you're right, I just got excited typing out the title :) You could actually use the AppleScript files in the repo to send messages directly without the use of the rest of the code. Usage would be like this:

osascript sendmessage_single.AppleScript PHONE_NUMBER_OR_ICLOUD_EMAIL "my message text" false false


Have you looked into using MessagesKit.framework? (In /System/Library/PrivateFrameworks)

If it's written in Obj-C, you can extract fully usable headers from it. If C++/C/etc., it will be difficult (but not impossible) to understand it.

After extracting the headers from that, you may well be able to use it instead of AppleScript.


Thanks for the pointer, exactly the type of response I was hoping to elicit


Really cool. Now I must figure a way to add this as an emacs mode. Good job!


How about a Sublime plugin :)


This is amazing, I have been wanting something like this for some time now. Hopefully the protocol can be demystified such that this is less clumsy.


This has the potential to be some day disruptive to Twilio, Plivo, etc.


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.


Did you tried capturing incoming messages? If yes, please redirect me how to do so.


ANyone know of way or an app to search your iMessage threads?



Different use case (SMS stats), but you can see an example of querying the local iMessage DB here: https://github.com/mroth/grayratio


Spotlight. Alfred. Connect directly to chat.db.

Any of those sound good? :)


Awesome! Is there a way to create a new conversation?


Hi, just wanted to let you know that I added new conversation functionality!


Great thanks!


Not yet, I plan on adding it this evening!


Cool project! Though, the OSX requirement makes its utility pretty limited.

Could someone host iMessage as a service without being sued into oblivion?


Hi, op here, I'm actually working on a hosted solution right now making use of a set of physical Macs and fast user switching. Hoping to have something to show for it in the next several weeks!


I think this is one of those projects we all think about doing, then realize an Apple ID is way too critical to a Mac / iPhone user's security (remote wipe anyone?) to let a third party authenticate with it.

It would be really handy as something I could run on my own mac.


Yeah, the service will essentially be a man in the middle on the account, and I believe it will be very important to communicate that with users. I'll think about releasing a standalone "server" app based on the code although I've already built something somewhat similar (although even "clunkier" if you can imagine that) here: https://github.com/CamHenlin/imessageservice


> Yeah, the service will essentially be a man in the middle on the account, and I believe it will be very important to communicate that with users.

No, it will be very important not to do it, because you are knowingly busting security open on Apple IDs with your service and think that educating users is the best way to mitigate that. We all know most of your users won't know any better. The better way to mitigate it is to not accept Apple IDs in the first place.

If you launch that service, I would feel obligated to tip off the iCloud folks that you're knowingly compromising Apple IDs. That isn't because I want to see you fail, but because you are compromising Apple IDs and your users are caught in the middle.

This is an idea you should let go. I know that sucks to hear.


I generally hate posts that are just a +1 to something, but I feel your point is important enough that it needs echoing. I as well will do the same as you if I see a service like this.


Yeah a server app would be cool.


I don't see Apple being happy with that


Would be nice if users could give you(r service) access to only the imessage key in their icloud keychain.


The protocol isn't open source. It's a cli layer over the messages app so at this point there's no way to "host" it somewhere.


you could host it by using a ton of macs :P


I've previously ran OSX in a VM to send automated alerts over iMessage. It worked rather well.


I've found during my own research that running an OS X VM sending out iMessages for too long will eventually get itself and its host machine blacklisted from iCloud services for a few days. Not sure how they detect the host but I can cause it consistently. I think the VM is blacklisted by its bad SN


Blacklisting/intentional degradation happens with volume sending on a real mac mini too.


Do you have any documentation of precisely when service starts being cut off?


No, sorry; I stopped using iMessage because it wasn't worthwhile to integrate with a system that didn't approve of my use. But when you get cut off, there's no explicit indication, the messages are just not delivered, I think I stopped getting indications that people were on iMessage (the green? bubbles) as well.


Yeah that's what I've come up with in my testing as well. It's kind of surprising that there isn't more research into it. Just all of the sudden iMessages stop sending, then a few days later they magically start sending again


Sounds like your OS is... a POS!


I never actually experienced any rate limiting/blacklisting issues while I ran it. I even tested spamming messages to myself, it worked but upset my iOS notifications a fair bit maybe I just got lucky.


macmini-server-in-a-closet = iMessage on linux over ssh.

I should label it "iMessage server".


Yeah why not?


Anyone know of a CLI client for Microsoft lync?



Bitlbee!!




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: