Tyler Clemons

Creating Adium Scripts (Random Text)

by on Aug.29, 2008, under Adium, AppleScript, Programming

Adium is a free mesenger client for the Mac OS X.  It allows users to connect to multiple chat services, such as AIM and ICQ, at once.  It is open source, which means users are allowed to tinker with it as they see fit.  With this extensibility, it becomes possible to type something like “/random” and generate a random message.  I decided to take a quick look at what goes on under the hood and decided to give a go at creating some easy scripts.

One of the easiest ways to learn how to create an Adium script is to open up an exisiting script and look at how it works.  Easy enough.  First, we need to setup a file structure.  Create a folder called random.AdiumScripts.  Then right click(CTLR+click), and click ‘show package contents.’  Create a folder called Contents.  Inside Contents, create a folder called Resources.  The result:

->random.AdiumScripts
–>Contents
—->Resources

The next step is to create the actual script.  Enter the Resources folder.  Open up the Script Editor from the Applications folder.  If this is not installed, then just be prepared to save a file using the .scpt extension.  Create a function like this:


on substitute()
set usethis to some item of {"A","B, "C"}
return "Random Line :   " & usethis
end substitute

The on substitute() function will be called every time the script is used.  Inside is an array of strings seperated by commas.  usethis is assigned to some random string inside the array and returned to Adium.  Now the question is, how do we use the script?

Go up one level back to the Contents folder.  Click HERE and drag the info.plist file into the directory.  If you changed any of the defaults, make the appropriate changes.

And that’s it.  Just click on the random.AdiumScripts icon and it should install. Type /random in a chatbox to test the script. That’s the simplest way to do it. There are some other XML properties that can be added but aren’t necessary for personal use. If you plan on publishing on Adium’s website, be sure to add any and all public standards.

You can add more substitutions by creating more script files and more entries into the XML tree. You can also edit the triggers by changing /random to any character sequence.

Your files will be installed in Library/Application Support/Adium 2.0/Scripts

:,

3 Comments for this entry

Leave a Reply

Looking for something?

Use the form below to search the site: