iChat scripting in leopard.

So basically I am using iChat to send out a message to a bunch of people over SMS to let them know if we are playing Ultimate (frisbee) or not, and if so what time. I wrote this script for Tiger, and it worked fine there, but it no longer works in Leopard.

tell application "iChat"
	activate
	set buddyList to {"John Doe", "Bob Radley"}
	repeat with currentBuddy in buddyList
		send "Ultimate at 3pm on Friday, Sept. 21. Reply with yes if you can come and no if you cannot. Thanks." to buddy currentBuddy
		delay 2.5
	end repeat
end tell

where John Doe is the name as it appears on my buddy list, and in my address book. The sn associated with that nae is the cell phone number (in the right format) of that person, well say +18005551234 for John Doe. In Tiger, this script worked fine, but in Leopard, it no longer works. It returns the error [Can’t get buddy “John Doe”] so i try using the screen name instead, +18005551234 instead of John Doe, and it works (it did not work in tiger). I was wondering if there was a way that I could make it work with John Doe so I don’t have to go change all the names to the numbers. I add people and remove people all the time, and it is much easier to just use their names instead of their numbers.

Thanks for your help,
Andy

Hi,

Apple did major changes in the dictionary of iChat in Leopard, one of them is a own element buddy with many properties.
The direct identification works either by id or by (screen)name.

To solve your problem, use something like this

tell application "iChat"
	activate
	set buddyList to {"John Doe", "Bob Radley"}
	repeat with currentBuddy in buddyList
		send "Ultimate at 3pm on Friday, Sept. 21. Reply with yes if you can come and no if you cannot. Thanks." to 1st buddy whose full name is currentBuddy
		delay 2.5
	end repeat
end tell

But hey, you can use AppleScript to “translate” the full names into screennames


tell application "iChat"
	set FullNameList to {"John Doe", "Bob Radley"}
	set screenNameList to {}
	repeat with currentBuddy in FullNameList
		set end of screenNameList to name of (1st buddy whose full name is currentBuddy)
	end repeat
end tell
screenNameList

you can replace your buddyList with the result

Wow, that was quick. Thank you very much. That works, and now I know how to modify my list easily if 10.6 screws it up again.