Eric St. Onge

 

 

iChat Scripting

Additions to iChat's AppleScript API to let users respond to chat events.

 

Fall 2007

Professional Project

Apple

iChat 4.0 (Mac OS X 10.5)

Software Engineer

Summary

There is a constant debate on the iChat team over which new features to add to the application. New features need to have a careful balance of engineering effort, value for users, and simplicity in the interface.

There are many features which haven't made it into the application, and likely never will, because they don't quite have that balance. Instead of continually saying "no" to users asking for those features, though, we provide a scripting dictionary that enables them to build some of that functionality themselves.

iChat has had very basic AppleScript support for several years. It had basic commands that let users set their status messages, send messages, and see the list of online buddies.

For Mac OS X 10.5, I expanded iChat's scripting dictionary to include text chats, audio and video chats, and file transfers. These new additions provide access to most of the functionality in the application.

These new additions allowed users to write more advanced scripts, but it still required active control of the application; it did not allow a script to be run in response to something happening in the application. That function is called "event scripting," and I also added that to iChat in Mac OS X 10.5, based on work that had been started by another engineer on the team.

The new event scripting interface is tightly integrated into the application. iChat already allows users to customize the application's behavior for specific events.

Users can choose to customize some of the common events that happen in the application.

For each of those events, a new "event handler" function was added to iChat's scripting dictionary. The event handler specifies the name of the function the user must write which will be executed when the event happens.

For instance, in the above image, you see the "message received" handler. This handler would be executed every time a new message is received. A user could write a basic script that sends a "Thank you" message every time a new message is received.

The user could then choose this script in iChat's preferences.

The next time iChat receives a message, it will send back a "Thank you" message in response.

Users could use the same technique to write more complicated scripts, such as a chat bot or a mechanism to add iChat into an automated workflow. I described these new additions to iChat's scripting dictionary to developers in session at Apple Worldwide Developer Conference in 2006 and 2007.

The new additions to iChat's scripting dictionary in Mac OS X Leopard allow for much more advanced scripts to be written by users. More objects have been exposed for users, and a new event scripting interface allows users to write scripts in response to common events that occur in the application. With these new additions, users can customize iChat for their own ideal behavior.


More Resources

Stuart Cheshire has posted a guide to using iChat Event Scripting to automatically set your status based on your network.

 

knitPro