iChat: Mass message selected buddies

I am trying to write a script that will allow me to select buddies from a dialog of currently active buddies (one or more from a list) type a message, and send to all of those I’ve selected.

So far I can script it to prompt for what I want to say, and then prompt for who I want to say it to, but I want to be able to send to more then one buddy, and I don’t want to have to type their names.

So I need help with listing the active buddies, then taking the ones I select, and send the message to them. I don’t yet know if this is possible, but I’m assuming it is.

benc4liberty

This should do it:

tell application "iChat"
	set onlineBuds to (handler of every account whose status is available) & (handler of every account whose status is idle)
	set targetBuds to (choose from list onlineBuds with multiple selections allowed)
	if targetBuds is not false then
set myMessage to text returned of (displayd dialog "Enter the message you want to send:" default answer "")
		repeat with targetBud in targetBuds
			send myMessage to (some account whose handler is targetBud)
		end repeat
	end if
end tell

There’s a few things you can customize if you want. First, this script uses Screen Names (“handles” but AS insists on calling the “handlers” for some reason), but you can use “Displayed Names” to get it exactly as it shows up in your iChat window. I just did it this way because some people in my list have more than one screen name but only one “displayed name” which can be confusing. If you want use displayed names, then do a search in the script and replace every occurence of “handler” with “name”.

Second, this script gets a list of people who are available AND people who are idle. you probably don’t need this but I thought I’d include it to just give you an example of how to do something like that. To get rid of it just delte the “&” and everything following it in the second line of the script. If you want a list of all available statuses, open Script Editor, click “Open Dictionary” in the File menu and choose iChat. Click the disclosure triangle by “iChat suite”, and then “Classes” and click on “accounts”. The “status” property lists all possibilities.

Hope this helps.

Script doesn’t work with “handler” in it, but when replaced with name, it works perfectly.

Thanks for the help.