Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osacript needs to be reworked for Big Sur #12

Closed
thecircleisround opened this issue Jul 19, 2021 · 3 comments
Closed

osacript needs to be reworked for Big Sur #12

thecircleisround opened this issue Jul 19, 2021 · 3 comments

Comments

@thecircleisround
Copy link

thecircleisround commented Jul 19, 2021

Current release does not work correctly with Big Sur. A lot easier to do this now without helper js files but requires knowing account id for the number you want to use which is specific to the machine you are using.

def send_imessage(phone,message):
    accountid = "ACCOUNT_ID"
    script = '''
	tell application "Messages"
        set theBuddy to participant "{}" of account id "{}"
        send "{}" to theBuddy
    end tell
        '''.format(phone,accountid,message)
    Popen(['osascript', '-e', script])

works for me and could be refactored to work with this package

@thecircleisround
Copy link
Author

should note that this method can send iMessage OR SMS depending on the account id

@kevinschaich
Copy link

Made a new package to do this w/ Monterey & later:

https://github.com/kevinschaich/py-imessage-shortcuts

@thecircleisround
Copy link
Author

thecircleisround commented Nov 16, 2021

Cool. I've since been using this:


from subprocess import Popen, PIPE

def send_imessage(phone, message):
    script = f'''
    tell application "Messages"
        set targetService to 1st account whose service type = SMS
        set targetBuddy to participant "{phone}" of targetService
        send "{message}" to targetBuddy
    end tell
    ''' 
    process = Popen(['osascript', '-e', script],stdout=PIPE)
    output = (process.communicate())
    return output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants