我需要向许多人发送消息,让他们知道事件何时发生。它总是相同的人名单,总是相同的事件,所以我想编写它。

我的问题是我知道我需要使用 send 命令来发送消息。该命令的格式是

tell application iChat to send "message" to _buddy_

问题是如何得到那个伙伴。我知道如何获取所有好友的列表,并遍历它们:
tell application "iChat"
    repeat with myBuddy in buddies
    end repeat
end tell

我似乎无法找到的是如何只获取我关心的好友,例如名为“Pietje Piet”和“Joe Anonymous”的好友,然后仅向这两个联系人发送消息。

最佳答案

您必须以某种方式在单独的列表中获取您关心的好友列表。这是一个建议:

set peopleICareAbout to {"Pietje Piet", "Joe Anonymous"}

tell application "iChat"
    repeat with myBuddy in buddies
        --get properties of myBuddy
        if full name of myBuddy is in peopleICareAbout then
            send "dfgdgdf gdg dfg dfg" to myBuddy
        end if
    end repeat
end tell

关于scripting - 如何使用 iChat 和 AppleScript 发送消息,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9325150/

10-12 12:40