I am trying to take in a target and have an if statement determine if it's a phone number or the full name. I cant seem to figure out how to find the full name from the iMessage app. Here is what I got so far and it seems to just be when the target is a noninteger.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
launch application "Messages"
tell application "Messages"
set targetService to 1st account whose service type = iMessage
set targetPhoneNumber to "Alejandro Cervantes"
set targetMessageToSend to "Test"
if targetPhoneNumber is not integer then
set targetName to get id of account of participant targetPhoneNumber
set targetBuddy to participant targetPhoneNumber of targetService whose full name is targetPhoneNumber
else
set targetBuddy to participant targetPhoneNumber of targetService
end if
set targetMessage to targetMessageToSend
send targetMessage to targetBuddy
end tell
question from:
https://stackoverflow.com/questions/65909296/imessage-apple-script-trying-to-send-a-message-to-target-that-can-be-the-full 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…