如何使用 iChat 和 AppleScript 发送消息 [英] How to send a message using iChat and AppleScript
问题描述
我需要向许多人发送消息,让他们知道事件何时发生.它总是相同的人员列表,总是相同的事件,所以我想编写脚本.
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.
我遇到的问题是我知道我需要使用 send 命令来发送消息.该命令的格式是
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
我似乎找不到的是如何只获取我关心的好友,例如名为Pietje Piet"和Joe Anonymous"的好友,然后仅向这两个联系人发送消息.
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.
推荐答案
您必须以某种方式在单独的列表中获取您关心的好友列表.这是一个建议:
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
这篇关于如何使用 iChat 和 AppleScript 发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!