I was messing around with Adium
the other day and noticed that if you right-click while writing a custom away message a context menu comes up with an option to "Insert Script >". Any time I see a script in use somewhere, I wonder what interesting thing I could do with Ruby. So, since it's that time of year, I created a script that shows Obama's current lead (or deficit) in the polls on a state-by-state basis. An example dynamically created message is: "In WA, Obama currently leads by 10.3. ."
I learned the nuts and bolts of how to add these scripts from Paint the Tiger, Carve the Dragon
. Basically, you need to create an Applescript that has a "substitute()" function, put it in "/Applications/Adium.app/Contents/Resources/Scripts/System Statistics.AdiumScripts/", and then edit the Info.plist file (at the same path) to contain the necessary information to tell Adium what to call your script, when to invoke it (what "%_" string to use), and the filename of the script.
Since I wanted to do some network calls and some fairly complicated parsing of those results, I delegated the heavy lifting to a Ruby script and had the Applescript simply execute that ruby script as a shell script. To use the script yourself, unzip this file
. It contains an applescript called Politics.scpt and a directory called "politics" that includes the "politics.rb" ruby script. Copy both the applescript and the "politics" directory to "/Applications/Adium.app/Contents/Resources/Scripts/System Statistics.AdiumScripts/".
You may want to try running the politics.rb file directly to ensure that it will work and you have all the dependencies you need. If anything's awry, you're probably missing the ruby gems hpricot or open-uri. The commands "sudo gem install hpricot" and "sudo gem install open-uri" should fix that.
Then edit the Info.plist file in the above directory, adding the text:
<string>Obama Politics update</string>
Now, after you restart Adium, you should have the "Obama Politics update" option in your "Insert Script" menu when writing your custom away message. Just typing in %_politics
directly should work as well. I don't know how to control Adium's refresh rate on the script, it seems to refresh every 15-30 seconds on its own.