Using AIM to send alerts from Perl

Peter Rukavina

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.

Comments

Submitted by Matthew Sachs on

Permalink


commenting out the line:

<tt>$oscar->commit_buddylist();</tt>



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.


<tt>commit_buddylist()</tt> won’t affect the ability to IM anyone, unless you have visibility mode 5 (VISMODE_PERMITBUDS.) N::O methods which manipulate the buddylist (which include some things that you might not normally expect to be part of the buddylist, but are noted in the documentation) just manipulate some instance variables in the object, <tt>commit_buddylist</tt> is where those changes actually set sent over to the OSCAR server. But again, the only tie between your buddylist and being able to IM people is the visibility stuff.


If a random thing that you worked around by commenting out stuff bothers you, give the current code in CVS a whirl; also, if you like nifty stuff with XML and abstraction, have a gander at OSCAR/XML.pm and OSCAR/XML/ in said CVS.

Add new comment

Plain text

  • Allowed HTML tags: <b> <i> <em> <strong> <blockquote> <code> <ul> <ol> <li>
  • Lines and paragraphs break automatically.

About This Blog

Photo of Peter RukavinaI am . I am a writer, letterpress printer, and a curious person.

To learn more about me, read my /nowlook at my bio, listen to audio I’ve posted, read presentations and speeches I’ve written, or get in touch (peter@rukavina.net is the quickest way). 

You can subscribe to an RSS feed of posts, an RSS feed of comments, or a podcast RSS feed that just contains audio posts. You can also receive a daily digests of posts by email.

Search