Hacking Gmail

(Grace) #1

146 Part II — Getting Inside Gmail


my $aim_user = “”;
my $aim_password = “”;
my $aim_destuser = “”;

my $message = “Your Gmail inbox, $username, has a new message
count of $new_msg”;

$aim = Net::AOLIM->new(‘username’ => $aim_user,
‘password’ => $aim_password,
);

$aim->signon or die “Cannot sign on to AIM”;
$aim->toc_send_im($aim_destuser, $message);

To use this script, place your Gmail and AIM username and passwords in the
variables at the top. (You will need a separate AIM account for the script itself,
which you can sign up for at http://www.aol.com) and then use cron to schedule it to
run at the desired interval.

A good introduction to cron can be found at
http://www.unixgeeks.org/security/newbie/unix/cron-1.html, but I set mine
for this script to the following:
1 * * * * /usr/bin/perl ~/code/gmail2AIM.pl

The preceding code should give you an idea of how you should set up cron.

The second and perhaps more fun way of sending Gmail new mail counts over
AIM is to create an AIM bot. This is a script that logs in as an AIM user and
replies when you “talk” to it. In this case, it’s not going to be particularly clever in
what it says — it will merely reply with the latest count.

To create a bot, start off by logging in to AIM as you did before and then permit-
ting anyone to send you a message:
$aim = Net::AOLIM->new(“username” => $aim_user,
“password” => $aim_password,
“callback” => \&reply,
“allow_srv_settings” => 0,
“login_timeout” => 2 );

$aim->im_permit_all();

$aim -> sign_on();

Once that is in place, set the script on a loop, waiting for an incoming message.
This is done with the Net::AOLIM’s ui_datagetfunction, like so:
Free download pdf