#!/usr/bin/perl # # TwitterIM Bot Replacement # Version: 0.01 # Author: Marquis Wang # Date: January 7, 2009 use warnings; use Net::OSCAR qw(:standard); # Configuration # Account and password that the bot uses to log in my $aimsn = ''; my $aimpw = ''; # AIM account that is authorized to submit tweets my $myaimsn = ''; # Credentials to post to Twitter my $twittersn = ''; my $twitterpw = ''; sub im_in { my($oscar, $sender, $message, $is_away) = @_; print "$sender: $message\n"; # Some AIM clients send HTML, we need # to convert it to plain text $message =~ s/<(.|\n)+?>//g; # Escape double quotes $message =~ s/\"/\\\"/g; if ( lc($sender) eq lc($myaimsn) ) { system "curl --basic --user $twittersn:$twitterpw --data source=im\\&status=\"$message\" http://twitter.com/statuses/update.xml" } } $oscar = Net::OSCAR->new(); $oscar->set_callback_im_in(\&im_in); $oscar->signon($aimsn, $aimpw); while(1) { $oscar->do_one_loop(); # Do stuff }