How to send a message using iChat and AppleScript

我的未来我决定 提交于 2019-11-28 04:31:56

问题


I have a need to send a message to a number of people to let them know when an event is occurring. It is always the same list of people, and always the same event, so I would like to script it.

The problem that I have is that I know that I need to use the send command to send the message. And the format of that command is

tell application iChat to send "message" to _buddy_

The problem is how to get that buddy. I know how to get the list of all buddies, and to loop over them:

tell application "iChat"
    repeat with myBuddy in buddies
    end repeat
end tell

What I can't seem to find is how to just get the buddies that I care about, for example those with name "Pietje Piet" and "Joe Anonymous", and then just to send messages to these two contacts.


回答1:


You'll have to aquire a list of the buddies you care about in a separate list somehow. Here's a suggestion:

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


来源:https://stackoverflow.com/questions/9325150/how-to-send-a-message-using-ichat-and-applescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!