Using AIM to send alerts from Perl

The AIMRelay perl script, from Eric Andresen is scratching my itches in all the right ways.

I was looking for a way to have various servers send me alerts through iChat (Apple’s instant messaging system that uses AOL’s instant messaging network). I wanted iChat to pop up a message when, say, a call was coming in for me on the Asterisk PBX. Or when the load average was high. Or when someone posted a comment on my weblog.

I started with Net::OSCAR, which is a Perl module that implement’s the AIM OSCAR protocol (AIM has two protocols, an old one called TOC, that is used by Net::AIM, and OSCAR, which is newer and more functional).

The problem with simply running a Net::OSCAR process every time I want to send a message is that AIM quickly protests if you signon and signoff too quickly in a short space of time — you start to get error messages when you attempt to signon again.

This is where AIMRelay comes it. It creates a sort of “Net::OSCAR daemon” that signs in to AIM once, and then accepts incoming commands (via AIM, telnet, or a Perl client provided) and relays them to the AIM network.

I ran into some problems when initially setting things up: Net::OSCAR was complaining when AIMRelay commited the buddylist:

You must use a tied Net::OSCAR::TLV hash! at /usr/lib/perl5/site_perl/5.8.0/Net/OSCAR/Utility.pm line 139

I solved this problem, for the moment, by commenting out the line:

 $oscar->commit_buddylist();

Doing this hasn’t caused any problems so far, but I understand there may be some ramifications if I try to send messages to AIM screen names that aren’t signed on.

Be aware that AIMRelay has some problems with handling iChat screen names: because they contain an ‘@mac.com’, AIMRelay thinks they’re email addresses and tries to handle them as such. This is trivial to fix, mostly because it simply involves making AIMRelay ‘stupider.’

I’ve been running an AIMRelay-based system for a couple of days now, and things have been working well.