I can send individual messages on applescript. I can also send to the same message to multiple people. What I can't do is send to a group chat. I've got a group name containing two people named in my icloud and in my contacts and in a current chat. Here's the code I do that with:
import PySimpleGUI as sg
import sys
import subprocess
from os import system, name
from playsound import playsound
people = "Firstname Lastname", "Firstname Lastname"
msg = 'test'
def onCall():
applescript = (
"""
set people to "{0}"
tell application "Messages"
repeat with myBuddy in buddies
--get properties of myBuddy
if name of myBuddy is in people then
send "{1}" to myBuddy
end if
end repeat
end tell
""".format(people, msg
)
)
args = [
item
for x in [("-e", l.strip()) for l in applescript.split("\n") if l.strip() != ""]
for item in x
]
proc = subprocess.Popen(["osascript"] + args, stdout=subprocess.PIPE)
progname = proc.stdout.read().strip()
I call the function with a clickable button that does send messages when the Firstname and Lastname are known contacts.
I don't get an error message. The text just doesn't send when I try to change any of the values to 'TestGroup' (which is what I have my group chat named'.