Created
March 20, 2015 02:40
-
-
Save brettcvz/2c73176e49e079ab3d3e to your computer and use it in GitHub Desktop.
JS-Applescript to send iMessages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env osascript -l JavaScript | |
function run(argv) { | |
var to = argv[0]; | |
var msg = argv[1]; | |
console.log("Sending message", "'" + msg + "'", "to", to); | |
messages = Application('Messages'); | |
var service; | |
for (var i in messages.services) { | |
var s = messages.services[i]; | |
var name = s.name(); | |
if (name == "SMS") { | |
service = s; | |
console.log("Sending via SMS"); | |
break; | |
} else if (name.substring(0,2) == "E:") { | |
service = s; | |
console.log("Sending via iMessage"); | |
break; | |
} | |
} | |
recip = service.buddies[to]; | |
messages.send(msg, {to: recip}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I just found this script. I tested but I got always this list of services:
service: E:myicloudemail
service: SMS
service: Google
service: rumbo.com
service: Bonjour
How can I check if the user is available only on SMS or also on iMessage?
Thanks