this is probably a simple question but I am a bit confused as I haven't found many examples online.
I've been able to send messages through Messages in Mac OS using Javascript (Using this tutorial) but I can't figure out how to do it using Python and PyObjC.
Using Javascript I'd do something like this:
var messages = Application('Messages');
var buddy = messages.services["E:%REPLACE_WITH_YOUR_IMESSAGE_EMAIL%"].buddies["%REPLACE_WITH_BUDDYS_EMAIL%"];
messages.send("JavaScript sent this message!", {to: buddy});
I can't figure out how to set the buddy
variable to the relevant object with Python. The following works fine to access Messages
from Foundation import *
from ScriptingBridge import *
Messages = SBApplication.applicationWithBundleIdentifier_("com.apple.iChat")
Then in Python I'm able do something like this.
In [182]: s = Messages.services()
In [183]: [x.name() for x in s]
Out[183]: ['E:foo@icloud.com', 'Bonjour', 'SMS']
But I'm not sure how to make the leap from this to actually getting it to send a message using Messages.send_to_
after I create the Messages object.
Your help would be greatly appreciated, thank you very much!