Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
547 views
in Technique[技术] by (71.8m points)

scripting - 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.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...