好友转换的AppleScript名称?

时间:2018-06-01 00:32:59

标签: macos applescript sms messages imessage

我正在编写一个涉及Messages应用程序的脚本,如下所示:

on readFile(theFile)
  -- Convert the file to a string
  set theFile to theFile as string
  -- Read the file and return its contents
  global messageData
  tell application "JSON Helper"
      set messageData to read JSON from (read file theFile)
      set theList to |list| of messageData
      repeat with element from 1 to length of theList
          set currentElement to item element of theList
          log currentElement
          tell application "Messages"
              global _message
              try
                  set _message to message of currentElement
              on error
                  set _message to "How's it going?"
              end try
              set _person to person of currentElement
              set theNumber to buddy _person
              log theNumber
              send _message to theNumber
          end tell
      end repeat
  end tell
end readFile

我有一个文件,我传入这个函数,其内容如下:

{
  "list" : [
      {
          "person":"John Doe",
          "message":"Something Something"
      }
  ]
}

此脚本有效(有点)。我所知道的人并不拥有iPhone,在记录theNumber时,我意识到它正在向该人的电子邮件发送短信,而不是他们的电话数。

AppleScript如何将该名称与好友联系起来? (基本上"伙伴"关键字是如何工作的?)

0 个答案:

没有答案