Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Last active December 14, 2015 20:48
Show Gist options
  • Save ELLIOTTCABLE/5145919 to your computer and use it in GitHub Desktop.
Save ELLIOTTCABLE/5145919 to your computer and use it in GitHub Desktop.
Tell her so. (= #AppleScript #nodejs #JavaScript #MacOSX #iMessage
cp = require 'child_process'
handle = 'imessage@somebody.tld'
message = 'I love you.'
interval = 15
love = ->
osascript = cp.spawn 'osascript', [], {stdio: ['pipe', 1, 2]}
console.log '-- Spawning `osascript`'
osascript.stdin.write """
tell application "Messages"
set theServices to every service whose name starts with "E:"
set theService to first item of theServices
send "#{ message } " to the the buddy "#{ handle }" of theService
end tell
""", ->
osascript.stdin.end()
setInterval love, interval *60*1000
love()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment